1 //===-- DWARFIndex.cpp -----------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "Plugins/SymbolFile/DWARF/DWARFIndex.h"
10 #include "Plugins/Language/ObjC/ObjCLanguage.h"
11 #include "Plugins/SymbolFile/DWARF/DWARFDIE.h"
12 #include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
14 using namespace lldb_private;
17 DWARFIndex::~DWARFIndex() = default;
19 void DWARFIndex::ProcessFunctionDIE(llvm::StringRef name, DIERef ref,
20 SymbolFileDWARF &dwarf,
21 const CompilerDeclContext &parent_decl_ctx,
22 uint32_t name_type_mask,
23 std::vector<DWARFDIE> &dies) {
24 DWARFDIE die = dwarf.GetDIE(ref);
26 ReportInvalidDIERef(ref, name);
30 // Exit early if we're searching exclusively for methods or selectors and
31 // we have a context specified (no methods in namespaces).
32 uint32_t looking_for_nonmethods =
33 name_type_mask & ~(eFunctionNameTypeMethod | eFunctionNameTypeSelector);
34 if (!looking_for_nonmethods && parent_decl_ctx.IsValid())
37 // Otherwise, we need to also check that the context matches. If it does not
38 // match, we do nothing.
39 if (!SymbolFileDWARF::DIEInDeclContext(&parent_decl_ctx, die))
42 // In case of a full match, we just insert everything we find.
43 if (name_type_mask & eFunctionNameTypeFull) {
48 // If looking for ObjC selectors, we need to also check if the name is a
50 if (name_type_mask & eFunctionNameTypeSelector &&
51 ObjCLanguage::IsPossibleObjCMethodName(die.GetName())) {
56 bool looking_for_methods = name_type_mask & lldb::eFunctionNameTypeMethod;
57 bool looking_for_functions = name_type_mask & lldb::eFunctionNameTypeBase;
58 if (looking_for_methods || looking_for_functions) {
59 // If we're looking for either methods or functions, we definitely want this
60 // die. Otherwise, only keep it if the die type matches what we are
62 if ((looking_for_methods && looking_for_functions) ||
63 looking_for_methods == die.IsMethod())