[Lldb-commits] [lldb] ce512d5 - Revert "[lldb] Refactor Module::LookupInfo constructor"
Alex Langford via lldb-commits
lldb-commits at lists.llvm.org
Tue Aug 24 14:53:03 PDT 2021
Author: Alex Langford
Date: 2021-08-24T14:52:17-07:00
New Revision: ce512d5c2af58515378f5ecd989cdc0ccea8c997
URL: https://github.com/llvm/llvm-project/commit/ce512d5c2af58515378f5ecd989cdc0ccea8c997
DIFF: https://github.com/llvm/llvm-project/commit/ce512d5c2af58515378f5ecd989cdc0ccea8c997.diff
LOG: Revert "[lldb] Refactor Module::LookupInfo constructor"
This reverts commit cd2134e42aa7d1168a3ed54e41793b022f961b1f.
Seems like this broke some tests on arm and aarch64 boxes. Will
investigate before re-landing.
Added:
Modified:
lldb/include/lldb/Core/Module.h
lldb/include/lldb/Target/Language.h
lldb/source/Core/CMakeLists.txt
lldb/source/Core/Module.cpp
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
Removed:
################################################################################
diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h
index 07f75191ca74d..767f2d232947c 100644
--- a/lldb/include/lldb/Core/Module.h
+++ b/lldb/include/lldb/Core/Module.h
@@ -896,7 +896,7 @@ class Module : public std::enable_shared_from_this<Module>,
LookupInfo() : m_name(), m_lookup_name() {}
LookupInfo(ConstString name, lldb::FunctionNameType name_type_mask,
- lldb::LanguageType language_type);
+ lldb::LanguageType language);
ConstString GetName() const { return m_name; }
@@ -922,7 +922,7 @@ class Module : public std::enable_shared_from_this<Module>,
ConstString m_lookup_name;
/// Limit matches to only be for this language
- lldb::LanguageType m_language_type = lldb::eLanguageTypeUnknown;
+ lldb::LanguageType m_language = lldb::eLanguageTypeUnknown;
/// One or more bits from lldb::FunctionNameType that indicate what kind of
/// names we are looking for
diff --git a/lldb/include/lldb/Target/Language.h b/lldb/include/lldb/Target/Language.h
index 73cba0726be64..2ad9677ea3f8c 100644
--- a/lldb/include/lldb/Target/Language.h
+++ b/lldb/include/lldb/Target/Language.h
@@ -202,20 +202,6 @@ class Language : public PluginInterface {
return std::vector<Language::MethodNameVariant>();
};
- class FunctionNameInfo {
- public:
- llvm::StringRef basename;
- llvm::StringRef context;
- lldb::FunctionNameType func_name_type;
- };
-
- virtual Language::FunctionNameInfo
- GetFunctionNameInfo(ConstString name) const {
- FunctionNameInfo ret;
- ret.func_name_type = lldb::eFunctionNameTypeNone;
- return ret;
- };
-
/// Returns true iff the given symbol name is compatible with the mangling
/// scheme of this language.
///
diff --git a/lldb/source/Core/CMakeLists.txt b/lldb/source/Core/CMakeLists.txt
index 2257b883fc403..65be803addf5f 100644
--- a/lldb/source/Core/CMakeLists.txt
+++ b/lldb/source/Core/CMakeLists.txt
@@ -82,6 +82,7 @@ add_lldb_library(lldbCore
lldbTarget
lldbUtility
lldbPluginCPlusPlusLanguage
+ lldbPluginObjCLanguage
${LLDB_CURSES_LIBS}
CLANG_LIBS
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index 16308d9dd0b88..c7538db7dd240 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -51,6 +51,7 @@
#endif
#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
+#include "Plugins/Language/ObjC/ObjCLanguage.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/Compiler.h"
@@ -634,81 +635,101 @@ void Module::FindCompileUnits(const FileSpec &path,
Module::LookupInfo::LookupInfo(ConstString name,
FunctionNameType name_type_mask,
- LanguageType language_type)
- : m_name(name), m_lookup_name(name), m_language_type(language_type),
+ LanguageType language)
+ : m_name(name), m_lookup_name(), m_language(language),
m_name_type_mask(eFunctionNameTypeNone),
m_match_name_after_lookup(false) {
+ const char *name_cstr = name.GetCString();
llvm::StringRef basename;
llvm::StringRef context;
- std::vector<Language *> languages;
- Language::ForEach([&languages](Language *l) {
- languages.push_back(l);
- return true;
- });
-
if (name_type_mask & eFunctionNameTypeAuto) {
- if (language_type == eLanguageTypeUnknown) {
- for (Language *lang : languages) {
- Language::FunctionNameInfo info = lang->GetFunctionNameInfo(name);
- if (info.func_name_type != eFunctionNameTypeNone) {
- m_name_type_mask = info.func_name_type;
- basename = info.basename;
- context = info.context;
- break;
- }
- }
+ if (CPlusPlusLanguage::IsCPPMangledName(name_cstr))
+ m_name_type_mask = eFunctionNameTypeFull;
+ else if ((language == eLanguageTypeUnknown ||
+ Language::LanguageIsObjC(language)) &&
+ ObjCLanguage::IsPossibleObjCMethodName(name_cstr))
+ m_name_type_mask = eFunctionNameTypeFull;
+ else if (Language::LanguageIsC(language)) {
+ m_name_type_mask = eFunctionNameTypeFull;
} else {
- if (auto *lang = Language::FindPlugin(language_type)) {
- Language::FunctionNameInfo info = lang->GetFunctionNameInfo(name);
- m_name_type_mask = info.func_name_type;
- basename = info.basename;
- context = info.context;
+ if ((language == eLanguageTypeUnknown ||
+ Language::LanguageIsObjC(language)) &&
+ ObjCLanguage::IsPossibleObjCSelector(name_cstr))
+ m_name_type_mask |= eFunctionNameTypeSelector;
+
+ CPlusPlusLanguage::MethodName cpp_method(name);
+ basename = cpp_method.GetBasename();
+ if (basename.empty()) {
+ if (CPlusPlusLanguage::ExtractContextAndIdentifier(name_cstr, context,
+ basename))
+ m_name_type_mask |= (eFunctionNameTypeMethod | eFunctionNameTypeBase);
+ else
+ m_name_type_mask |= eFunctionNameTypeFull;
+ } else {
+ m_name_type_mask |= (eFunctionNameTypeMethod | eFunctionNameTypeBase);
}
}
-
- // NOTE: There are several ways to get here, but this is a fallback path in
- // case the above does not succeed at extracting any useful information from
- // the loaded language plugins.
- if (m_name_type_mask == eFunctionNameTypeNone)
- m_name_type_mask = eFunctionNameTypeFull;
-
} else {
m_name_type_mask = name_type_mask;
- if (language_type != eLanguageTypeUnknown) {
- if (auto *lang = Language::FindPlugin(language_type)) {
- Language::FunctionNameInfo info = lang->GetFunctionNameInfo(name);
- if (info.func_name_type & m_name_type_mask) {
- // If the user asked for FunctionNameTypes that aren't possible,
- // then filter those out. (e.g. asking for Selectors on
- // C++ symbols, or even if the symbol given can't be a selector in
- // ObjC)
- m_name_type_mask &= info.func_name_type;
- basename = info.basename;
- context = info.context;
+ if (name_type_mask & eFunctionNameTypeMethod ||
+ name_type_mask & eFunctionNameTypeBase) {
+ // If they've asked for a CPP method or function name and it can't be
+ // that, we don't even need to search for CPP methods or names.
+ CPlusPlusLanguage::MethodName cpp_method(name);
+ if (cpp_method.IsValid()) {
+ basename = cpp_method.GetBasename();
+
+ if (!cpp_method.GetQualifiers().empty()) {
+ // There is a "const" or other qualifier following the end of the
+ // function parens, this can't be a eFunctionNameTypeBase
+ m_name_type_mask &= ~(eFunctionNameTypeBase);
+ if (m_name_type_mask == eFunctionNameTypeNone)
+ return;
}
+ } else {
+ // If the CPP method parser didn't manage to chop this up, try to fill
+ // in the base name if we can. If a::b::c is passed in, we need to just
+ // look up "c", and then we'll filter the result later.
+ CPlusPlusLanguage::ExtractContextAndIdentifier(name_cstr, context,
+ basename);
}
- } else {
- for (Language *lang : languages) {
- Language::FunctionNameInfo info = lang->GetFunctionNameInfo(name);
- if (info.func_name_type & m_name_type_mask) {
- m_name_type_mask &= info.func_name_type;
- basename = info.basename;
- context = info.context;
- break;
- }
+ }
+
+ if (name_type_mask & eFunctionNameTypeSelector) {
+ if (!ObjCLanguage::IsPossibleObjCSelector(name_cstr)) {
+ m_name_type_mask &= ~(eFunctionNameTypeSelector);
+ if (m_name_type_mask == eFunctionNameTypeNone)
+ return;
+ }
+ }
+
+ // Still try and get a basename in case someone specifies a name type mask
+ // of eFunctionNameTypeFull and a name like "A::func"
+ if (basename.empty()) {
+ if (name_type_mask & eFunctionNameTypeFull &&
+ !CPlusPlusLanguage::IsCPPMangledName(name_cstr)) {
+ CPlusPlusLanguage::MethodName cpp_method(name);
+ basename = cpp_method.GetBasename();
+ if (basename.empty())
+ CPlusPlusLanguage::ExtractContextAndIdentifier(name_cstr, context,
+ basename);
}
}
}
if (!basename.empty()) {
- // The name supplied was incomplete for lookup purposes. For example, in C++
- // we may have gotten something like "a::count". In this case, we want to do
- // a lookup on the basename "count" and then make sure any matching results
- // contain "a::count" so that it would match "b::a::count" and "a::count".
- // This is why we set match_name_after_lookup to true.
+ // The name supplied was a partial C++ path like "a::count". In this case
+ // we want to do a lookup on the basename "count" and then make sure any
+ // matching results contain "a::count" so that it would match "b::a::count"
+ // and "a::count". This is why we set "match_name_after_lookup" to true
m_lookup_name.SetString(basename);
m_match_name_after_lookup = true;
+ } else {
+ // The name is already correct, just use the exact name as supplied, and we
+ // won't need to check if any matches contain "name"
+ m_lookup_name = name;
+ m_match_name_after_lookup = false;
}
}
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 3e57951471c46..814bfe28ca31a 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -59,39 +59,6 @@ lldb_private::ConstString CPlusPlusLanguage::GetPluginNameStatic() {
return g_name;
}
-Language::FunctionNameInfo
-CPlusPlusLanguage::GetFunctionNameInfo(ConstString name) const {
- FunctionNameInfo info;
- info.func_name_type = lldb::eFunctionNameTypeNone;
-
- if (IsCPPMangledName(name.GetCString())) {
- info.func_name_type = lldb::eFunctionNameTypeFull;
- }
-
- CPlusPlusLanguage::MethodName method(name);
- llvm::StringRef basename = method.GetBasename();
- if (basename.empty()) {
- if (CPlusPlusLanguage::ExtractContextAndIdentifier(
- name.GetCString(), info.context, info.basename)) {
- info.func_name_type |=
- (lldb::eFunctionNameTypeMethod | eFunctionNameTypeBase);
- } else {
- info.func_name_type |= lldb::eFunctionNameTypeFull;
- }
- } else {
- info.func_name_type |=
- (lldb::eFunctionNameTypeMethod | eFunctionNameTypeBase);
- }
-
- if (!method.GetQualifiers().empty()) {
- // There is a 'const' or other qualifier following the end of the function
- // parens, this can't be a eFunctionNameTypeBase.
- info.func_name_type &= ~(lldb::eFunctionNameTypeBase);
- }
-
- return info;
-}
-
bool CPlusPlusLanguage::SymbolNameFitsToLanguage(Mangled mangled) const {
const char *mangled_name = mangled.GetMangledName().GetCString();
return mangled_name && CPlusPlusLanguage::IsCPPMangledName(mangled_name);
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
index 985820d24d8a5..46d708bec192a 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
@@ -104,9 +104,6 @@ class CPlusPlusLanguage : public Language {
static lldb_private::ConstString GetPluginNameStatic();
- Language::FunctionNameInfo
- GetFunctionNameInfo(ConstString name) const override;
-
bool SymbolNameFitsToLanguage(Mangled mangled) const override;
ConstString
diff --git a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
index 46cf5ce3910cd..613b2fb2d8a5a 100644
--- a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
+++ b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
@@ -275,22 +275,6 @@ ObjCLanguage::GetMethodNameVariants(ConstString method_name) const {
return variant_names;
}
-Language::FunctionNameInfo
-ObjCLanguage::GetFunctionNameInfo(ConstString name) const {
- Language::FunctionNameInfo info;
- info.func_name_type = lldb::eFunctionNameTypeNone;
-
- if (ObjCLanguage::IsPossibleObjCMethodName(name.GetCString())) {
- info.func_name_type = lldb::eFunctionNameTypeFull;
- }
-
- if (ObjCLanguage::IsPossibleObjCSelector(name.GetCString())) {
- info.func_name_type |= lldb::eFunctionNameTypeSelector;
- }
-
- return info;
-}
-
bool ObjCLanguage::SymbolNameFitsToLanguage(Mangled mangled) const {
ConstString demangled_name = mangled.GetDemangledName();
if (!demangled_name)
diff --git a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
index 38a5572900989..691c51883c8a3 100644
--- a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
+++ b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
@@ -104,9 +104,6 @@ class ObjCLanguage : public Language {
std::vector<Language::MethodNameVariant>
GetMethodNameVariants(ConstString method_name) const override;
- Language::FunctionNameInfo
- GetFunctionNameInfo(ConstString name) const override;
-
bool SymbolNameFitsToLanguage(Mangled mangled) const override;
lldb::TypeCategoryImplSP GetFormatters() override;
More information about the lldb-commits
mailing list