[Lldb-commits] [lldb] r369702 - Revert Extend FindTypes with CompilerContext to allow filtering by language.
Adrian Prantl via lldb-commits
lldb-commits at lists.llvm.org
Thu Aug 22 13:41:16 PDT 2019
Author: adrian
Date: Thu Aug 22 13:41:16 2019
New Revision: 369702
URL: http://llvm.org/viewvc/llvm-project?rev=369702&view=rev
Log:
Revert Extend FindTypes with CompilerContext to allow filtering by language.
This reverts r369690 (git commit aa3a564efa6b5fff2129f81a4041069a0233168f)
Modified:
lldb/trunk/include/lldb/Core/PluginManager.h
lldb/trunk/include/lldb/Symbol/ClangASTContext.h
lldb/trunk/include/lldb/Symbol/SymbolFile.h
lldb/trunk/include/lldb/Symbol/TypeSystem.h
lldb/trunk/include/lldb/Target/Language.h
lldb/trunk/include/lldb/lldb-private-interfaces.h
lldb/trunk/lit/SymbolFile/DWARF/compilercontext.ll
lldb/trunk/source/Core/Debugger.cpp
lldb/trunk/source/Core/PluginManager.cpp
lldb/trunk/source/Interpreter/OptionValueLanguage.cpp
lldb/trunk/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
lldb/trunk/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
lldb/trunk/source/Symbol/ClangASTContext.cpp
lldb/trunk/source/Symbol/SymbolFile.cpp
lldb/trunk/source/Symbol/TypeSystem.cpp
lldb/trunk/source/Target/Language.cpp
lldb/trunk/source/Target/Target.cpp
lldb/trunk/tools/lldb-test/lldb-test.cpp
Modified: lldb/trunk/include/lldb/Core/PluginManager.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/PluginManager.h?rev=369702&r1=369701&r2=369702&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/PluginManager.h (original)
+++ lldb/trunk/include/lldb/Core/PluginManager.h Thu Aug 22 13:41:16 2019
@@ -385,10 +385,10 @@ public:
GetInstrumentationRuntimeCreateCallbackForPluginName(ConstString name);
// TypeSystem
- static bool RegisterPlugin(ConstString name, const char *description,
- TypeSystemCreateInstance create_callback,
- LanguageSet supported_languages_for_types,
- LanguageSet supported_languages_for_expressions);
+ static bool RegisterPlugin(
+ ConstString name, const char *description,
+ TypeSystemCreateInstance create_callback,
+ TypeSystemEnumerateSupportedLanguages enumerate_languages_callback);
static bool UnregisterPlugin(TypeSystemCreateInstance create_callback);
@@ -398,14 +398,18 @@ public:
static TypeSystemCreateInstance
GetTypeSystemCreateCallbackForPluginName(ConstString name);
- static LanguageSet GetAllTypeSystemSupportedLanguagesForTypes();
+ static TypeSystemEnumerateSupportedLanguages
+ GetTypeSystemEnumerateSupportedLanguagesCallbackAtIndex(uint32_t idx);
- static LanguageSet GetAllTypeSystemSupportedLanguagesForExpressions();
+ static TypeSystemEnumerateSupportedLanguages
+ GetTypeSystemEnumerateSupportedLanguagesCallbackForPluginName(
+ ConstString name);
// REPL
- static bool RegisterPlugin(ConstString name, const char *description,
- REPLCreateInstance create_callback,
- LanguageSet supported_languages);
+ static bool
+ RegisterPlugin(ConstString name, const char *description,
+ REPLCreateInstance create_callback,
+ REPLEnumerateSupportedLanguages enumerate_languages_callback);
static bool UnregisterPlugin(REPLCreateInstance create_callback);
@@ -414,7 +418,12 @@ public:
static REPLCreateInstance
GetREPLCreateCallbackForPluginName(ConstString name);
- static LanguageSet GetREPLAllTypeSystemSupportedLanguages();
+ static REPLEnumerateSupportedLanguages
+ GetREPLEnumerateSupportedLanguagesCallbackAtIndex(uint32_t idx);
+
+ static REPLEnumerateSupportedLanguages
+ GetREPLSystemEnumerateSupportedLanguagesCallbackForPluginName(
+ ConstString name);
// Some plug-ins might register a DebuggerInitializeCallback callback when
// registering the plug-in. After a new Debugger instance is created, this
@@ -432,28 +441,32 @@ public:
ConstString description, bool is_global_property);
static lldb::OptionValuePropertiesSP
- GetSettingForPlatformPlugin(Debugger &debugger, ConstString setting_name);
+ GetSettingForPlatformPlugin(Debugger &debugger,
+ ConstString setting_name);
static bool CreateSettingForPlatformPlugin(
Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
ConstString description, bool is_global_property);
static lldb::OptionValuePropertiesSP
- GetSettingForProcessPlugin(Debugger &debugger, ConstString setting_name);
+ GetSettingForProcessPlugin(Debugger &debugger,
+ ConstString setting_name);
static bool CreateSettingForProcessPlugin(
Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
ConstString description, bool is_global_property);
static lldb::OptionValuePropertiesSP
- GetSettingForSymbolFilePlugin(Debugger &debugger, ConstString setting_name);
+ GetSettingForSymbolFilePlugin(Debugger &debugger,
+ ConstString setting_name);
static bool CreateSettingForSymbolFilePlugin(
Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
ConstString description, bool is_global_property);
static lldb::OptionValuePropertiesSP
- GetSettingForJITLoaderPlugin(Debugger &debugger, ConstString setting_name);
+ GetSettingForJITLoaderPlugin(Debugger &debugger,
+ ConstString setting_name);
static bool CreateSettingForJITLoaderPlugin(
Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=369702&r1=369701&r2=369702&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original)
+++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Thu Aug 22 13:41:16 2019
@@ -68,8 +68,9 @@ public:
static lldb::TypeSystemSP CreateInstance(lldb::LanguageType language,
Module *module, Target *target);
- static LanguageSet GetSupportedLanguagesForTypes();
- static LanguageSet GetSupportedLanguagesForExpressions();
+ static void EnumerateSupportedLanguages(
+ std::set<lldb::LanguageType> &languages_for_types,
+ std::set<lldb::LanguageType> &languages_for_expressions);
static void Initialize();
Modified: lldb/trunk/include/lldb/Symbol/SymbolFile.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolFile.h?rev=369702&r1=369701&r2=369702&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/SymbolFile.h (original)
+++ lldb/trunk/include/lldb/Symbol/SymbolFile.h Thu Aug 22 13:41:16 2019
@@ -17,7 +17,6 @@
#include "lldb/Symbol/SourceModule.h"
#include "lldb/Symbol/Type.h"
#include "lldb/Symbol/TypeList.h"
-#include "lldb/Symbol/TypeSystem.h"
#include "lldb/lldb-private.h"
#include "llvm/ADT/DenseSet.h"
@@ -190,11 +189,7 @@ public:
bool append, uint32_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeMap &types);
-
- /// Find types specified by a CompilerContextPattern.
- /// \param languages Only return results in these languages.
- virtual size_t FindTypes(llvm::ArrayRef<CompilerContext> pattern,
- LanguageSet languages, bool append,
+ virtual size_t FindTypes(llvm::ArrayRef<CompilerContext> pattern, bool append,
TypeMap &types);
virtual void
Modified: lldb/trunk/include/lldb/Symbol/TypeSystem.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/TypeSystem.h?rev=369702&r1=369701&r2=369702&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/TypeSystem.h (original)
+++ lldb/trunk/include/lldb/Symbol/TypeSystem.h Thu Aug 22 13:41:16 2019
@@ -15,7 +15,6 @@
#include <string>
#include "llvm/ADT/APSInt.h"
-#include "llvm/ADT/SmallBitVector.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Error.h"
@@ -31,24 +30,7 @@ class PDBASTParser;
namespace lldb_private {
-/// A SmallBitVector that represents a set of source languages (\p
-/// lldb::LanguageType). Each lldb::LanguageType is represented by
-/// the bit with the position of its enumerator. The largest
-/// LanguageType is < 64, so this is space-efficient and on 64-bit
-/// architectures a LanguageSet can be completely stack-allocated.
-struct LanguageSet {
- llvm::SmallBitVector bitvector;
- LanguageSet() = default;
-
- /// If the set contains a single language only, return it.
- llvm::Optional<lldb::LanguageType> GetSingularLanguage();
- void Insert(lldb::LanguageType language);
- bool Empty() const;
- size_t Size() const;
- bool operator[](unsigned i) const;
-};
-
-/// Interface for representing the Type Systems in different languages.
+// Interface for representing the Type Systems in different languages.
class TypeSystem : public PluginInterface {
public:
// Intrusive type system that allows us to use llvm casting.
Modified: lldb/trunk/include/lldb/Target/Language.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Language.h?rev=369702&r1=369701&r2=369702&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Language.h (original)
+++ lldb/trunk/include/lldb/Target/Language.h Thu Aug 22 13:41:16 2019
@@ -267,9 +267,12 @@ public:
static std::set<lldb::LanguageType> GetSupportedLanguages();
- static LanguageSet GetLanguagesSupportingTypeSystems();
- static LanguageSet GetLanguagesSupportingTypeSystemsForExpressions();
- static LanguageSet GetLanguagesSupportingREPLs();
+ static void GetLanguagesSupportingTypeSystems(
+ std::set<lldb::LanguageType> &languages,
+ std::set<lldb::LanguageType> &languages_for_expressions);
+
+ static void
+ GetLanguagesSupportingREPLs(std::set<lldb::LanguageType> &languages);
protected:
// Classes that inherit from Language can see and modify these
Modified: lldb/trunk/include/lldb/lldb-private-interfaces.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-private-interfaces.h?rev=369702&r1=369701&r2=369702&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-private-interfaces.h (original)
+++ lldb/trunk/include/lldb/lldb-private-interfaces.h Thu Aug 22 13:41:16 2019
@@ -102,6 +102,11 @@ typedef lldb::REPLSP (*REPLCreateInstanc
lldb::LanguageType language,
Debugger *debugger, Target *target,
const char *repl_options);
+typedef void (*TypeSystemEnumerateSupportedLanguages)(
+ std::set<lldb::LanguageType> &languages_for_types,
+ std::set<lldb::LanguageType> &languages_for_expressions);
+typedef void (*REPLEnumerateSupportedLanguages)(
+ std::set<lldb::LanguageType> &languages);
typedef int (*ComparisonFunction)(const void *, const void *);
typedef void (*DebuggerInitializeCallback)(Debugger &debugger);
Modified: lldb/trunk/lit/SymbolFile/DWARF/compilercontext.ll
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/DWARF/compilercontext.ll?rev=369702&r1=369701&r2=369702&view=diff
==============================================================================
--- lldb/trunk/lit/SymbolFile/DWARF/compilercontext.ll (original)
+++ lldb/trunk/lit/SymbolFile/DWARF/compilercontext.ll Thu Aug 22 13:41:16 2019
@@ -1,21 +1,18 @@
; Test finding types by CompilerContext.
; RUN: llc %s -filetype=obj -o %t.o
-; RUN: lldb-test symbols %t.o -find=type --language=C99 \
+; RUN: lldb-test symbols %t.o -find=type \
; RUN: -compiler-context="Module:CModule,Module:SubModule,Struct:FromSubmoduleX" \
; RUN: | FileCheck %s --check-prefix=NORESULTS
-; RUN: lldb-test symbols %t.o -find=type --language=C++ \
-; RUN: -compiler-context="Module:CModule,Module:SubModule,Struct:FromSubmodule" \
-; RUN: | FileCheck %s --check-prefix=NORESULTS
-; RUN: lldb-test symbols %t.o -find=type --language=C99 \
+; RUN: lldb-test symbols %t.o -find=type \
; RUN: -compiler-context="Module:CModule,Module:SubModule,Struct:FromSubmodule" \
; RUN: | FileCheck %s
-; RUN: lldb-test symbols %t.o -find=type --language=C99 \
+; RUN: lldb-test symbols %t.o -find=type \
; RUN: -compiler-context="Module:CModule,AnyModule:*,Struct:FromSubmodule" \
; RUN: | FileCheck %s
-; RUN: lldb-test symbols %t.o -find=type --language=C99 \
+; RUN: lldb-test symbols %t.o -find=type \
; RUN: -compiler-context="AnyModule:*,Struct:FromSubmodule" \
; RUN: | FileCheck %s
-; RUN: lldb-test symbols %t.o -find=type --language=C99 \
+; RUN: lldb-test symbols %t.o -find=type \
; RUN: -compiler-context="Module:CModule,Module:SubModule,AnyType:FromSubmodule" \
; RUN: | FileCheck %s
;
Modified: lldb/trunk/source/Core/Debugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=369702&r1=369701&r2=369702&view=diff
==============================================================================
--- lldb/trunk/source/Core/Debugger.cpp (original)
+++ lldb/trunk/source/Core/Debugger.cpp Thu Aug 22 13:41:16 2019
@@ -1623,11 +1623,13 @@ Status Debugger::RunREPL(LanguageType la
FileSpec repl_executable;
if (language == eLanguageTypeUnknown) {
- LanguageSet repl_languages = Language::GetLanguagesSupportingREPLs();
+ std::set<LanguageType> repl_languages;
- if (auto single_lang = repl_languages.GetSingularLanguage()) {
- language = *single_lang;
- } else if (repl_languages.Empty()) {
+ Language::GetLanguagesSupportingREPLs(repl_languages);
+
+ if (repl_languages.size() == 1) {
+ language = *repl_languages.begin();
+ } else if (repl_languages.empty()) {
err.SetErrorStringWithFormat(
"LLDB isn't configured with REPL support for any languages.");
return err;
Modified: lldb/trunk/source/Core/PluginManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/PluginManager.cpp?rev=369702&r1=369701&r2=369702&view=diff
==============================================================================
--- lldb/trunk/source/Core/PluginManager.cpp (original)
+++ lldb/trunk/source/Core/PluginManager.cpp Thu Aug 22 13:41:16 2019
@@ -2083,11 +2083,12 @@ PluginManager::GetInstrumentationRuntime
#pragma mark TypeSystem
struct TypeSystemInstance {
+ TypeSystemInstance() : name(), description(), create_callback(nullptr) {}
+
ConstString name;
std::string description;
TypeSystemCreateInstance create_callback;
- LanguageSet supported_languages_for_types;
- LanguageSet supported_languages_for_expressions;
+ TypeSystemEnumerateSupportedLanguages enumerate_callback;
};
typedef std::vector<TypeSystemInstance> TypeSystemInstances;
@@ -2102,11 +2103,11 @@ static TypeSystemInstances &GetTypeSyste
return g_instances;
}
-bool PluginManager::RegisterPlugin(
- ConstString name, const char *description,
- TypeSystemCreateInstance create_callback,
- LanguageSet supported_languages_for_types,
- LanguageSet supported_languages_for_expressions) {
+bool PluginManager::RegisterPlugin(ConstString name,
+ const char *description,
+ TypeSystemCreateInstance create_callback,
+ TypeSystemEnumerateSupportedLanguages
+ enumerate_supported_languages_callback) {
if (create_callback) {
TypeSystemInstance instance;
assert((bool)name);
@@ -2114,8 +2115,7 @@ bool PluginManager::RegisterPlugin(
if (description && description[0])
instance.description = description;
instance.create_callback = create_callback;
- instance.supported_languages_for_types = supported_languages_for_types;
- instance.supported_languages_for_expressions = supported_languages_for_expressions;
+ instance.enumerate_callback = enumerate_supported_languages_callback;
std::lock_guard<std::recursive_mutex> guard(GetTypeSystemMutex());
GetTypeSystemInstances().push_back(instance);
}
@@ -2163,22 +2163,30 @@ PluginManager::GetTypeSystemCreateCallba
return nullptr;
}
-LanguageSet PluginManager::GetAllTypeSystemSupportedLanguagesForTypes() {
+TypeSystemEnumerateSupportedLanguages
+PluginManager::GetTypeSystemEnumerateSupportedLanguagesCallbackAtIndex(
+ uint32_t idx) {
std::lock_guard<std::recursive_mutex> guard(GetTypeSystemMutex());
- LanguageSet all;
TypeSystemInstances &instances = GetTypeSystemInstances();
- for (unsigned i = 0; i < instances.size(); ++i)
- all.bitvector |= instances[i].supported_languages_for_types.bitvector;
- return all;
+ if (idx < instances.size())
+ return instances[idx].enumerate_callback;
+ return nullptr;
}
-LanguageSet PluginManager::GetAllTypeSystemSupportedLanguagesForExpressions() {
- std::lock_guard<std::recursive_mutex> guard(GetTypeSystemMutex());
- LanguageSet all;
- TypeSystemInstances &instances = GetTypeSystemInstances();
- for (unsigned i = 0; i < instances.size(); ++i)
- all.bitvector |= instances[i].supported_languages_for_expressions.bitvector;
- return all;
+TypeSystemEnumerateSupportedLanguages
+PluginManager::GetTypeSystemEnumerateSupportedLanguagesCallbackForPluginName(
+ ConstString name) {
+ if (name) {
+ std::lock_guard<std::recursive_mutex> guard(GetTypeSystemMutex());
+ TypeSystemInstances &instances = GetTypeSystemInstances();
+
+ TypeSystemInstances::iterator pos, end = instances.end();
+ for (pos = instances.begin(); pos != end; ++pos) {
+ if (name == pos->name)
+ return pos->enumerate_callback;
+ }
+ }
+ return nullptr;
}
#pragma mark REPL
@@ -2189,7 +2197,7 @@ struct REPLInstance {
ConstString name;
std::string description;
REPLCreateInstance create_callback;
- LanguageSet supported_languages;
+ REPLEnumerateSupportedLanguages enumerate_languages_callback;
};
typedef std::vector<REPLInstance> REPLInstances;
@@ -2204,9 +2212,10 @@ static REPLInstances &GetREPLInstances()
return g_instances;
}
-bool PluginManager::RegisterPlugin(ConstString name, const char *description,
- REPLCreateInstance create_callback,
- LanguageSet supported_languages) {
+bool PluginManager::RegisterPlugin(
+ ConstString name, const char *description,
+ REPLCreateInstance create_callback,
+ REPLEnumerateSupportedLanguages enumerate_languages_callback) {
if (create_callback) {
REPLInstance instance;
assert((bool)name);
@@ -2214,7 +2223,7 @@ bool PluginManager::RegisterPlugin(Const
if (description && description[0])
instance.description = description;
instance.create_callback = create_callback;
- instance.supported_languages = supported_languages;
+ instance.enumerate_languages_callback = enumerate_languages_callback;
std::lock_guard<std::recursive_mutex> guard(GetREPLMutex());
GetREPLInstances().push_back(instance);
}
@@ -2260,13 +2269,29 @@ PluginManager::GetREPLCreateCallbackForP
return nullptr;
}
-LanguageSet PluginManager::GetREPLAllTypeSystemSupportedLanguages() {
+REPLEnumerateSupportedLanguages
+PluginManager::GetREPLEnumerateSupportedLanguagesCallbackAtIndex(uint32_t idx) {
std::lock_guard<std::recursive_mutex> guard(GetREPLMutex());
- LanguageSet all;
REPLInstances &instances = GetREPLInstances();
- for (unsigned i = 0; i < instances.size(); ++i)
- all.bitvector |= instances[i].supported_languages.bitvector;
- return all;
+ if (idx < instances.size())
+ return instances[idx].enumerate_languages_callback;
+ return nullptr;
+}
+
+REPLEnumerateSupportedLanguages
+PluginManager::GetREPLSystemEnumerateSupportedLanguagesCallbackForPluginName(
+ ConstString name) {
+ if (name) {
+ std::lock_guard<std::recursive_mutex> guard(GetREPLMutex());
+ REPLInstances &instances = GetREPLInstances();
+
+ REPLInstances::iterator pos, end = instances.end();
+ for (pos = instances.begin(); pos != end; ++pos) {
+ if (name == pos->name)
+ return pos->enumerate_languages_callback;
+ }
+ }
+ return nullptr;
}
#pragma mark PluginManager
Modified: lldb/trunk/source/Interpreter/OptionValueLanguage.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionValueLanguage.cpp?rev=369702&r1=369701&r2=369702&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/OptionValueLanguage.cpp (original)
+++ lldb/trunk/source/Interpreter/OptionValueLanguage.cpp Thu Aug 22 13:41:16 2019
@@ -10,7 +10,6 @@
#include "lldb/DataFormatters/FormatManager.h"
#include "lldb/Target/Language.h"
-#include "lldb/Symbol/TypeSystem.h"
#include "lldb/Utility/Args.h"
#include "lldb/Utility/Stream.h"
@@ -40,20 +39,23 @@ Status OptionValueLanguage::SetValueFrom
case eVarSetOperationReplace:
case eVarSetOperationAssign: {
ConstString lang_name(value.trim());
- LanguageSet languages_for_types = Language::GetLanguagesSupportingTypeSystems();
+ std::set<lldb::LanguageType> languages_for_types;
+ std::set<lldb::LanguageType> languages_for_expressions;
+ Language::GetLanguagesSupportingTypeSystems(languages_for_types,
+ languages_for_expressions);
+
LanguageType new_type =
Language::GetLanguageTypeFromString(lang_name.GetStringRef());
- if (new_type && languages_for_types[new_type]) {
+ if (new_type && languages_for_types.count(new_type)) {
m_value_was_set = true;
m_current_value = new_type;
} else {
StreamString error_strm;
error_strm.Printf("invalid language type '%s', ", value.str().c_str());
error_strm.Printf("valid values are:\n");
- for (int bit : languages_for_types.bitvector.set_bits()) {
- auto language = (LanguageType)bit;
- error_strm.Printf(" %s\n",
- Language::GetNameForLanguageType(language));
+ for (lldb::LanguageType language : languages_for_types) {
+ error_strm.Printf("%s%s%s", " ",
+ Language::GetNameForLanguageType(language), "\n");
}
error.SetErrorString(error_strm.GetString());
}
Modified: lldb/trunk/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp?rev=369702&r1=369701&r2=369702&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp Thu Aug 22 13:41:16 2019
@@ -319,8 +319,7 @@ uint32_t SymbolFileBreakpad::FindTypes(
}
size_t SymbolFileBreakpad::FindTypes(llvm::ArrayRef<CompilerContext> pattern,
- LanguageSet languages, bool append,
- TypeMap &types) {
+ bool append, TypeMap &types) {
if (!append)
types.Clear();
return types.GetSize();
Modified: lldb/trunk/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h?rev=369702&r1=369701&r2=369702&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h Thu Aug 22 13:41:16 2019
@@ -116,8 +116,8 @@ public:
llvm::DenseSet<SymbolFile *> &searched_symbol_files,
TypeMap &types) override;
- size_t FindTypes(llvm::ArrayRef<CompilerContext> pattern,
- LanguageSet languages, bool append, TypeMap &types) override;
+ size_t FindTypes(llvm::ArrayRef<CompilerContext> pattern, bool append,
+ TypeMap &types) override;
llvm::Expected<TypeSystem &>
GetTypeSystemForLanguage(lldb::LanguageType language) override {
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp?rev=369702&r1=369701&r2=369702&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Thu Aug 22 13:41:16 2019
@@ -148,10 +148,7 @@ TypeSP DWARFASTParserClang::ParseTypeFro
die.GetDeclContext(decl_context);
TypeMap dwo_types;
- // The type in the Clang module must have the same langage as the current CU.
- LanguageSet languages;
- languages.Insert(die.GetCU()->GetLanguageType());
- if (!dwo_module_sp->GetSymbolFile()->FindTypes(decl_context, languages, true,
+ if (!dwo_module_sp->GetSymbolFile()->FindTypes(decl_context, true,
dwo_types)) {
if (!IsClangModuleFwdDecl(die))
return TypeSP();
@@ -162,8 +159,8 @@ TypeSP DWARFASTParserClang::ParseTypeFro
for (const auto &name_module : sym_file.getExternalTypeModules()) {
if (!name_module.second)
continue;
- if (name_module.second->GetSymbolFile()->FindTypes(
- decl_context, languages, true, dwo_types))
+ if (name_module.second->GetSymbolFile()->FindTypes(decl_context, true,
+ dwo_types))
break;
}
}
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=369702&r1=369701&r2=369702&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Thu Aug 22 13:41:16 2019
@@ -2485,8 +2485,7 @@ uint32_t SymbolFileDWARF::FindTypes(
}
size_t SymbolFileDWARF::FindTypes(llvm::ArrayRef<CompilerContext> pattern,
- LanguageSet languages, bool append,
- TypeMap &types) {
+ bool append, TypeMap &types) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
if (!append)
types.Clear();
@@ -2509,9 +2508,6 @@ size_t SymbolFileDWARF::FindTypes(llvm::
DWARFDIE die = GetDIE(die_ref);
if (die) {
- if (!languages[die.GetCU()->GetLanguageType()])
- continue;
-
llvm::SmallVector<CompilerContext, 4> die_context;
die.GetDeclContext(die_context);
if (!contextMatches(die_context, pattern))
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h?rev=369702&r1=369701&r2=369702&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Thu Aug 22 13:41:16 2019
@@ -185,8 +185,7 @@ public:
lldb_private::TypeMap &types) override;
size_t FindTypes(llvm::ArrayRef<lldb_private::CompilerContext> pattern,
- lldb_private::LanguageSet languages, bool append,
- lldb_private::TypeMap &types) override;
+ bool append, lldb_private::TypeMap &types) override;
size_t GetTypes(lldb_private::SymbolContextScope *sc_scope,
lldb::TypeClass type_mask,
Modified: lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp?rev=369702&r1=369701&r2=369702&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp Thu Aug 22 13:41:16 2019
@@ -1270,10 +1270,7 @@ uint32_t SymbolFileNativePDB::FindTypes(
}
size_t SymbolFileNativePDB::FindTypes(llvm::ArrayRef<CompilerContext> pattern,
- LanguageSet languages, bool append,
- TypeMap &types) {
- if (!append)
- types.Clear();
+ bool append, TypeMap &types) {
return 0;
}
Modified: lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h?rev=369702&r1=369701&r2=369702&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h Thu Aug 22 13:41:16 2019
@@ -134,8 +134,8 @@ public:
llvm::DenseSet<SymbolFile *> &searched_symbol_files,
TypeMap &types) override;
- size_t FindTypes(llvm::ArrayRef<CompilerContext> pattern,
- LanguageSet languages, bool append, TypeMap &types) override;
+ size_t FindTypes(llvm::ArrayRef<CompilerContext> pattern, bool append,
+ TypeMap &types) override;
llvm::Expected<TypeSystem &>
GetTypeSystemForLanguage(lldb::LanguageType language) override;
Modified: lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp?rev=369702&r1=369701&r2=369702&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp Thu Aug 22 13:41:16 2019
@@ -1585,10 +1585,7 @@ void SymbolFilePDB::FindTypesByName(
}
size_t SymbolFilePDB::FindTypes(llvm::ArrayRef<CompilerContext> pattern,
- LanguageSet languages, bool append,
- lldb_private::TypeMap &types) {
- if (!append)
- types.Clear();
+ bool append, lldb_private::TypeMap &types) {
return 0;
}
Modified: lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h?rev=369702&r1=369701&r2=369702&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h Thu Aug 22 13:41:16 2019
@@ -133,8 +133,7 @@ public:
lldb_private::TypeMap &types) override;
size_t FindTypes(llvm::ArrayRef<lldb_private::CompilerContext> pattern,
- lldb_private::LanguageSet languages, bool append,
- lldb_private::TypeMap &types) override;
+ bool append, lldb_private::TypeMap &types) override;
void FindTypesByRegex(const lldb_private::RegularExpression ®ex,
uint32_t max_matches, lldb_private::TypeMap &types);
Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=369702&r1=369701&r2=369702&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Thu Aug 22 13:41:16 2019
@@ -734,36 +734,32 @@ lldb::TypeSystemSP ClangASTContext::Crea
return lldb::TypeSystemSP();
}
-LanguageSet ClangASTContext::GetSupportedLanguagesForTypes() {
- LanguageSet languages;
- languages.Insert(lldb::eLanguageTypeC89);
- languages.Insert(lldb::eLanguageTypeC);
- languages.Insert(lldb::eLanguageTypeC11);
- languages.Insert(lldb::eLanguageTypeC_plus_plus);
- languages.Insert(lldb::eLanguageTypeC99);
- languages.Insert(lldb::eLanguageTypeObjC);
- languages.Insert(lldb::eLanguageTypeObjC_plus_plus);
- languages.Insert(lldb::eLanguageTypeC_plus_plus_03);
- languages.Insert(lldb::eLanguageTypeC_plus_plus_11);
- languages.Insert(lldb::eLanguageTypeC11);
- languages.Insert(lldb::eLanguageTypeC_plus_plus_14);
- return languages;
-}
+void ClangASTContext::EnumerateSupportedLanguages(
+ std::set<lldb::LanguageType> &languages_for_types,
+ std::set<lldb::LanguageType> &languages_for_expressions) {
+ static std::vector<lldb::LanguageType> s_supported_languages_for_types(
+ {lldb::eLanguageTypeC89, lldb::eLanguageTypeC, lldb::eLanguageTypeC11,
+ lldb::eLanguageTypeC_plus_plus, lldb::eLanguageTypeC99,
+ lldb::eLanguageTypeObjC, lldb::eLanguageTypeObjC_plus_plus,
+ lldb::eLanguageTypeC_plus_plus_03, lldb::eLanguageTypeC_plus_plus_11,
+ lldb::eLanguageTypeC11, lldb::eLanguageTypeC_plus_plus_14});
+
+ static std::vector<lldb::LanguageType> s_supported_languages_for_expressions(
+ {lldb::eLanguageTypeC_plus_plus, lldb::eLanguageTypeObjC_plus_plus,
+ lldb::eLanguageTypeC_plus_plus_03, lldb::eLanguageTypeC_plus_plus_11,
+ lldb::eLanguageTypeC_plus_plus_14});
-LanguageSet ClangASTContext::GetSupportedLanguagesForExpressions() {
- LanguageSet languages;
- languages.Insert(lldb::eLanguageTypeC_plus_plus);
- languages.Insert(lldb::eLanguageTypeObjC_plus_plus);
- languages.Insert(lldb::eLanguageTypeC_plus_plus_03);
- languages.Insert(lldb::eLanguageTypeC_plus_plus_11);
- languages.Insert(lldb::eLanguageTypeC_plus_plus_14);
- return languages;
+ languages_for_types.insert(s_supported_languages_for_types.begin(),
+ s_supported_languages_for_types.end());
+ languages_for_expressions.insert(
+ s_supported_languages_for_expressions.begin(),
+ s_supported_languages_for_expressions.end());
}
void ClangASTContext::Initialize() {
- PluginManager::RegisterPlugin(
- GetPluginNameStatic(), "clang base AST context plug-in", CreateInstance,
- GetSupportedLanguagesForTypes(), GetSupportedLanguagesForExpressions());
+ PluginManager::RegisterPlugin(GetPluginNameStatic(),
+ "clang base AST context plug-in",
+ CreateInstance, EnumerateSupportedLanguages);
}
void ClangASTContext::Terminate() {
Modified: lldb/trunk/source/Symbol/SymbolFile.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolFile.cpp?rev=369702&r1=369701&r2=369702&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/SymbolFile.cpp (original)
+++ lldb/trunk/source/Symbol/SymbolFile.cpp Thu Aug 22 13:41:16 2019
@@ -150,8 +150,7 @@ uint32_t SymbolFile::FindTypes(
}
size_t SymbolFile::FindTypes(llvm::ArrayRef<CompilerContext> pattern,
- LanguageSet languages, bool append,
- TypeMap &types) {
+ bool append, TypeMap &types) {
if (!append)
types.Clear();
return 0;
Modified: lldb/trunk/source/Symbol/TypeSystem.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/TypeSystem.cpp?rev=369702&r1=369701&r2=369702&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/TypeSystem.cpp (original)
+++ lldb/trunk/source/Symbol/TypeSystem.cpp Thu Aug 22 13:41:16 2019
@@ -25,23 +25,6 @@
using namespace lldb_private;
using namespace lldb;
-/// A 64-bit SmallBitVector is only small up to 64-7 bits, and the
-/// setBitsInMask interface wants to write full bytes.
-static const size_t num_small_bitvector_bits = 64 - 8;
-static_assert(eNumLanguageTypes < num_small_bitvector_bits,
- "Languages bit vector is no longer small on 64 bit systems");
-
-llvm::Optional<LanguageType> LanguageSet::GetSingularLanguage() {
- if (bitvector.count() == 1)
- return (LanguageType)bitvector.find_first();
- return {};
-}
-
-void LanguageSet::Insert(LanguageType language) { bitvector.set(language); }
-size_t LanguageSet::Size() const { return bitvector.count(); }
-bool LanguageSet::Empty() const { return bitvector.none(); }
-bool LanguageSet::operator[](unsigned i) const { return bitvector[i]; }
-
TypeSystem::TypeSystem(LLVMCastKind kind) : m_kind(kind), m_sym_file(nullptr) {}
TypeSystem::~TypeSystem() {}
Modified: lldb/trunk/source/Target/Language.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Language.cpp?rev=369702&r1=369701&r2=369702&view=diff
==============================================================================
--- lldb/trunk/source/Target/Language.cpp (original)
+++ lldb/trunk/source/Target/Language.cpp Thu Aug 22 13:41:16 2019
@@ -357,16 +357,26 @@ std::set<lldb::LanguageType> Language::G
return supported_languages;
}
-LanguageSet Language::GetLanguagesSupportingTypeSystems() {
- return PluginManager::GetAllTypeSystemSupportedLanguagesForTypes();
-}
+void Language::GetLanguagesSupportingTypeSystems(
+ std::set<lldb::LanguageType> &languages,
+ std::set<lldb::LanguageType> &languages_for_expressions) {
+ uint32_t idx = 0;
-LanguageSet Language::GetLanguagesSupportingTypeSystemsForExpressions() {
- return PluginManager::GetAllTypeSystemSupportedLanguagesForExpressions();
+ while (TypeSystemEnumerateSupportedLanguages enumerate = PluginManager::
+ GetTypeSystemEnumerateSupportedLanguagesCallbackAtIndex(idx++)) {
+ (*enumerate)(languages, languages_for_expressions);
+ }
}
-LanguageSet Language::GetLanguagesSupportingREPLs() {
- return PluginManager::GetREPLAllTypeSystemSupportedLanguages();
+void Language::GetLanguagesSupportingREPLs(
+ std::set<lldb::LanguageType> &languages) {
+ uint32_t idx = 0;
+
+ while (REPLEnumerateSupportedLanguages enumerate =
+ PluginManager::GetREPLEnumerateSupportedLanguagesCallbackAtIndex(
+ idx++)) {
+ (*enumerate)(languages);
+ }
}
std::unique_ptr<Language::TypeScavenger> Language::GetTypeScavenger() {
Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=369702&r1=369701&r2=369702&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Thu Aug 22 13:41:16 2019
@@ -206,11 +206,13 @@ const lldb::ProcessSP &Target::GetProces
lldb::REPLSP Target::GetREPL(Status &err, lldb::LanguageType language,
const char *repl_options, bool can_create) {
if (language == eLanguageTypeUnknown) {
- LanguageSet repl_languages = Language::GetLanguagesSupportingREPLs();
+ std::set<LanguageType> repl_languages;
- if (auto single_lang = repl_languages.GetSingularLanguage()) {
- language = *single_lang;
- } else if (repl_languages.Empty()) {
+ Language::GetLanguagesSupportingREPLs(repl_languages);
+
+ if (repl_languages.size() == 1) {
+ language = *repl_languages.begin();
+ } else if (repl_languages.size() == 0) {
err.SetErrorStringWithFormat(
"LLDB isn't configured with REPL support for any languages.");
return REPLSP();
@@ -2127,18 +2129,23 @@ Target::GetScratchTypeSystemForLanguage(
if (language == eLanguageTypeMipsAssembler // GNU AS and LLVM use it for all
// assembly code
|| language == eLanguageTypeUnknown) {
- LanguageSet languages_for_expressions =
- Language::GetLanguagesSupportingTypeSystemsForExpressions();
+ std::set<lldb::LanguageType> languages_for_types;
+ std::set<lldb::LanguageType> languages_for_expressions;
+
+ Language::GetLanguagesSupportingTypeSystems(languages_for_types,
+ languages_for_expressions);
- if (languages_for_expressions[eLanguageTypeC]) {
+ if (languages_for_expressions.count(eLanguageTypeC)) {
language = eLanguageTypeC; // LLDB's default. Override by setting the
// target language.
} else {
- if (languages_for_expressions.Empty())
+ if (languages_for_expressions.empty()) {
return llvm::make_error<llvm::StringError>(
"No expression support for any languages",
llvm::inconvertibleErrorCode());
- language = (LanguageType)languages_for_expressions.bitvector.find_first();
+ } else {
+ language = *languages_for_expressions.begin();
+ }
}
}
@@ -2152,19 +2159,21 @@ std::vector<TypeSystem *> Target::GetScr
std::vector<TypeSystem *> scratch_type_systems;
- LanguageSet languages_for_expressions =
- Language::GetLanguagesSupportingTypeSystemsForExpressions();
+ std::set<lldb::LanguageType> languages_for_types;
+ std::set<lldb::LanguageType> languages_for_expressions;
+
+ Language::GetLanguagesSupportingTypeSystems(languages_for_types,
+ languages_for_expressions);
- for (auto bit : languages_for_expressions.bitvector.set_bits()) {
- auto language = (LanguageType)bit;
+ for (auto lang : languages_for_expressions) {
auto type_system_or_err =
- GetScratchTypeSystemForLanguage(language, create_on_demand);
+ GetScratchTypeSystemForLanguage(lang, create_on_demand);
if (!type_system_or_err)
LLDB_LOG_ERROR(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_TARGET),
type_system_or_err.takeError(),
"Language '{}' has expression support but no scratch type "
"system available",
- Language::GetNameForLanguageType(language));
+ Language::GetNameForLanguageType(lang));
else
scratch_type_systems.emplace_back(&type_system_or_err.get());
}
Modified: lldb/trunk/tools/lldb-test/lldb-test.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-test/lldb-test.cpp?rev=369702&r1=369701&r2=369702&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-test/lldb-test.cpp (original)
+++ lldb/trunk/tools/lldb-test/lldb-test.cpp Thu Aug 22 13:41:16 2019
@@ -26,7 +26,6 @@
#include "lldb/Symbol/TypeList.h"
#include "lldb/Symbol/TypeMap.h"
#include "lldb/Symbol/VariableList.h"
-#include "lldb/Target/Language.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/CleanUp.h"
@@ -145,10 +144,6 @@ static cl::opt<std::string> CompilerCont
cl::desc("Specify a compiler context as \"kind:name,...\"."),
cl::value_desc("context"), cl::sub(SymbolsSubcommand));
-static cl::opt<std::string>
- Language("language", cl::desc("Specify a language type, like C99."),
- cl::value_desc("language"), cl::sub(SymbolsSubcommand));
-
static cl::list<FunctionNameType> FunctionNameFlags(
"function-flags", cl::desc("Function search flags:"),
cl::values(clEnumValN(eFunctionNameTypeAuto, "auto",
@@ -512,17 +507,13 @@ Error opts::symbols::findTypes(lldb_priv
CompilerDeclContext *ContextPtr =
ContextOr->IsValid() ? &*ContextOr : nullptr;
- LanguageSet languages;
- if (!Language.empty())
- languages.Insert(Language::GetLanguageTypeFromString(Language));
-
DenseSet<SymbolFile *> SearchedFiles;
TypeMap Map;
if (!Name.empty())
Symfile.FindTypes(ConstString(Name), ContextPtr, true, UINT32_MAX,
SearchedFiles, Map);
else
- Symfile.FindTypes(parseCompilerContext(), languages, true, Map);
+ Symfile.FindTypes(parseCompilerContext(), true, Map);
outs() << formatv("Found {0} types:\n", Map.GetSize());
StreamString Stream;
More information about the lldb-commits
mailing list