aboutsummaryrefslogtreecommitdiffstats
path: root/source/Symbol
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-10-23 17:53:01 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-10-23 17:53:01 +0000
commitead246455adf1a215ec2715dad6533073a6beb4e (patch)
treef3f97a47d77053bf96fe74cdbd6fae74380e8a92 /source/Symbol
parentfdb00c4408990a0a63ef7f496d809ce59f263bc5 (diff)
downloadsrc-vendor/lldb.tar.gz
src-vendor/lldb.zip
Vendor import of stripped lldb trunk r375505, the last commit before thevendor/lldb/lldb-trunk-r375505vendor/lldb
upstream Subversion repository was made read-only, and the LLVM project migrated to GitHub: https://llvm.org/svn/llvm-project/lldb/trunk@375505
Notes
Notes: svn path=/vendor/lldb/dist/; revision=353952 svn path=/vendor/lldb/lldb-r375505/; revision=353953; tag=vendor/lldb/lldb-trunk-r375505
Diffstat (limited to 'source/Symbol')
-rw-r--r--source/Symbol/ArmUnwindInfo.cpp1
-rw-r--r--source/Symbol/Block.cpp38
-rw-r--r--source/Symbol/ClangASTContext.cpp1935
-rw-r--r--source/Symbol/ClangASTImporter.cpp384
-rw-r--r--source/Symbol/CompactUnwindInfo.cpp11
-rw-r--r--source/Symbol/CompileUnit.cpp87
-rw-r--r--source/Symbol/CompilerType.cpp28
-rw-r--r--source/Symbol/CxxModuleHandler.cpp14
-rw-r--r--source/Symbol/DWARFCallFrameInfo.cpp17
-rw-r--r--source/Symbol/DeclVendor.cpp11
-rw-r--r--source/Symbol/FuncUnwinders.cpp65
-rw-r--r--source/Symbol/Function.cpp53
-rw-r--r--source/Symbol/LineTable.cpp68
-rw-r--r--source/Symbol/LocateSymbolFile.cpp171
-rw-r--r--source/Symbol/LocateSymbolFileMacOSX.cpp71
-rw-r--r--source/Symbol/ObjectFile.cpp77
-rw-r--r--source/Symbol/PostfixExpression.cpp23
-rw-r--r--source/Symbol/Symbol.cpp9
-rw-r--r--source/Symbol/SymbolContext.cpp166
-rw-r--r--source/Symbol/SymbolFile.cpp180
-rw-r--r--source/Symbol/SymbolVendor.cpp413
-rw-r--r--source/Symbol/Symtab.cpp18
-rw-r--r--source/Symbol/Type.cpp120
-rw-r--r--source/Symbol/TypeMap.cpp13
-rw-r--r--source/Symbol/TypeSystem.cpp192
-rw-r--r--source/Symbol/UnwindPlan.cpp46
-rw-r--r--source/Symbol/UnwindTable.cpp24
-rw-r--r--source/Symbol/Variable.cpp123
-rw-r--r--source/Symbol/VerifyDecl.cpp15
29 files changed, 2074 insertions, 2299 deletions
diff --git a/source/Symbol/ArmUnwindInfo.cpp b/source/Symbol/ArmUnwindInfo.cpp
index b9fd84b1e706..fdf4e30b2db5 100644
--- a/source/Symbol/ArmUnwindInfo.cpp
+++ b/source/Symbol/ArmUnwindInfo.cpp
@@ -344,6 +344,7 @@ bool ArmUnwindInfo::GetUnwindPlan(Target &target, const Address &addr,
unwind_plan.SetSourceName("ARM.exidx unwind info");
unwind_plan.SetSourcedFromCompiler(eLazyBoolYes);
unwind_plan.SetUnwindPlanValidAtAllInstructions(eLazyBoolNo);
+ unwind_plan.SetUnwindPlanForSignalTrap(eLazyBoolNo);
unwind_plan.SetRegisterKind(eRegisterKindDWARF);
return true;
diff --git a/source/Symbol/Block.cpp b/source/Symbol/Block.cpp
index 6fe617080f96..77a4830dea7c 100644
--- a/source/Symbol/Block.cpp
+++ b/source/Symbol/Block.cpp
@@ -12,7 +12,6 @@
#include "lldb/Core/Section.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/SymbolFile.h"
-#include "lldb/Symbol/SymbolVendor.h"
#include "lldb/Symbol/VariableList.h"
#include "lldb/Utility/Log.h"
@@ -337,22 +336,24 @@ void Block::AddRange(const Range &range) {
const Declaration &func_decl = func_type->GetDeclaration();
if (func_decl.GetLine()) {
- log->Printf("warning: %s:%u block {0x%8.8" PRIx64
- "} has range[%u] [0x%" PRIx64 " - 0x%" PRIx64
- ") which is not contained in parent block {0x%8.8" PRIx64
- "} in function {0x%8.8" PRIx64 "} from %s",
- func_decl.GetFile().GetPath().c_str(), func_decl.GetLine(),
- GetID(), (uint32_t)m_ranges.GetSize(), block_start_addr,
- block_end_addr, parent_block->GetID(), function->GetID(),
- module_sp->GetFileSpec().GetPath().c_str());
+ LLDB_LOGF(log,
+ "warning: %s:%u block {0x%8.8" PRIx64
+ "} has range[%u] [0x%" PRIx64 " - 0x%" PRIx64
+ ") which is not contained in parent block {0x%8.8" PRIx64
+ "} in function {0x%8.8" PRIx64 "} from %s",
+ func_decl.GetFile().GetPath().c_str(), func_decl.GetLine(),
+ GetID(), (uint32_t)m_ranges.GetSize(), block_start_addr,
+ block_end_addr, parent_block->GetID(), function->GetID(),
+ module_sp->GetFileSpec().GetPath().c_str());
} else {
- log->Printf("warning: block {0x%8.8" PRIx64
- "} has range[%u] [0x%" PRIx64 " - 0x%" PRIx64
- ") which is not contained in parent block {0x%8.8" PRIx64
- "} in function {0x%8.8" PRIx64 "} from %s",
- GetID(), (uint32_t)m_ranges.GetSize(), block_start_addr,
- block_end_addr, parent_block->GetID(), function->GetID(),
- module_sp->GetFileSpec().GetPath().c_str());
+ LLDB_LOGF(log,
+ "warning: block {0x%8.8" PRIx64 "} has range[%u] [0x%" PRIx64
+ " - 0x%" PRIx64
+ ") which is not contained in parent block {0x%8.8" PRIx64
+ "} in function {0x%8.8" PRIx64 "} from %s",
+ GetID(), (uint32_t)m_ranges.GetSize(), block_start_addr,
+ block_end_addr, parent_block->GetID(), function->GetID(),
+ module_sp->GetFileSpec().GetPath().c_str());
}
}
parent_block->AddRange(range);
@@ -391,7 +392,7 @@ VariableListSP Block::GetBlockVariableList(bool can_create) {
SymbolContext sc;
CalculateSymbolContext(&sc);
assert(sc.module_sp);
- sc.module_sp->GetSymbolVendor()->ParseVariablesForContext(sc);
+ sc.module_sp->GetSymbolFile()->ParseVariablesForContext(sc);
}
}
return m_variable_list_sp;
@@ -462,8 +463,7 @@ uint32_t Block::AppendVariables(bool can_create, bool get_parent_variables,
SymbolFile *Block::GetSymbolFile() {
if (ModuleSP module_sp = CalculateSymbolContextModule())
- if (SymbolVendor *sym_vendor = module_sp->GetSymbolVendor())
- return sym_vendor->GetSymbolFile();
+ return module_sp->GetSymbolFile();
return nullptr;
}
diff --git a/source/Symbol/ClangASTContext.cpp b/source/Symbol/ClangASTContext.cpp
index 205523355ce0..565b15a007da 100644
--- a/source/Symbol/ClangASTContext.cpp
+++ b/source/Symbol/ClangASTContext.cpp
@@ -47,11 +47,11 @@
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/FileSystemOptions.h"
+#include "clang/Basic/LangStandard.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/TargetOptions.h"
#include "clang/Frontend/FrontendOptions.h"
-#include "clang/Frontend/LangStandard.h"
#include "clang/Sema/Sema.h"
#ifdef LLDB_DEFINED_NDEBUG_FOR_CLANG
@@ -65,6 +65,7 @@
#include "llvm/Support/Threading.h"
#include "Plugins/ExpressionParser/Clang/ClangFunctionCaller.h"
+#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
#include "Plugins/ExpressionParser/Clang/ClangUserExpression.h"
#include "Plugins/ExpressionParser/Clang/ClangUtilityFunction.h"
#include "lldb/Utility/ArchSpec.h"
@@ -76,14 +77,12 @@
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/ThreadSafeDenseMap.h"
#include "lldb/Core/UniqueCStringMap.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/ClangASTImporter.h"
#include "lldb/Symbol/ClangExternalASTSourceCallbacks.h"
#include "lldb/Symbol/ClangExternalASTSourceCommon.h"
#include "lldb/Symbol/ClangUtil.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolFile.h"
-#include "lldb/Symbol/VerifyDecl.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/Process.h"
@@ -104,17 +103,24 @@
using namespace lldb;
using namespace lldb_private;
-using namespace llvm;
using namespace clang;
+using llvm::StringSwitch;
namespace {
+#ifdef LLDB_CONFIGURATION_DEBUG
+static void VerifyDecl(clang::Decl *decl) {
+ assert(decl && "VerifyDecl called with nullptr?");
+ decl->getAccess();
+}
+#endif
+
static inline bool
ClangASTContextSupportsLanguage(lldb::LanguageType language) {
return language == eLanguageTypeUnknown || // Clang is the default type system
- Language::LanguageIsC(language) ||
- Language::LanguageIsCPlusPlus(language) ||
- Language::LanguageIsObjC(language) ||
- Language::LanguageIsPascal(language) ||
+ lldb_private::Language::LanguageIsC(language) ||
+ lldb_private::Language::LanguageIsCPlusPlus(language) ||
+ lldb_private::Language::LanguageIsObjC(language) ||
+ lldb_private::Language::LanguageIsPascal(language) ||
// Use Clang for Rust until there is a proper language plugin for it
language == eLanguageTypeRust ||
language == eLanguageTypeExtRenderScript ||
@@ -331,219 +337,82 @@ static ClangASTMap &GetASTMap() {
return *g_map_ptr;
}
-bool ClangASTContext::IsOperator(const char *name,
+bool ClangASTContext::IsOperator(llvm::StringRef name,
clang::OverloadedOperatorKind &op_kind) {
- if (name == nullptr || name[0] == '\0')
- return false;
-
-#define OPERATOR_PREFIX "operator"
-#define OPERATOR_PREFIX_LENGTH (sizeof(OPERATOR_PREFIX) - 1)
-
- const char *post_op_name = nullptr;
-
- bool no_space = true;
-
- if (::strncmp(name, OPERATOR_PREFIX, OPERATOR_PREFIX_LENGTH))
+ // All operators have to start with "operator".
+ if (!name.consume_front("operator"))
return false;
- post_op_name = name + OPERATOR_PREFIX_LENGTH;
-
- if (post_op_name[0] == ' ') {
- post_op_name++;
- no_space = false;
- }
-
-#undef OPERATOR_PREFIX
-#undef OPERATOR_PREFIX_LENGTH
-
- // This is an operator, set the overloaded operator kind to invalid in case
- // this is a conversion operator...
- op_kind = clang::NUM_OVERLOADED_OPERATORS;
-
- switch (post_op_name[0]) {
- default:
- if (no_space)
- return false;
- break;
- case 'n':
- if (no_space)
- return false;
- if (strcmp(post_op_name, "new") == 0)
- op_kind = clang::OO_New;
- else if (strcmp(post_op_name, "new[]") == 0)
- op_kind = clang::OO_Array_New;
- break;
-
- case 'd':
- if (no_space)
- return false;
- if (strcmp(post_op_name, "delete") == 0)
- op_kind = clang::OO_Delete;
- else if (strcmp(post_op_name, "delete[]") == 0)
- op_kind = clang::OO_Array_Delete;
- break;
-
- case '+':
- if (post_op_name[1] == '\0')
- op_kind = clang::OO_Plus;
- else if (post_op_name[2] == '\0') {
- if (post_op_name[1] == '=')
- op_kind = clang::OO_PlusEqual;
- else if (post_op_name[1] == '+')
- op_kind = clang::OO_PlusPlus;
- }
- break;
-
- case '-':
- if (post_op_name[1] == '\0')
- op_kind = clang::OO_Minus;
- else if (post_op_name[2] == '\0') {
- switch (post_op_name[1]) {
- case '=':
- op_kind = clang::OO_MinusEqual;
- break;
- case '-':
- op_kind = clang::OO_MinusMinus;
- break;
- case '>':
- op_kind = clang::OO_Arrow;
- break;
- }
- } else if (post_op_name[3] == '\0') {
- if (post_op_name[2] == '*')
- op_kind = clang::OO_ArrowStar;
- break;
- }
- break;
-
- case '*':
- if (post_op_name[1] == '\0')
- op_kind = clang::OO_Star;
- else if (post_op_name[1] == '=' && post_op_name[2] == '\0')
- op_kind = clang::OO_StarEqual;
- break;
-
- case '/':
- if (post_op_name[1] == '\0')
- op_kind = clang::OO_Slash;
- else if (post_op_name[1] == '=' && post_op_name[2] == '\0')
- op_kind = clang::OO_SlashEqual;
- break;
-
- case '%':
- if (post_op_name[1] == '\0')
- op_kind = clang::OO_Percent;
- else if (post_op_name[1] == '=' && post_op_name[2] == '\0')
- op_kind = clang::OO_PercentEqual;
- break;
-
- case '^':
- if (post_op_name[1] == '\0')
- op_kind = clang::OO_Caret;
- else if (post_op_name[1] == '=' && post_op_name[2] == '\0')
- op_kind = clang::OO_CaretEqual;
- break;
-
- case '&':
- if (post_op_name[1] == '\0')
- op_kind = clang::OO_Amp;
- else if (post_op_name[2] == '\0') {
- switch (post_op_name[1]) {
- case '=':
- op_kind = clang::OO_AmpEqual;
- break;
- case '&':
- op_kind = clang::OO_AmpAmp;
- break;
- }
- }
- break;
-
- case '|':
- if (post_op_name[1] == '\0')
- op_kind = clang::OO_Pipe;
- else if (post_op_name[2] == '\0') {
- switch (post_op_name[1]) {
- case '=':
- op_kind = clang::OO_PipeEqual;
- break;
- case '|':
- op_kind = clang::OO_PipePipe;
- break;
- }
- }
- break;
-
- case '~':
- if (post_op_name[1] == '\0')
- op_kind = clang::OO_Tilde;
- break;
-
- case '!':
- if (post_op_name[1] == '\0')
- op_kind = clang::OO_Exclaim;
- else if (post_op_name[1] == '=' && post_op_name[2] == '\0')
- op_kind = clang::OO_ExclaimEqual;
- break;
-
- case '=':
- if (post_op_name[1] == '\0')
- op_kind = clang::OO_Equal;
- else if (post_op_name[1] == '=' && post_op_name[2] == '\0')
- op_kind = clang::OO_EqualEqual;
- break;
-
- case '<':
- if (post_op_name[1] == '\0')
- op_kind = clang::OO_Less;
- else if (post_op_name[2] == '\0') {
- switch (post_op_name[1]) {
- case '<':
- op_kind = clang::OO_LessLess;
- break;
- case '=':
- op_kind = clang::OO_LessEqual;
- break;
- }
- } else if (post_op_name[3] == '\0') {
- if (post_op_name[2] == '=')
- op_kind = clang::OO_LessLessEqual;
- }
- break;
-
- case '>':
- if (post_op_name[1] == '\0')
- op_kind = clang::OO_Greater;
- else if (post_op_name[2] == '\0') {
- switch (post_op_name[1]) {
- case '>':
- op_kind = clang::OO_GreaterGreater;
- break;
- case '=':
- op_kind = clang::OO_GreaterEqual;
- break;
- }
- } else if (post_op_name[1] == '>' && post_op_name[2] == '=' &&
- post_op_name[3] == '\0') {
- op_kind = clang::OO_GreaterGreaterEqual;
- }
- break;
-
- case ',':
- if (post_op_name[1] == '\0')
- op_kind = clang::OO_Comma;
- break;
-
- case '(':
- if (post_op_name[1] == ')' && post_op_name[2] == '\0')
- op_kind = clang::OO_Call;
- break;
+ // Remember if there was a space after "operator". This is necessary to
+ // check for collisions with strangely named functions like "operatorint()".
+ bool space_after_operator = name.consume_front(" ");
+
+ op_kind = StringSwitch<clang::OverloadedOperatorKind>(name)
+ .Case("+", clang::OO_Plus)
+ .Case("+=", clang::OO_PlusEqual)
+ .Case("++", clang::OO_PlusPlus)
+ .Case("-", clang::OO_Minus)
+ .Case("-=", clang::OO_MinusEqual)
+ .Case("--", clang::OO_MinusMinus)
+ .Case("->", clang::OO_Arrow)
+ .Case("->*", clang::OO_ArrowStar)
+ .Case("*", clang::OO_Star)
+ .Case("*=", clang::OO_StarEqual)
+ .Case("/", clang::OO_Slash)
+ .Case("/=", clang::OO_SlashEqual)
+ .Case("%", clang::OO_Percent)
+ .Case("%=", clang::OO_PercentEqual)
+ .Case("^", clang::OO_Caret)
+ .Case("^=", clang::OO_CaretEqual)
+ .Case("&", clang::OO_Amp)
+ .Case("&=", clang::OO_AmpEqual)
+ .Case("&&", clang::OO_AmpAmp)
+ .Case("|", clang::OO_Pipe)
+ .Case("|=", clang::OO_PipeEqual)
+ .Case("||", clang::OO_PipePipe)
+ .Case("~", clang::OO_Tilde)
+ .Case("!", clang::OO_Exclaim)
+ .Case("!=", clang::OO_ExclaimEqual)
+ .Case("=", clang::OO_Equal)
+ .Case("==", clang::OO_EqualEqual)
+ .Case("<", clang::OO_Less)
+ .Case("<<", clang::OO_LessLess)
+ .Case("<<=", clang::OO_LessLessEqual)
+ .Case("<=", clang::OO_LessEqual)
+ .Case(">", clang::OO_Greater)
+ .Case(">>", clang::OO_GreaterGreater)
+ .Case(">>=", clang::OO_GreaterGreaterEqual)
+ .Case(">=", clang::OO_GreaterEqual)
+ .Case("()", clang::OO_Call)
+ .Case("[]", clang::OO_Subscript)
+ .Case(",", clang::OO_Comma)
+ .Default(clang::NUM_OVERLOADED_OPERATORS);
+
+ // We found a fitting operator, so we can exit now.
+ if (op_kind != clang::NUM_OVERLOADED_OPERATORS)
+ return true;
- case '[':
- if (post_op_name[1] == ']' && post_op_name[2] == '\0')
- op_kind = clang::OO_Subscript;
- break;
- }
+ // After the "operator " or "operator" part is something unknown. This means
+ // it's either one of the named operators (new/delete), a conversion operator
+ // (e.g. operator bool) or a function which name starts with "operator"
+ // (e.g. void operatorbool).
+
+ // If it's a function that starts with operator it can't have a space after
+ // "operator" because identifiers can't contain spaces.
+ // E.g. "operator int" (conversion operator)
+ // vs. "operatorint" (function with colliding name).
+ if (!space_after_operator)
+ return false; // not an operator.
+
+ // Now the operator is either one of the named operators or a conversion
+ // operator.
+ op_kind = StringSwitch<clang::OverloadedOperatorKind>(name)
+ .Case("new", clang::OO_New)
+ .Case("new[]", clang::OO_Array_New)
+ .Case("delete", clang::OO_Delete)
+ .Case("delete[]", clang::OO_Array_Delete)
+ // conversion operators hit this case.
+ .Default(clang::NUM_OVERLOADED_OPERATORS);
return true;
}
@@ -571,7 +440,7 @@ static void ParseLangArgs(LangOptions &Opts, InputKind IK, const char *triple) {
// Set some properties which depend solely on the input kind; it would be
// nice to move these to the language standard, and have the driver resolve
// the input kind + language standard.
- if (IK.getLanguage() == InputKind::Asm) {
+ if (IK.getLanguage() == clang::Language::Asm) {
Opts.AsmPreprocessor = 1;
} else if (IK.isObjectiveC()) {
Opts.ObjC = 1;
@@ -582,26 +451,26 @@ static void ParseLangArgs(LangOptions &Opts, InputKind IK, const char *triple) {
if (LangStd == LangStandard::lang_unspecified) {
// Based on the base language, pick one.
switch (IK.getLanguage()) {
- case InputKind::Unknown:
- case InputKind::LLVM_IR:
- case InputKind::RenderScript:
+ case clang::Language::Unknown:
+ case clang::Language::LLVM_IR:
+ case clang::Language::RenderScript:
llvm_unreachable("Invalid input kind!");
- case InputKind::OpenCL:
+ case clang::Language::OpenCL:
LangStd = LangStandard::lang_opencl10;
break;
- case InputKind::CUDA:
+ case clang::Language::CUDA:
LangStd = LangStandard::lang_cuda;
break;
- case InputKind::Asm:
- case InputKind::C:
- case InputKind::ObjC:
+ case clang::Language::Asm:
+ case clang::Language::C:
+ case clang::Language::ObjC:
LangStd = LangStandard::lang_gnu99;
break;
- case InputKind::CXX:
- case InputKind::ObjCXX:
+ case clang::Language::CXX:
+ case clang::Language::ObjCXX:
LangStd = LangStandard::lang_gnucxx98;
break;
- case InputKind::HIP:
+ case clang::Language::HIP:
LangStd = LangStandard::lang_hip;
break;
}
@@ -625,7 +494,7 @@ static void ParseLangArgs(LangOptions &Opts, InputKind IK, const char *triple) {
Opts.OpenCL = 1;
Opts.AltiVec = 1;
Opts.CXXOperatorNames = 1;
- Opts.LaxVectorConversions = 1;
+ Opts.setLaxVectorConversions(LangOptions::LaxVectorConversionKind::All);
}
// OpenCL and C++ both have bool, true, false keywords.
@@ -653,15 +522,29 @@ static void ParseLangArgs(LangOptions &Opts, InputKind IK, const char *triple) {
Opts.NoInlineDefine = !Opt;
}
-ClangASTContext::ClangASTContext(const char *target_triple)
- : TypeSystem(TypeSystem::eKindClang), m_target_triple(), m_ast_up(),
- m_language_options_up(), m_source_manager_up(), m_diagnostics_engine_up(),
- m_target_options_rp(), m_target_info_up(), m_identifier_table_up(),
- m_selector_table_up(), m_builtins_up(), m_callback_tag_decl(nullptr),
- m_callback_objc_decl(nullptr), m_callback_baton(nullptr),
- m_pointer_byte_size(0), m_ast_owned(false) {
- if (target_triple && target_triple[0])
+ClangASTContext::ClangASTContext(llvm::StringRef target_triple)
+ : TypeSystem(TypeSystem::eKindClang) {
+ if (!target_triple.empty())
SetTargetTriple(target_triple);
+ // The caller didn't pass an ASTContext so create a new one for this
+ // ClangASTContext.
+ CreateASTContext();
+}
+
+ClangASTContext::ClangASTContext(ArchSpec arch)
+ : TypeSystem(TypeSystem::eKindClang) {
+ SetTargetTriple(arch.GetTriple().str());
+ // The caller didn't pass an ASTContext so create a new one for this
+ // ClangASTContext.
+ CreateASTContext();
+}
+
+ClangASTContext::ClangASTContext(ASTContext &existing_ctxt)
+ : TypeSystem(TypeSystem::eKindClang) {
+ SetTargetTriple(existing_ctxt.getTargetInfo().getTriple().str());
+
+ m_ast_up.reset(&existing_ctxt);
+ GetASTMap().Insert(&existing_ctxt, this);
}
// Destructor
@@ -695,6 +578,7 @@ lldb::TypeSystemSP ClangASTContext::CreateInstance(lldb::LanguageType language,
fixed_arch.GetTriple().getOS() == llvm::Triple::UnknownOS) {
if (fixed_arch.GetTriple().getArch() == llvm::Triple::arm ||
fixed_arch.GetTriple().getArch() == llvm::Triple::aarch64 ||
+ fixed_arch.GetTriple().getArch() == llvm::Triple::aarch64_32 ||
fixed_arch.GetTriple().getArch() == llvm::Triple::thumb) {
fixed_arch.GetTriple().setOS(llvm::Triple::IOS);
} else {
@@ -703,58 +587,57 @@ lldb::TypeSystemSP ClangASTContext::CreateInstance(lldb::LanguageType language,
}
if (module) {
- std::shared_ptr<ClangASTContext> ast_sp(new ClangASTContext);
- if (ast_sp) {
- ast_sp->SetArchitecture(fixed_arch);
- }
+ std::shared_ptr<ClangASTContext> ast_sp(
+ new ClangASTContext(fixed_arch));
return ast_sp;
} else if (target && target->IsValid()) {
std::shared_ptr<ClangASTContextForExpressions> ast_sp(
- new ClangASTContextForExpressions(*target));
- if (ast_sp) {
- ast_sp->SetArchitecture(fixed_arch);
- ast_sp->m_scratch_ast_source_up.reset(
- new ClangASTSource(target->shared_from_this()));
- lldbassert(ast_sp->getFileManager());
- ast_sp->m_scratch_ast_source_up->InstallASTContext(
- *ast_sp->getASTContext(), *ast_sp->getFileManager(), true);
- llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> proxy_ast_source(
- ast_sp->m_scratch_ast_source_up->CreateProxy());
- ast_sp->SetExternalSource(proxy_ast_source);
- return ast_sp;
- }
+ new ClangASTContextForExpressions(*target, fixed_arch));
+ ast_sp->m_scratch_ast_source_up.reset(
+ new ClangASTSource(target->shared_from_this()));
+ lldbassert(ast_sp->getFileManager());
+ ast_sp->m_scratch_ast_source_up->InstallASTContext(
+ *ast_sp->getASTContext(), *ast_sp->getFileManager(), true);
+ llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> proxy_ast_source(
+ ast_sp->m_scratch_ast_source_up->CreateProxy());
+ ast_sp->SetExternalSource(proxy_ast_source);
+ return ast_sp;
}
}
}
return lldb::TypeSystemSP();
}
-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});
-
- 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());
+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;
+}
+
+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;
}
void ClangASTContext::Initialize() {
- PluginManager::RegisterPlugin(GetPluginNameStatic(),
- "clang base AST context plug-in",
- CreateInstance, EnumerateSupportedLanguages);
+ PluginManager::RegisterPlugin(
+ GetPluginNameStatic(), "clang base AST context plug-in", CreateInstance,
+ GetSupportedLanguagesForTypes(), GetSupportedLanguagesForExpressions());
}
void ClangASTContext::Terminate() {
@@ -762,11 +645,10 @@ void ClangASTContext::Terminate() {
}
void ClangASTContext::Finalize() {
- if (m_ast_up) {
- GetASTMap().Erase(m_ast_up.get());
- if (!m_ast_owned)
- m_ast_up.release();
- }
+ assert(m_ast_up);
+ GetASTMap().Erase(m_ast_up.get());
+ if (!m_ast_owned)
+ m_ast_up.release();
m_builtins_up.reset();
m_selector_table_up.reset();
@@ -776,23 +658,9 @@ void ClangASTContext::Finalize() {
m_diagnostics_engine_up.reset();
m_source_manager_up.reset();
m_language_options_up.reset();
- m_ast_up.reset();
m_scratch_ast_source_up.reset();
}
-void ClangASTContext::Clear() {
- m_ast_up.reset();
- m_language_options_up.reset();
- m_source_manager_up.reset();
- m_diagnostics_engine_up.reset();
- m_target_options_rp.reset();
- m_target_info_up.reset();
- m_identifier_table_up.reset();
- m_selector_table_up.reset();
- m_builtins_up.reset();
- m_pointer_byte_size = 0;
-}
-
void ClangASTContext::setSema(Sema *s) {
// Ensure that the new sema actually belongs to our ASTContext.
assert(s == nullptr || &s->getASTContext() == m_ast_up.get());
@@ -803,20 +671,8 @@ const char *ClangASTContext::GetTargetTriple() {
return m_target_triple.c_str();
}
-void ClangASTContext::SetTargetTriple(const char *target_triple) {
- Clear();
- m_target_triple.assign(target_triple);
-}
-
-void ClangASTContext::SetArchitecture(const ArchSpec &arch) {
- SetTargetTriple(arch.GetTriple().str().c_str());
-}
-
-bool ClangASTContext::HasExternalSource() {
- ASTContext *ast = getASTContext();
- if (ast)
- return ast->getExternalSource() != nullptr;
- return false;
+void ClangASTContext::SetTargetTriple(llvm::StringRef target_triple) {
+ m_target_triple = target_triple.str();
}
void ClangASTContext::SetExternalSource(
@@ -828,56 +684,40 @@ void ClangASTContext::SetExternalSource(
}
}
-void ClangASTContext::RemoveExternalSource() {
- ASTContext *ast = getASTContext();
-
- if (ast) {
- llvm::IntrusiveRefCntPtr<ExternalASTSource> empty_ast_source_up;
- ast->setExternalSource(empty_ast_source_up);
- ast->getTranslationUnitDecl()->setHasExternalLexicalStorage(false);
- }
-}
-
-void ClangASTContext::setASTContext(clang::ASTContext *ast_ctx) {
- if (!m_ast_owned) {
- m_ast_up.release();
- }
- m_ast_owned = false;
- m_ast_up.reset(ast_ctx);
- GetASTMap().Insert(ast_ctx, this);
+ASTContext *ClangASTContext::getASTContext() {
+ assert(m_ast_up);
+ return m_ast_up.get();
}
-ASTContext *ClangASTContext::getASTContext() {
- if (m_ast_up == nullptr) {
- m_ast_owned = true;
- m_ast_up.reset(new ASTContext(*getLanguageOptions(), *getSourceManager(),
- *getIdentifierTable(), *getSelectorTable(),
- *getBuiltinContext()));
+void ClangASTContext::CreateASTContext() {
+ assert(!m_ast_up);
+ m_ast_owned = true;
+ m_ast_up.reset(new ASTContext(*getLanguageOptions(), *getSourceManager(),
+ *getIdentifierTable(), *getSelectorTable(),
+ *getBuiltinContext()));
- m_ast_up->getDiagnostics().setClient(getDiagnosticConsumer(), false);
+ m_ast_up->getDiagnostics().setClient(getDiagnosticConsumer(), false);
- // This can be NULL if we don't know anything about the architecture or if
- // the target for an architecture isn't enabled in the llvm/clang that we
- // built
- TargetInfo *target_info = getTargetInfo();
- if (target_info)
- m_ast_up->InitBuiltinTypes(*target_info);
+ // This can be NULL if we don't know anything about the architecture or if
+ // the target for an architecture isn't enabled in the llvm/clang that we
+ // built
+ TargetInfo *target_info = getTargetInfo();
+ if (target_info)
+ m_ast_up->InitBuiltinTypes(*target_info);
- if ((m_callback_tag_decl || m_callback_objc_decl) && m_callback_baton) {
- m_ast_up->getTranslationUnitDecl()->setHasExternalLexicalStorage();
- // m_ast_up->getTranslationUnitDecl()->setHasExternalVisibleStorage();
- }
+ if ((m_callback_tag_decl || m_callback_objc_decl) && m_callback_baton) {
+ m_ast_up->getTranslationUnitDecl()->setHasExternalLexicalStorage();
+ // m_ast_up->getTranslationUnitDecl()->setHasExternalVisibleStorage();
+ }
- GetASTMap().Insert(m_ast_up.get(), this);
+ GetASTMap().Insert(m_ast_up.get(), this);
- llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> ast_source_up(
- new ClangExternalASTSourceCallbacks(
- ClangASTContext::CompleteTagDecl,
- ClangASTContext::CompleteObjCInterfaceDecl, nullptr,
- ClangASTContext::LayoutRecordType, this));
- SetExternalSource(ast_source_up);
- }
- return m_ast_up.get();
+ llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> ast_source_up(
+ new ClangExternalASTSourceCallbacks(
+ ClangASTContext::CompleteTagDecl,
+ ClangASTContext::CompleteObjCInterfaceDecl, nullptr,
+ ClangASTContext::LayoutRecordType, this));
+ SetExternalSource(ast_source_up);
}
ClangASTContext *ClangASTContext::GetASTContext(clang::ASTContext *ast) {
@@ -901,8 +741,9 @@ IdentifierTable *ClangASTContext::getIdentifierTable() {
LangOptions *ClangASTContext::getLanguageOptions() {
if (m_language_options_up == nullptr) {
m_language_options_up.reset(new LangOptions());
- ParseLangArgs(*m_language_options_up, InputKind::ObjCXX, GetTargetTriple());
- // InitializeLangOptions(*m_language_options_up, InputKind::ObjCXX);
+ ParseLangArgs(*m_language_options_up, clang::Language::ObjCXX,
+ GetTargetTriple());
+ // InitializeLangOptions(*m_language_options_up, Language::ObjCXX);
}
return m_language_options_up.get();
}
@@ -956,7 +797,7 @@ public:
llvm::SmallVector<char, 32> diag_str(10);
info.FormatDiagnostic(diag_str);
diag_str.push_back('\0');
- m_log->Printf("Compiler diagnostic: %s\n", diag_str.data());
+ LLDB_LOGF(m_log, "Compiler diagnostic: %s\n", diag_str.data());
}
}
@@ -1009,60 +850,71 @@ ClangASTContext::GetBuiltinTypeForEncodingAndBitSize(Encoding encoding,
CompilerType ClangASTContext::GetBuiltinTypeForEncodingAndBitSize(
ASTContext *ast, Encoding encoding, uint32_t bit_size) {
+ auto *clang_ast_context = ClangASTContext::GetASTContext(ast);
if (!ast)
return CompilerType();
switch (encoding) {
case eEncodingInvalid:
if (QualTypeMatchesBitSize(bit_size, ast, ast->VoidPtrTy))
- return CompilerType(ast, ast->VoidPtrTy);
+ return CompilerType(clang_ast_context, ast->VoidPtrTy.getAsOpaquePtr());
break;
case eEncodingUint:
if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedCharTy))
- return CompilerType(ast, ast->UnsignedCharTy);
+ return CompilerType(clang_ast_context,
+ ast->UnsignedCharTy.getAsOpaquePtr());
if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedShortTy))
- return CompilerType(ast, ast->UnsignedShortTy);
+ return CompilerType(clang_ast_context,
+ ast->UnsignedShortTy.getAsOpaquePtr());
if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedIntTy))
- return CompilerType(ast, ast->UnsignedIntTy);
+ return CompilerType(clang_ast_context,
+ ast->UnsignedIntTy.getAsOpaquePtr());
if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedLongTy))
- return CompilerType(ast, ast->UnsignedLongTy);
+ return CompilerType(clang_ast_context,
+ ast->UnsignedLongTy.getAsOpaquePtr());
if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedLongLongTy))
- return CompilerType(ast, ast->UnsignedLongLongTy);
+ return CompilerType(clang_ast_context,
+ ast->UnsignedLongLongTy.getAsOpaquePtr());
if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedInt128Ty))
- return CompilerType(ast, ast->UnsignedInt128Ty);
+ return CompilerType(clang_ast_context,
+ ast->UnsignedInt128Ty.getAsOpaquePtr());
break;
case eEncodingSint:
if (QualTypeMatchesBitSize(bit_size, ast, ast->SignedCharTy))
- return CompilerType(ast, ast->SignedCharTy);
+ return CompilerType(clang_ast_context,
+ ast->SignedCharTy.getAsOpaquePtr());
if (QualTypeMatchesBitSize(bit_size, ast, ast->ShortTy))
- return CompilerType(ast, ast->ShortTy);
+ return CompilerType(clang_ast_context, ast->ShortTy.getAsOpaquePtr());
if (QualTypeMatchesBitSize(bit_size, ast, ast->IntTy))
- return CompilerType(ast, ast->IntTy);
+ return CompilerType(clang_ast_context, ast->IntTy.getAsOpaquePtr());
if (QualTypeMatchesBitSize(bit_size, ast, ast->LongTy))
- return CompilerType(ast, ast->LongTy);
+ return CompilerType(clang_ast_context, ast->LongTy.getAsOpaquePtr());
if (QualTypeMatchesBitSize(bit_size, ast, ast->LongLongTy))
- return CompilerType(ast, ast->LongLongTy);
+ return CompilerType(clang_ast_context, ast->LongLongTy.getAsOpaquePtr());
if (QualTypeMatchesBitSize(bit_size, ast, ast->Int128Ty))
- return CompilerType(ast, ast->Int128Ty);
+ return CompilerType(clang_ast_context, ast->Int128Ty.getAsOpaquePtr());
break;
case eEncodingIEEE754:
if (QualTypeMatchesBitSize(bit_size, ast, ast->FloatTy))
- return CompilerType(ast, ast->FloatTy);
+ return CompilerType(clang_ast_context, ast->FloatTy.getAsOpaquePtr());
if (QualTypeMatchesBitSize(bit_size, ast, ast->DoubleTy))
- return CompilerType(ast, ast->DoubleTy);
+ return CompilerType(clang_ast_context, ast->DoubleTy.getAsOpaquePtr());
if (QualTypeMatchesBitSize(bit_size, ast, ast->LongDoubleTy))
- return CompilerType(ast, ast->LongDoubleTy);
+ return CompilerType(clang_ast_context,
+ ast->LongDoubleTy.getAsOpaquePtr());
if (QualTypeMatchesBitSize(bit_size, ast, ast->HalfTy))
- return CompilerType(ast, ast->HalfTy);
+ return CompilerType(clang_ast_context, ast->HalfTy.getAsOpaquePtr());
break;
case eEncodingVector:
// Sanity check that bit_size is a multiple of 8's.
if (bit_size && !(bit_size & 0x7u))
return CompilerType(
- ast, ast->getExtVectorType(ast->UnsignedCharTy, bit_size / 8));
+ clang_ast_context,
+ ast->getExtVectorType(ast->UnsignedCharTy, bit_size / 8)
+ .getAsOpaquePtr());
break;
}
@@ -1182,18 +1034,18 @@ CompilerType ClangASTContext::GetBuiltinTypeForDWARFEncodingAndBitSize(
case DW_ATE_address:
if (QualTypeMatchesBitSize(bit_size, ast, ast->VoidPtrTy))
- return CompilerType(ast, ast->VoidPtrTy);
+ return CompilerType(this, ast->VoidPtrTy.getAsOpaquePtr());
break;
case DW_ATE_boolean:
if (QualTypeMatchesBitSize(bit_size, ast, ast->BoolTy))
- return CompilerType(ast, ast->BoolTy);
+ return CompilerType(this, ast->BoolTy.getAsOpaquePtr());
if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedCharTy))
- return CompilerType(ast, ast->UnsignedCharTy);
+ return CompilerType(this, ast->UnsignedCharTy.getAsOpaquePtr());
if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedShortTy))
- return CompilerType(ast, ast->UnsignedShortTy);
+ return CompilerType(this, ast->UnsignedShortTy.getAsOpaquePtr());
if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedIntTy))
- return CompilerType(ast, ast->UnsignedIntTy);
+ return CompilerType(this, ast->UnsignedIntTy.getAsOpaquePtr());
break;
case DW_ATE_lo_user:
@@ -1203,47 +1055,51 @@ CompilerType ClangASTContext::GetBuiltinTypeForDWARFEncodingAndBitSize(
CompilerType complex_int_clang_type =
GetBuiltinTypeForDWARFEncodingAndBitSize("int", DW_ATE_signed,
bit_size / 2);
- return CompilerType(ast, ast->getComplexType(ClangUtil::GetQualType(
- complex_int_clang_type)));
+ return CompilerType(
+ this, ast->getComplexType(
+ ClangUtil::GetQualType(complex_int_clang_type))
+ .getAsOpaquePtr());
}
}
break;
case DW_ATE_complex_float:
if (QualTypeMatchesBitSize(bit_size, ast, ast->FloatComplexTy))
- return CompilerType(ast, ast->FloatComplexTy);
+ return CompilerType(this, ast->FloatComplexTy.getAsOpaquePtr());
else if (QualTypeMatchesBitSize(bit_size, ast, ast->DoubleComplexTy))
- return CompilerType(ast, ast->DoubleComplexTy);
+ return CompilerType(this, ast->DoubleComplexTy.getAsOpaquePtr());
else if (QualTypeMatchesBitSize(bit_size, ast, ast->LongDoubleComplexTy))
- return CompilerType(ast, ast->LongDoubleComplexTy);
+ return CompilerType(this, ast->LongDoubleComplexTy.getAsOpaquePtr());
else {
CompilerType complex_float_clang_type =
GetBuiltinTypeForDWARFEncodingAndBitSize("float", DW_ATE_float,
bit_size / 2);
- return CompilerType(ast, ast->getComplexType(ClangUtil::GetQualType(
- complex_float_clang_type)));
+ return CompilerType(
+ this, ast->getComplexType(
+ ClangUtil::GetQualType(complex_float_clang_type))
+ .getAsOpaquePtr());
}
break;
case DW_ATE_float:
if (streq(type_name, "float") &&
QualTypeMatchesBitSize(bit_size, ast, ast->FloatTy))
- return CompilerType(ast, ast->FloatTy);
+ return CompilerType(this, ast->FloatTy.getAsOpaquePtr());
if (streq(type_name, "double") &&
QualTypeMatchesBitSize(bit_size, ast, ast->DoubleTy))
- return CompilerType(ast, ast->DoubleTy);
+ return CompilerType(this, ast->DoubleTy.getAsOpaquePtr());
if (streq(type_name, "long double") &&
QualTypeMatchesBitSize(bit_size, ast, ast->LongDoubleTy))
- return CompilerType(ast, ast->LongDoubleTy);
+ return CompilerType(this, ast->LongDoubleTy.getAsOpaquePtr());
// Fall back to not requiring a name match
if (QualTypeMatchesBitSize(bit_size, ast, ast->FloatTy))
- return CompilerType(ast, ast->FloatTy);
+ return CompilerType(this, ast->FloatTy.getAsOpaquePtr());
if (QualTypeMatchesBitSize(bit_size, ast, ast->DoubleTy))
- return CompilerType(ast, ast->DoubleTy);
+ return CompilerType(this, ast->DoubleTy.getAsOpaquePtr());
if (QualTypeMatchesBitSize(bit_size, ast, ast->LongDoubleTy))
- return CompilerType(ast, ast->LongDoubleTy);
+ return CompilerType(this, ast->LongDoubleTy.getAsOpaquePtr());
if (QualTypeMatchesBitSize(bit_size, ast, ast->HalfTy))
- return CompilerType(ast, ast->HalfTy);
+ return CompilerType(this, ast->HalfTy.getAsOpaquePtr());
break;
case DW_ATE_signed:
@@ -1252,55 +1108,55 @@ CompilerType ClangASTContext::GetBuiltinTypeForDWARFEncodingAndBitSize(
QualTypeMatchesBitSize(bit_size, ast, ast->WCharTy) &&
(getTargetInfo() &&
TargetInfo::isTypeSigned(getTargetInfo()->getWCharType())))
- return CompilerType(ast, ast->WCharTy);
+ return CompilerType(this, ast->WCharTy.getAsOpaquePtr());
if (streq(type_name, "void") &&
QualTypeMatchesBitSize(bit_size, ast, ast->VoidTy))
- return CompilerType(ast, ast->VoidTy);
+ return CompilerType(this, ast->VoidTy.getAsOpaquePtr());
if (strstr(type_name, "long long") &&
QualTypeMatchesBitSize(bit_size, ast, ast->LongLongTy))
- return CompilerType(ast, ast->LongLongTy);
+ return CompilerType(this, ast->LongLongTy.getAsOpaquePtr());
if (strstr(type_name, "long") &&
QualTypeMatchesBitSize(bit_size, ast, ast->LongTy))
- return CompilerType(ast, ast->LongTy);
+ return CompilerType(this, ast->LongTy.getAsOpaquePtr());
if (strstr(type_name, "short") &&
QualTypeMatchesBitSize(bit_size, ast, ast->ShortTy))
- return CompilerType(ast, ast->ShortTy);
+ return CompilerType(this, ast->ShortTy.getAsOpaquePtr());
if (strstr(type_name, "char")) {
if (QualTypeMatchesBitSize(bit_size, ast, ast->CharTy))
- return CompilerType(ast, ast->CharTy);
+ return CompilerType(this, ast->CharTy.getAsOpaquePtr());
if (QualTypeMatchesBitSize(bit_size, ast, ast->SignedCharTy))
- return CompilerType(ast, ast->SignedCharTy);
+ return CompilerType(this, ast->SignedCharTy.getAsOpaquePtr());
}
if (strstr(type_name, "int")) {
if (QualTypeMatchesBitSize(bit_size, ast, ast->IntTy))
- return CompilerType(ast, ast->IntTy);
+ return CompilerType(this, ast->IntTy.getAsOpaquePtr());
if (QualTypeMatchesBitSize(bit_size, ast, ast->Int128Ty))
- return CompilerType(ast, ast->Int128Ty);
+ return CompilerType(this, ast->Int128Ty.getAsOpaquePtr());
}
}
// We weren't able to match up a type name, just search by size
if (QualTypeMatchesBitSize(bit_size, ast, ast->CharTy))
- return CompilerType(ast, ast->CharTy);
+ return CompilerType(this, ast->CharTy.getAsOpaquePtr());
if (QualTypeMatchesBitSize(bit_size, ast, ast->ShortTy))
- return CompilerType(ast, ast->ShortTy);
+ return CompilerType(this, ast->ShortTy.getAsOpaquePtr());
if (QualTypeMatchesBitSize(bit_size, ast, ast->IntTy))
- return CompilerType(ast, ast->IntTy);
+ return CompilerType(this, ast->IntTy.getAsOpaquePtr());
if (QualTypeMatchesBitSize(bit_size, ast, ast->LongTy))
- return CompilerType(ast, ast->LongTy);
+ return CompilerType(this, ast->LongTy.getAsOpaquePtr());
if (QualTypeMatchesBitSize(bit_size, ast, ast->LongLongTy))
- return CompilerType(ast, ast->LongLongTy);
+ return CompilerType(this, ast->LongLongTy.getAsOpaquePtr());
if (QualTypeMatchesBitSize(bit_size, ast, ast->Int128Ty))
- return CompilerType(ast, ast->Int128Ty);
+ return CompilerType(this, ast->Int128Ty.getAsOpaquePtr());
break;
case DW_ATE_signed_char:
if (ast->getLangOpts().CharIsSigned && type_name &&
streq(type_name, "char")) {
if (QualTypeMatchesBitSize(bit_size, ast, ast->CharTy))
- return CompilerType(ast, ast->CharTy);
+ return CompilerType(this, ast->CharTy.getAsOpaquePtr());
}
if (QualTypeMatchesBitSize(bit_size, ast, ast->SignedCharTy))
- return CompilerType(ast, ast->SignedCharTy);
+ return CompilerType(this, ast->SignedCharTy.getAsOpaquePtr());
break;
case DW_ATE_unsigned:
@@ -1309,53 +1165,53 @@ CompilerType ClangASTContext::GetBuiltinTypeForDWARFEncodingAndBitSize(
if (QualTypeMatchesBitSize(bit_size, ast, ast->WCharTy)) {
if (!(getTargetInfo() &&
TargetInfo::isTypeSigned(getTargetInfo()->getWCharType())))
- return CompilerType(ast, ast->WCharTy);
+ return CompilerType(this, ast->WCharTy.getAsOpaquePtr());
}
}
if (strstr(type_name, "long long")) {
if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedLongLongTy))
- return CompilerType(ast, ast->UnsignedLongLongTy);
+ return CompilerType(this, ast->UnsignedLongLongTy.getAsOpaquePtr());
} else if (strstr(type_name, "long")) {
if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedLongTy))
- return CompilerType(ast, ast->UnsignedLongTy);
+ return CompilerType(this, ast->UnsignedLongTy.getAsOpaquePtr());
} else if (strstr(type_name, "short")) {
if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedShortTy))
- return CompilerType(ast, ast->UnsignedShortTy);
+ return CompilerType(this, ast->UnsignedShortTy.getAsOpaquePtr());
} else if (strstr(type_name, "char")) {
if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedCharTy))
- return CompilerType(ast, ast->UnsignedCharTy);
+ return CompilerType(this, ast->UnsignedCharTy.getAsOpaquePtr());
} else if (strstr(type_name, "int")) {
if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedIntTy))
- return CompilerType(ast, ast->UnsignedIntTy);
+ return CompilerType(this, ast->UnsignedIntTy.getAsOpaquePtr());
if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedInt128Ty))
- return CompilerType(ast, ast->UnsignedInt128Ty);
+ return CompilerType(this, ast->UnsignedInt128Ty.getAsOpaquePtr());
}
}
// We weren't able to match up a type name, just search by size
if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedCharTy))
- return CompilerType(ast, ast->UnsignedCharTy);
+ return CompilerType(this, ast->UnsignedCharTy.getAsOpaquePtr());
if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedShortTy))
- return CompilerType(ast, ast->UnsignedShortTy);
+ return CompilerType(this, ast->UnsignedShortTy.getAsOpaquePtr());
if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedIntTy))
- return CompilerType(ast, ast->UnsignedIntTy);
+ return CompilerType(this, ast->UnsignedIntTy.getAsOpaquePtr());
if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedLongTy))
- return CompilerType(ast, ast->UnsignedLongTy);
+ return CompilerType(this, ast->UnsignedLongTy.getAsOpaquePtr());
if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedLongLongTy))
- return CompilerType(ast, ast->UnsignedLongLongTy);
+ return CompilerType(this, ast->UnsignedLongLongTy.getAsOpaquePtr());
if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedInt128Ty))
- return CompilerType(ast, ast->UnsignedInt128Ty);
+ return CompilerType(this, ast->UnsignedInt128Ty.getAsOpaquePtr());
break;
case DW_ATE_unsigned_char:
if (!ast->getLangOpts().CharIsSigned && type_name &&
streq(type_name, "char")) {
if (QualTypeMatchesBitSize(bit_size, ast, ast->CharTy))
- return CompilerType(ast, ast->CharTy);
+ return CompilerType(this, ast->CharTy.getAsOpaquePtr());
}
if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedCharTy))
- return CompilerType(ast, ast->UnsignedCharTy);
+ return CompilerType(this, ast->UnsignedCharTy.getAsOpaquePtr());
if (QualTypeMatchesBitSize(bit_size, ast, ast->UnsignedShortTy))
- return CompilerType(ast, ast->UnsignedShortTy);
+ return CompilerType(this, ast->UnsignedShortTy.getAsOpaquePtr());
break;
case DW_ATE_imaginary_float:
@@ -1363,11 +1219,12 @@ CompilerType ClangASTContext::GetBuiltinTypeForDWARFEncodingAndBitSize(
case DW_ATE_UTF:
if (type_name) {
- if (streq(type_name, "char16_t")) {
- return CompilerType(ast, ast->Char16Ty);
- } else if (streq(type_name, "char32_t")) {
- return CompilerType(ast, ast->Char32Ty);
- }
+ if (streq(type_name, "char16_t"))
+ return CompilerType(this, ast->Char16Ty.getAsOpaquePtr());
+ if (streq(type_name, "char32_t"))
+ return CompilerType(this, ast->Char32Ty.getAsOpaquePtr());
+ if (streq(type_name, "char8_t"))
+ return CompilerType(this, ast->Char8Ty.getAsOpaquePtr());
}
break;
}
@@ -1390,7 +1247,8 @@ CompilerType ClangASTContext::GetBuiltinTypeForDWARFEncodingAndBitSize(
CompilerType ClangASTContext::GetUnknownAnyType(clang::ASTContext *ast) {
if (ast)
- return CompilerType(ast, ast->UnknownAnyTy);
+ return CompilerType(ClangASTContext::GetASTContext(ast),
+ ast->UnknownAnyTy.getAsOpaquePtr());
return CompilerType();
}
@@ -1401,7 +1259,7 @@ CompilerType ClangASTContext::GetCStringType(bool is_const) {
if (is_const)
char_type.addConst();
- return CompilerType(ast, ast->getPointerType(char_type));
+ return CompilerType(this, ast->getPointerType(char_type).getAsOpaquePtr());
}
clang::DeclContext *
@@ -1446,6 +1304,16 @@ bool ClangASTContext::AreTypesSame(CompilerType type1, CompilerType type2,
return ast->getASTContext()->hasSameType(type1_qual, type2_qual);
}
+CompilerType ClangASTContext::GetTypeForDecl(void *opaque_decl) {
+ if (!opaque_decl)
+ return CompilerType();
+
+ clang::Decl *decl = static_cast<clang::Decl *>(opaque_decl);
+ if (auto *named_decl = llvm::dyn_cast<clang::NamedDecl>(decl))
+ return GetTypeForDecl(named_decl);
+ return CompilerType();
+}
+
CompilerType ClangASTContext::GetTypeForDecl(clang::NamedDecl *decl) {
if (clang::ObjCInterfaceDecl *interface_decl =
llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl))
@@ -1461,7 +1329,8 @@ CompilerType ClangASTContext::GetTypeForDecl(TagDecl *decl) {
// AST if our AST didn't already exist...
ASTContext *ast = &decl->getASTContext();
if (ast)
- return CompilerType(ast, ast->getTagDeclType(decl));
+ return CompilerType(ClangASTContext::GetASTContext(ast),
+ ast->getTagDeclType(decl).getAsOpaquePtr());
return CompilerType();
}
@@ -1471,7 +1340,8 @@ CompilerType ClangASTContext::GetTypeForDecl(ObjCInterfaceDecl *decl) {
// AST if our AST didn't already exist...
ASTContext *ast = &decl->getASTContext();
if (ast)
- return CompilerType(ast, ast->getObjCInterfaceType(decl));
+ return CompilerType(ClangASTContext::GetASTContext(ast),
+ ast->getObjCInterfaceType(decl).getAsOpaquePtr());
return CompilerType();
}
@@ -1501,14 +1371,43 @@ CompilerType ClangASTContext::CreateRecordType(DeclContext *decl_ctx,
// something is struct or a class, so we default to always use the more
// complete definition just in case.
- bool is_anonymous = (!name) || (!name[0]);
+ bool has_name = name && name[0];
CXXRecordDecl *decl = CXXRecordDecl::Create(
*ast, (TagDecl::TagKind)kind, decl_ctx, SourceLocation(),
- SourceLocation(), is_anonymous ? nullptr : &ast->Idents.get(name));
+ SourceLocation(), has_name ? &ast->Idents.get(name) : nullptr);
- if (is_anonymous)
- decl->setAnonymousStructOrUnion(true);
+ if (!has_name) {
+ // In C++ a lambda is also represented as an unnamed class. This is
+ // different from an *anonymous class* that the user wrote:
+ //
+ // struct A {
+ // // anonymous class (GNU/MSVC extension)
+ // struct {
+ // int x;
+ // };
+ // // unnamed class within a class
+ // struct {
+ // int y;
+ // } B;
+ // };
+ //
+ // void f() {
+ // // unammed class outside of a class
+ // struct {
+ // int z;
+ // } C;
+ // }
+ //
+ // Anonymous classes is a GNU/MSVC extension that clang supports. It
+ // requires the anonymous class be embedded within a class. So the new
+ // heuristic verifies this condition.
+ //
+ // FIXME: An unnamed class within a class is also wrongly recognized as an
+ // anonymous struct.
+ if (isa<CXXRecordDecl>(decl_ctx))
+ decl->setAnonymousStructOrUnion(true);
+ }
if (decl) {
if (metadata)
@@ -1520,7 +1419,7 @@ CompilerType ClangASTContext::CreateRecordType(DeclContext *decl_ctx,
if (decl_ctx)
decl_ctx->addDecl(decl);
- return CompilerType(ast, ast->getTagDeclType(decl));
+ return CompilerType(this, ast->getTagDeclType(decl).getAsOpaquePtr());
}
return CompilerType();
}
@@ -1743,7 +1642,8 @@ CompilerType ClangASTContext::CreateClassTemplateSpecializationType(
ASTContext *ast = getASTContext();
if (ast)
return CompilerType(
- ast, ast->getTagDeclType(class_template_specialization_decl));
+ this, ast->getTagDeclType(class_template_specialization_decl)
+ .getAsOpaquePtr());
}
return CompilerType();
}
@@ -1874,7 +1774,7 @@ CompilerType ClangASTContext::CreateObjCClass(const char *name,
if (decl && metadata)
SetMetadata(ast, decl, *metadata);
- return CompilerType(ast, ast->getObjCInterfaceType(decl));
+ return CompilerType(this, ast->getObjCInterfaceType(decl).getAsOpaquePtr());
}
static inline bool BaseSpecifierIsEmpty(const CXXBaseSpecifier *b) {
@@ -2220,14 +2120,14 @@ CompilerType ClangASTContext::CreateFunctionType(
proto_info.TypeQuals = clang::Qualifiers::fromFastMask(type_quals);
proto_info.RefQualifier = RQ_None;
- return CompilerType(ast,
+ return CompilerType(ClangASTContext::GetASTContext(ast),
ast->getFunctionType(ClangUtil::GetQualType(result_type),
- qual_type_args, proto_info));
+ qual_type_args, proto_info).getAsOpaquePtr());
}
ParmVarDecl *ClangASTContext::CreateParameterDeclaration(
clang::DeclContext *decl_ctx, const char *name,
- const CompilerType &param_type, int storage) {
+ const CompilerType &param_type, int storage, bool add_decl) {
ASTContext *ast = getASTContext();
assert(ast != nullptr);
auto *decl =
@@ -2235,7 +2135,9 @@ ParmVarDecl *ClangASTContext::CreateParameterDeclaration(
name && name[0] ? &ast->Idents.get(name) : nullptr,
ClangUtil::GetQualType(param_type), nullptr,
(clang::StorageClass)storage, nullptr);
- decl_ctx->addDecl(decl);
+ if (add_decl)
+ decl_ctx->addDecl(decl);
+
return decl;
}
@@ -2265,20 +2167,23 @@ CompilerType ClangASTContext::CreateArrayType(const CompilerType &element_type,
if (is_vector) {
return CompilerType(
- ast, ast->getExtVectorType(ClangUtil::GetQualType(element_type),
- element_count));
+ this, ast->getExtVectorType(ClangUtil::GetQualType(element_type),
+ element_count)
+ .getAsOpaquePtr());
} else {
llvm::APInt ap_element_count(64, element_count);
if (element_count == 0) {
- return CompilerType(ast, ast->getIncompleteArrayType(
- ClangUtil::GetQualType(element_type),
- clang::ArrayType::Normal, 0));
+ return CompilerType(this, ast->getIncompleteArrayType(
+ ClangUtil::GetQualType(element_type),
+ clang::ArrayType::Normal, 0)
+ .getAsOpaquePtr());
} else {
- return CompilerType(
- ast, ast->getConstantArrayType(ClangUtil::GetQualType(element_type),
- ap_element_count,
- clang::ArrayType::Normal, 0));
+ return CompilerType(this, ast->getConstantArrayType(
+ ClangUtil::GetQualType(element_type),
+ ap_element_count, nullptr,
+ clang::ArrayType::Normal, 0)
+ .getAsOpaquePtr());
}
}
}
@@ -2352,7 +2257,7 @@ ClangASTContext::CreateEnumerationType(const char *name, DeclContext *decl_ctx,
enum_decl->setAccess(AS_public); // TODO respect what's in the debug info
- return CompilerType(ast, ast->getTagDeclType(enum_decl));
+ return CompilerType(this, ast->getTagDeclType(enum_decl).getAsOpaquePtr());
}
return CompilerType();
}
@@ -2361,42 +2266,51 @@ CompilerType ClangASTContext::GetIntTypeFromBitSize(clang::ASTContext *ast,
size_t bit_size,
bool is_signed) {
if (ast) {
+ auto *clang_ast_context = ClangASTContext::GetASTContext(ast);
if (is_signed) {
if (bit_size == ast->getTypeSize(ast->SignedCharTy))
- return CompilerType(ast, ast->SignedCharTy);
+ return CompilerType(clang_ast_context,
+ ast->SignedCharTy.getAsOpaquePtr());
if (bit_size == ast->getTypeSize(ast->ShortTy))
- return CompilerType(ast, ast->ShortTy);
+ return CompilerType(clang_ast_context, ast->ShortTy.getAsOpaquePtr());
if (bit_size == ast->getTypeSize(ast->IntTy))
- return CompilerType(ast, ast->IntTy);
+ return CompilerType(clang_ast_context, ast->IntTy.getAsOpaquePtr());
if (bit_size == ast->getTypeSize(ast->LongTy))
- return CompilerType(ast, ast->LongTy);
+ return CompilerType(clang_ast_context, ast->LongTy.getAsOpaquePtr());
if (bit_size == ast->getTypeSize(ast->LongLongTy))
- return CompilerType(ast, ast->LongLongTy);
+ return CompilerType(clang_ast_context,
+ ast->LongLongTy.getAsOpaquePtr());
if (bit_size == ast->getTypeSize(ast->Int128Ty))
- return CompilerType(ast, ast->Int128Ty);
+ return CompilerType(clang_ast_context, ast->Int128Ty.getAsOpaquePtr());
} else {
if (bit_size == ast->getTypeSize(ast->UnsignedCharTy))
- return CompilerType(ast, ast->UnsignedCharTy);
+ return CompilerType(clang_ast_context,
+ ast->UnsignedCharTy.getAsOpaquePtr());
if (bit_size == ast->getTypeSize(ast->UnsignedShortTy))
- return CompilerType(ast, ast->UnsignedShortTy);
+ return CompilerType(clang_ast_context,
+ ast->UnsignedShortTy.getAsOpaquePtr());
if (bit_size == ast->getTypeSize(ast->UnsignedIntTy))
- return CompilerType(ast, ast->UnsignedIntTy);
+ return CompilerType(clang_ast_context,
+ ast->UnsignedIntTy.getAsOpaquePtr());
if (bit_size == ast->getTypeSize(ast->UnsignedLongTy))
- return CompilerType(ast, ast->UnsignedLongTy);
+ return CompilerType(clang_ast_context,
+ ast->UnsignedLongTy.getAsOpaquePtr());
if (bit_size == ast->getTypeSize(ast->UnsignedLongLongTy))
- return CompilerType(ast, ast->UnsignedLongLongTy);
+ return CompilerType(clang_ast_context,
+ ast->UnsignedLongLongTy.getAsOpaquePtr());
if (bit_size == ast->getTypeSize(ast->UnsignedInt128Ty))
- return CompilerType(ast, ast->UnsignedInt128Ty);
+ return CompilerType(clang_ast_context,
+ ast->UnsignedInt128Ty.getAsOpaquePtr());
}
}
return CompilerType();
@@ -2926,8 +2840,9 @@ bool ClangASTContext::IsArrayType(lldb::opaque_compiler_type_t type,
case clang::Type::ConstantArray:
if (element_type_ptr)
element_type_ptr->SetCompilerType(
- getASTContext(),
- llvm::cast<clang::ConstantArrayType>(qual_type)->getElementType());
+ this, llvm::cast<clang::ConstantArrayType>(qual_type)
+ ->getElementType()
+ .getAsOpaquePtr());
if (size)
*size = llvm::cast<clang::ConstantArrayType>(qual_type)
->getSize()
@@ -2939,8 +2854,9 @@ bool ClangASTContext::IsArrayType(lldb::opaque_compiler_type_t type,
case clang::Type::IncompleteArray:
if (element_type_ptr)
element_type_ptr->SetCompilerType(
- getASTContext(),
- llvm::cast<clang::IncompleteArrayType>(qual_type)->getElementType());
+ this, llvm::cast<clang::IncompleteArrayType>(qual_type)
+ ->getElementType()
+ .getAsOpaquePtr());
if (size)
*size = 0;
if (is_incomplete)
@@ -2950,8 +2866,9 @@ bool ClangASTContext::IsArrayType(lldb::opaque_compiler_type_t type,
case clang::Type::VariableArray:
if (element_type_ptr)
element_type_ptr->SetCompilerType(
- getASTContext(),
- llvm::cast<clang::VariableArrayType>(qual_type)->getElementType());
+ this, llvm::cast<clang::VariableArrayType>(qual_type)
+ ->getElementType()
+ .getAsOpaquePtr());
if (size)
*size = 0;
if (is_incomplete)
@@ -2961,8 +2878,9 @@ bool ClangASTContext::IsArrayType(lldb::opaque_compiler_type_t type,
case clang::Type::DependentSizedArray:
if (element_type_ptr)
element_type_ptr->SetCompilerType(
- getASTContext(), llvm::cast<clang::DependentSizedArrayType>(qual_type)
- ->getElementType());
+ this, llvm::cast<clang::DependentSizedArrayType>(qual_type)
+ ->getElementType()
+ .getAsOpaquePtr());
if (size)
*size = 0;
if (is_incomplete)
@@ -3013,7 +2931,7 @@ bool ClangASTContext::IsVectorType(lldb::opaque_compiler_type_t type,
*size = vector_type->getNumElements();
if (element_type)
*element_type =
- CompilerType(getASTContext(), vector_type->getElementType());
+ CompilerType(this, vector_type->getElementType().getAsOpaquePtr());
}
return true;
} break;
@@ -3025,7 +2943,7 @@ bool ClangASTContext::IsVectorType(lldb::opaque_compiler_type_t type,
*size = ext_vector_type->getNumElements();
if (element_type)
*element_type =
- CompilerType(getASTContext(), ext_vector_type->getElementType());
+ CompilerType(this, ext_vector_type->getElementType().getAsOpaquePtr());
}
return true;
}
@@ -3218,7 +3136,7 @@ ClangASTContext::IsHomogeneousAggregate(lldb::opaque_compiler_type_t type,
++num_fields;
}
if (base_type_ptr)
- *base_type_ptr = CompilerType(getASTContext(), base_qual_type);
+ *base_type_ptr = CompilerType(this, base_qual_type.getAsOpaquePtr());
return num_fields;
}
}
@@ -3270,7 +3188,7 @@ ClangASTContext::GetFunctionArgumentAtIndex(lldb::opaque_compiler_type_t type,
llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
if (func) {
if (index < func->getNumParams())
- return CompilerType(getASTContext(), func->getParamType(index));
+ return CompilerType(this, func->getParamType(index).getAsOpaquePtr());
}
}
return CompilerType();
@@ -3330,7 +3248,7 @@ bool ClangASTContext::IsBlockPointerType(
QualType pointee_type = block_pointer_type->getPointeeType();
QualType function_pointer_type = m_ast_up->getPointerType(pointee_type);
*function_pointer_type_ptr =
- CompilerType(getASTContext(), function_pointer_type);
+ CompilerType(this, function_pointer_type.getAsOpaquePtr());
}
return true;
}
@@ -3427,26 +3345,30 @@ bool ClangASTContext::IsPointerType(lldb::opaque_compiler_type_t type,
case clang::Type::ObjCObjectPointer:
if (pointee_type)
pointee_type->SetCompilerType(
- getASTContext(), llvm::cast<clang::ObjCObjectPointerType>(qual_type)
- ->getPointeeType());
+ this, llvm::cast<clang::ObjCObjectPointerType>(qual_type)
+ ->getPointeeType()
+ .getAsOpaquePtr());
return true;
case clang::Type::BlockPointer:
if (pointee_type)
pointee_type->SetCompilerType(
- getASTContext(),
- llvm::cast<clang::BlockPointerType>(qual_type)->getPointeeType());
+ this, llvm::cast<clang::BlockPointerType>(qual_type)
+ ->getPointeeType()
+ .getAsOpaquePtr());
return true;
case clang::Type::Pointer:
if (pointee_type)
- pointee_type->SetCompilerType(
- getASTContext(),
- llvm::cast<clang::PointerType>(qual_type)->getPointeeType());
+ pointee_type->SetCompilerType(this,
+ llvm::cast<clang::PointerType>(qual_type)
+ ->getPointeeType()
+ .getAsOpaquePtr());
return true;
case clang::Type::MemberPointer:
if (pointee_type)
pointee_type->SetCompilerType(
- getASTContext(),
- llvm::cast<clang::MemberPointerType>(qual_type)->getPointeeType());
+ this, llvm::cast<clang::MemberPointerType>(qual_type)
+ ->getPointeeType()
+ .getAsOpaquePtr());
return true;
case clang::Type::Typedef:
return IsPointerType(llvm::cast<clang::TypedefType>(qual_type)
@@ -3495,38 +3417,43 @@ bool ClangASTContext::IsPointerOrReferenceType(
case clang::Type::ObjCObjectPointer:
if (pointee_type)
pointee_type->SetCompilerType(
- getASTContext(), llvm::cast<clang::ObjCObjectPointerType>(qual_type)
- ->getPointeeType());
+ this, llvm::cast<clang::ObjCObjectPointerType>(qual_type)
+ ->getPointeeType().getAsOpaquePtr());
return true;
case clang::Type::BlockPointer:
if (pointee_type)
pointee_type->SetCompilerType(
- getASTContext(),
- llvm::cast<clang::BlockPointerType>(qual_type)->getPointeeType());
+ this, llvm::cast<clang::BlockPointerType>(qual_type)
+ ->getPointeeType()
+ .getAsOpaquePtr());
return true;
case clang::Type::Pointer:
if (pointee_type)
- pointee_type->SetCompilerType(
- getASTContext(),
- llvm::cast<clang::PointerType>(qual_type)->getPointeeType());
+ pointee_type->SetCompilerType(this,
+ llvm::cast<clang::PointerType>(qual_type)
+ ->getPointeeType()
+ .getAsOpaquePtr());
return true;
case clang::Type::MemberPointer:
if (pointee_type)
pointee_type->SetCompilerType(
- getASTContext(),
- llvm::cast<clang::MemberPointerType>(qual_type)->getPointeeType());
+ this, llvm::cast<clang::MemberPointerType>(qual_type)
+ ->getPointeeType()
+ .getAsOpaquePtr());
return true;
case clang::Type::LValueReference:
if (pointee_type)
pointee_type->SetCompilerType(
- getASTContext(),
- llvm::cast<clang::LValueReferenceType>(qual_type)->desugar());
+ this, llvm::cast<clang::LValueReferenceType>(qual_type)
+ ->desugar()
+ .getAsOpaquePtr());
return true;
case clang::Type::RValueReference:
if (pointee_type)
pointee_type->SetCompilerType(
- getASTContext(),
- llvm::cast<clang::RValueReferenceType>(qual_type)->desugar());
+ this, llvm::cast<clang::RValueReferenceType>(qual_type)
+ ->desugar()
+ .getAsOpaquePtr());
return true;
case clang::Type::Typedef:
return IsPointerOrReferenceType(llvm::cast<clang::TypedefType>(qual_type)
@@ -3569,16 +3496,18 @@ bool ClangASTContext::IsReferenceType(lldb::opaque_compiler_type_t type,
case clang::Type::LValueReference:
if (pointee_type)
pointee_type->SetCompilerType(
- getASTContext(),
- llvm::cast<clang::LValueReferenceType>(qual_type)->desugar());
+ this, llvm::cast<clang::LValueReferenceType>(qual_type)
+ ->desugar()
+ .getAsOpaquePtr());
if (is_rvalue)
*is_rvalue = false;
return true;
case clang::Type::RValueReference:
if (pointee_type)
pointee_type->SetCompilerType(
- getASTContext(),
- llvm::cast<clang::RValueReferenceType>(qual_type)->desugar());
+ this, llvm::cast<clang::RValueReferenceType>(qual_type)
+ ->desugar()
+ .getAsOpaquePtr());
if (is_rvalue)
*is_rvalue = true;
return true;
@@ -3770,9 +3699,9 @@ bool ClangASTContext::IsPossibleDynamicType(lldb::opaque_compiler_type_t type,
}
if (dynamic_pointee_type)
dynamic_pointee_type->SetCompilerType(
- getASTContext(),
- llvm::cast<clang::ObjCObjectPointerType>(qual_type)
- ->getPointeeType());
+ this, llvm::cast<clang::ObjCObjectPointerType>(qual_type)
+ ->getPointeeType()
+ .getAsOpaquePtr());
return true;
}
break;
@@ -3832,8 +3761,8 @@ bool ClangASTContext::IsPossibleDynamicType(lldb::opaque_compiler_type_t type,
case clang::BuiltinType::UnknownAny:
case clang::BuiltinType::Void:
if (dynamic_pointee_type)
- dynamic_pointee_type->SetCompilerType(getASTContext(),
- pointee_qual_type);
+ dynamic_pointee_type->SetCompilerType(
+ this, pointee_qual_type.getAsOpaquePtr());
return true;
default:
break;
@@ -3855,8 +3784,9 @@ bool ClangASTContext::IsPossibleDynamicType(lldb::opaque_compiler_type_t type,
if (metadata)
success = metadata->GetIsDynamicCXXType();
else {
- is_complete = CompilerType(getASTContext(), pointee_qual_type)
- .GetCompleteType();
+ is_complete =
+ CompilerType(this, pointee_qual_type.getAsOpaquePtr())
+ .GetCompleteType();
if (is_complete)
success = cxx_record_decl->isDynamicClass();
else
@@ -3866,8 +3796,8 @@ bool ClangASTContext::IsPossibleDynamicType(lldb::opaque_compiler_type_t type,
if (success) {
if (dynamic_pointee_type)
- dynamic_pointee_type->SetCompilerType(getASTContext(),
- pointee_qual_type);
+ dynamic_pointee_type->SetCompilerType(
+ this, pointee_qual_type.getAsOpaquePtr());
return true;
}
}
@@ -3878,8 +3808,8 @@ bool ClangASTContext::IsPossibleDynamicType(lldb::opaque_compiler_type_t type,
case clang::Type::ObjCInterface:
if (check_objc) {
if (dynamic_pointee_type)
- dynamic_pointee_type->SetCompilerType(getASTContext(),
- pointee_qual_type);
+ dynamic_pointee_type->SetCompilerType(
+ this, pointee_qual_type.getAsOpaquePtr());
return true;
}
break;
@@ -3987,25 +3917,6 @@ bool ClangASTContext::IsObjCObjectPointerType(const CompilerType &type,
return false;
}
-bool ClangASTContext::GetObjCClassName(const CompilerType &type,
- std::string &class_name) {
- if (!type)
- return false;
-
- clang::QualType qual_type(ClangUtil::GetCanonicalQualType(type));
-
- const clang::ObjCObjectType *object_type =
- llvm::dyn_cast<clang::ObjCObjectType>(qual_type);
- if (object_type) {
- const clang::ObjCInterfaceDecl *interface = object_type->getInterface();
- if (interface) {
- class_name = interface->getNameAsString();
- return true;
- }
- }
- return false;
-}
-
// Type Completion
bool ClangASTContext::GetCompleteType(lldb::opaque_compiler_type_t type) {
@@ -4062,14 +3973,14 @@ ClangASTContext::GetTypeInfo(lldb::opaque_compiler_type_t type,
case clang::BuiltinType::ObjCClass:
if (pointee_or_element_clang_type)
pointee_or_element_clang_type->SetCompilerType(
- getASTContext(), getASTContext()->ObjCBuiltinClassTy);
+ this, getASTContext()->ObjCBuiltinClassTy.getAsOpaquePtr());
builtin_type_flags |= eTypeIsPointer | eTypeIsObjC;
break;
case clang::BuiltinType::ObjCSel:
if (pointee_or_element_clang_type)
- pointee_or_element_clang_type->SetCompilerType(getASTContext(),
- getASTContext()->CharTy);
+ pointee_or_element_clang_type->SetCompilerType(
+ this, getASTContext()->CharTy.getAsOpaquePtr());
builtin_type_flags |= eTypeIsPointer | eTypeIsObjC;
break;
@@ -4112,7 +4023,7 @@ ClangASTContext::GetTypeInfo(lldb::opaque_compiler_type_t type,
case clang::Type::BlockPointer:
if (pointee_or_element_clang_type)
pointee_or_element_clang_type->SetCompilerType(
- getASTContext(), qual_type->getPointeeType());
+ this, qual_type->getPointeeType().getAsOpaquePtr());
return eTypeIsPointer | eTypeHasChildren | eTypeIsBlock;
case clang::Type::Complex: {
@@ -4136,8 +4047,9 @@ ClangASTContext::GetTypeInfo(lldb::opaque_compiler_type_t type,
case clang::Type::VariableArray:
if (pointee_or_element_clang_type)
pointee_or_element_clang_type->SetCompilerType(
- getASTContext(), llvm::cast<clang::ArrayType>(qual_type.getTypePtr())
- ->getElementType());
+ this, llvm::cast<clang::ArrayType>(qual_type.getTypePtr())
+ ->getElementType()
+ .getAsOpaquePtr());
return eTypeHasChildren | eTypeIsArray;
case clang::Type::DependentName:
@@ -4147,31 +4059,34 @@ ClangASTContext::GetTypeInfo(lldb::opaque_compiler_type_t type,
case clang::Type::DependentTemplateSpecialization:
return eTypeIsTemplate;
case clang::Type::Decltype:
- return CompilerType(
- getASTContext(),
- llvm::cast<clang::DecltypeType>(qual_type)->getUnderlyingType())
+ return CompilerType(this, llvm::cast<clang::DecltypeType>(qual_type)
+ ->getUnderlyingType()
+ .getAsOpaquePtr())
.GetTypeInfo(pointee_or_element_clang_type);
case clang::Type::Enum:
if (pointee_or_element_clang_type)
pointee_or_element_clang_type->SetCompilerType(
- getASTContext(),
- llvm::cast<clang::EnumType>(qual_type)->getDecl()->getIntegerType());
+ this, llvm::cast<clang::EnumType>(qual_type)
+ ->getDecl()
+ ->getIntegerType()
+ .getAsOpaquePtr());
return eTypeIsEnumeration | eTypeHasValue;
case clang::Type::Auto:
- return CompilerType(
- getASTContext(),
- llvm::cast<clang::AutoType>(qual_type)->getDeducedType())
+ return CompilerType(this, llvm::cast<clang::AutoType>(qual_type)
+ ->getDeducedType()
+ .getAsOpaquePtr())
.GetTypeInfo(pointee_or_element_clang_type);
case clang::Type::Elaborated:
- return CompilerType(
- getASTContext(),
- llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType())
+ return CompilerType(this, llvm::cast<clang::ElaboratedType>(qual_type)
+ ->getNamedType()
+ .getAsOpaquePtr())
.GetTypeInfo(pointee_or_element_clang_type);
case clang::Type::Paren:
- return CompilerType(getASTContext(),
- llvm::cast<clang::ParenType>(qual_type)->desugar())
+ return CompilerType(this, llvm::cast<clang::ParenType>(qual_type)
+ ->desugar()
+ .getAsOpaquePtr())
.GetTypeInfo(pointee_or_element_clang_type);
case clang::Type::FunctionProto:
@@ -4185,9 +4100,9 @@ ClangASTContext::GetTypeInfo(lldb::opaque_compiler_type_t type,
case clang::Type::RValueReference:
if (pointee_or_element_clang_type)
pointee_or_element_clang_type->SetCompilerType(
- getASTContext(),
- llvm::cast<clang::ReferenceType>(qual_type.getTypePtr())
- ->getPointeeType());
+ this, llvm::cast<clang::ReferenceType>(qual_type.getTypePtr())
+ ->getPointeeType()
+ .getAsOpaquePtr());
return eTypeHasChildren | eTypeIsReference | eTypeHasValue;
case clang::Type::MemberPointer:
@@ -4196,7 +4111,7 @@ ClangASTContext::GetTypeInfo(lldb::opaque_compiler_type_t type,
case clang::Type::ObjCObjectPointer:
if (pointee_or_element_clang_type)
pointee_or_element_clang_type->SetCompilerType(
- getASTContext(), qual_type->getPointeeType());
+ this, qual_type->getPointeeType().getAsOpaquePtr());
return eTypeHasChildren | eTypeIsObjC | eTypeIsClass | eTypeIsPointer |
eTypeHasValue;
@@ -4208,7 +4123,7 @@ ClangASTContext::GetTypeInfo(lldb::opaque_compiler_type_t type,
case clang::Type::Pointer:
if (pointee_or_element_clang_type)
pointee_or_element_clang_type->SetCompilerType(
- getASTContext(), qual_type->getPointeeType());
+ this, qual_type->getPointeeType().getAsOpaquePtr());
return eTypeHasChildren | eTypeIsPointer | eTypeHasValue;
case clang::Type::Record:
@@ -4226,21 +4141,21 @@ ClangASTContext::GetTypeInfo(lldb::opaque_compiler_type_t type,
case clang::Type::Typedef:
return eTypeIsTypedef |
- CompilerType(getASTContext(),
- llvm::cast<clang::TypedefType>(qual_type)
- ->getDecl()
- ->getUnderlyingType())
+ CompilerType(this, llvm::cast<clang::TypedefType>(qual_type)
+ ->getDecl()
+ ->getUnderlyingType()
+ .getAsOpaquePtr())
.GetTypeInfo(pointee_or_element_clang_type);
case clang::Type::TypeOfExpr:
- return CompilerType(getASTContext(),
- llvm::cast<clang::TypeOfExprType>(qual_type)
- ->getUnderlyingExpr()
- ->getType())
+ return CompilerType(this, llvm::cast<clang::TypeOfExprType>(qual_type)
+ ->getUnderlyingExpr()
+ ->getType()
+ .getAsOpaquePtr())
.GetTypeInfo(pointee_or_element_clang_type);
case clang::Type::TypeOf:
- return CompilerType(
- getASTContext(),
- llvm::cast<clang::TypeOfType>(qual_type)->getUnderlyingType())
+ return CompilerType(this, llvm::cast<clang::TypeOfType>(qual_type)
+ ->getUnderlyingType()
+ .getAsOpaquePtr())
.GetTypeInfo(pointee_or_element_clang_type);
case clang::Type::UnresolvedUsing:
return 0;
@@ -4339,10 +4254,10 @@ ClangASTContext::GetMinimumLanguage(lldb::opaque_compiler_type_t type) {
}
break;
case clang::Type::Typedef:
- return CompilerType(getASTContext(),
- llvm::cast<clang::TypedefType>(qual_type)
- ->getDecl()
- ->getUnderlyingType())
+ return CompilerType(this, llvm::cast<clang::TypedefType>(qual_type)
+ ->getDecl()
+ ->getUnderlyingType()
+ .getAsOpaquePtr())
.GetMinimumLanguage();
}
}
@@ -4420,18 +4335,19 @@ ClangASTContext::GetTypeClass(lldb::opaque_compiler_type_t type) {
case clang::Type::UnresolvedUsing:
break;
case clang::Type::Paren:
- return CompilerType(getASTContext(),
- llvm::cast<clang::ParenType>(qual_type)->desugar())
+ return CompilerType(this, llvm::cast<clang::ParenType>(qual_type)
+ ->desugar()
+ .getAsOpaquePtr())
.GetTypeClass();
case clang::Type::Auto:
- return CompilerType(
- getASTContext(),
- llvm::cast<clang::AutoType>(qual_type)->getDeducedType())
+ return CompilerType(this, llvm::cast<clang::AutoType>(qual_type)
+ ->getDeducedType()
+ .getAsOpaquePtr())
.GetTypeClass();
case clang::Type::Elaborated:
- return CompilerType(
- getASTContext(),
- llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType())
+ return CompilerType(this, llvm::cast<clang::ElaboratedType>(qual_type)
+ ->getNamedType()
+ .getAsOpaquePtr())
.GetTypeClass();
case clang::Type::Attributed:
@@ -4452,20 +4368,20 @@ ClangASTContext::GetTypeClass(lldb::opaque_compiler_type_t type) {
break;
case clang::Type::TypeOfExpr:
- return CompilerType(getASTContext(),
- llvm::cast<clang::TypeOfExprType>(qual_type)
- ->getUnderlyingExpr()
- ->getType())
+ return CompilerType(this, llvm::cast<clang::TypeOfExprType>(qual_type)
+ ->getUnderlyingExpr()
+ ->getType()
+ .getAsOpaquePtr())
.GetTypeClass();
case clang::Type::TypeOf:
- return CompilerType(
- getASTContext(),
- llvm::cast<clang::TypeOfType>(qual_type)->getUnderlyingType())
+ return CompilerType(this, llvm::cast<clang::TypeOfType>(qual_type)
+ ->getUnderlyingType()
+ .getAsOpaquePtr())
.GetTypeClass();
case clang::Type::Decltype:
- return CompilerType(
- getASTContext(),
- llvm::cast<clang::TypeOfType>(qual_type)->getUnderlyingType())
+ return CompilerType(this, llvm::cast<clang::TypeOfType>(qual_type)
+ ->getUnderlyingType()
+ .getAsOpaquePtr())
.GetTypeClass();
case clang::Type::TemplateSpecialization:
break;
@@ -4513,8 +4429,8 @@ ClangASTContext::GetArrayElementType(lldb::opaque_compiler_type_t type,
if (!array_eletype)
return CompilerType();
- CompilerType element_type(getASTContext(),
- array_eletype->getCanonicalTypeUnqualified());
+ CompilerType element_type(
+ this, array_eletype->getCanonicalTypeUnqualified().getAsOpaquePtr());
// TODO: the real stride will be >= this value.. find the real one!
if (stride)
@@ -4533,14 +4449,18 @@ CompilerType ClangASTContext::GetArrayType(lldb::opaque_compiler_type_t type,
if (clang::ASTContext *ast_ctx = getASTContext()) {
if (size != 0)
return CompilerType(
- ast_ctx, ast_ctx->getConstantArrayType(
- qual_type, llvm::APInt(64, size),
- clang::ArrayType::ArraySizeModifier::Normal, 0));
+ this, ast_ctx
+ ->getConstantArrayType(
+ qual_type, llvm::APInt(64, size), nullptr,
+ clang::ArrayType::ArraySizeModifier::Normal, 0)
+ .getAsOpaquePtr());
else
return CompilerType(
- ast_ctx,
- ast_ctx->getIncompleteArrayType(
- qual_type, clang::ArrayType::ArraySizeModifier::Normal, 0));
+ this,
+ ast_ctx
+ ->getIncompleteArrayType(
+ qual_type, clang::ArrayType::ArraySizeModifier::Normal, 0)
+ .getAsOpaquePtr());
}
}
@@ -4550,7 +4470,7 @@ CompilerType ClangASTContext::GetArrayType(lldb::opaque_compiler_type_t type,
CompilerType
ClangASTContext::GetCanonicalType(lldb::opaque_compiler_type_t type) {
if (type)
- return CompilerType(getASTContext(), GetCanonicalQualType(type));
+ return CompilerType(this, GetCanonicalQualType(type).getAsOpaquePtr());
return CompilerType();
}
@@ -4571,8 +4491,8 @@ CompilerType
ClangASTContext::GetFullyUnqualifiedType(lldb::opaque_compiler_type_t type) {
if (type)
return CompilerType(
- getASTContext(),
- GetFullyUnqualifiedType_Impl(getASTContext(), GetQualType(type)));
+ this,
+ GetFullyUnqualifiedType_Impl(getASTContext(), GetQualType(type)).getAsOpaquePtr());
return CompilerType();
}
@@ -4595,7 +4515,7 @@ CompilerType ClangASTContext::GetFunctionArgumentTypeAtIndex(
if (func) {
const uint32_t num_args = func->getNumParams();
if (idx < num_args)
- return CompilerType(getASTContext(), func->getParamType(idx));
+ return CompilerType(this, func->getParamType(idx).getAsOpaquePtr());
}
}
return CompilerType();
@@ -4608,7 +4528,7 @@ ClangASTContext::GetFunctionReturnType(lldb::opaque_compiler_type_t type) {
const clang::FunctionProtoType *func =
llvm::dyn_cast<clang::FunctionProtoType>(qual_type.getTypePtr());
if (func)
- return CompilerType(getASTContext(), func->getReturnType());
+ return CompilerType(this, func->getReturnType().getAsOpaquePtr());
}
return CompilerType();
}
@@ -4667,27 +4587,28 @@ ClangASTContext::GetNumMemberFunctions(lldb::opaque_compiler_type_t type) {
break;
case clang::Type::Typedef:
- return CompilerType(getASTContext(),
- llvm::cast<clang::TypedefType>(qual_type)
- ->getDecl()
- ->getUnderlyingType())
+ return CompilerType(this, llvm::cast<clang::TypedefType>(qual_type)
+ ->getDecl()
+ ->getUnderlyingType()
+ .getAsOpaquePtr())
.GetNumMemberFunctions();
case clang::Type::Auto:
- return CompilerType(
- getASTContext(),
- llvm::cast<clang::AutoType>(qual_type)->getDeducedType())
+ return CompilerType(this, llvm::cast<clang::AutoType>(qual_type)
+ ->getDeducedType()
+ .getAsOpaquePtr())
.GetNumMemberFunctions();
case clang::Type::Elaborated:
- return CompilerType(
- getASTContext(),
- llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType())
+ return CompilerType(this, llvm::cast<clang::ElaboratedType>(qual_type)
+ ->getNamedType()
+ .getAsOpaquePtr())
.GetNumMemberFunctions();
case clang::Type::Paren:
- return CompilerType(getASTContext(),
- llvm::cast<clang::ParenType>(qual_type)->desugar())
+ return CompilerType(this, llvm::cast<clang::ParenType>(qual_type)
+ ->desugar()
+ .getAsOpaquePtr())
.GetNumMemberFunctions();
default:
@@ -4843,8 +4764,8 @@ ClangASTContext::GetMemberFunctionAtIndex(lldb::opaque_compiler_type_t type,
CompilerType
ClangASTContext::GetNonReferenceType(lldb::opaque_compiler_type_t type) {
if (type)
- return CompilerType(getASTContext(),
- GetQualType(type).getNonReferenceType());
+ return CompilerType(
+ this, GetQualType(type).getNonReferenceType().getAsOpaquePtr());
return CompilerType();
}
@@ -4874,7 +4795,7 @@ CompilerType ClangASTContext::CreateTypedefType(
decl_ctx->addDecl(decl);
// Get a uniqued clang::QualType for the typedef decl type
- return CompilerType(clang_ast, clang_ast->getTypedefType(decl));
+ return CompilerType(ast, clang_ast->getTypedefType(decl).getAsOpaquePtr());
}
return CompilerType();
}
@@ -4883,8 +4804,8 @@ CompilerType
ClangASTContext::GetPointeeType(lldb::opaque_compiler_type_t type) {
if (type) {
clang::QualType qual_type(GetQualType(type));
- return CompilerType(getASTContext(),
- qual_type.getTypePtr()->getPointeeType());
+ return CompilerType(
+ this, qual_type.getTypePtr()->getPointeeType().getAsOpaquePtr());
}
return CompilerType();
}
@@ -4898,12 +4819,13 @@ ClangASTContext::GetPointerType(lldb::opaque_compiler_type_t type) {
switch (type_class) {
case clang::Type::ObjCObject:
case clang::Type::ObjCInterface:
- return CompilerType(getASTContext(),
- getASTContext()->getObjCObjectPointerType(qual_type));
+ return CompilerType(this, getASTContext()
+ ->getObjCObjectPointerType(qual_type)
+ .getAsOpaquePtr());
default:
- return CompilerType(getASTContext(),
- getASTContext()->getPointerType(qual_type));
+ return CompilerType(
+ this, getASTContext()->getPointerType(qual_type).getAsOpaquePtr());
}
}
return CompilerType();
@@ -5005,8 +4927,8 @@ ClangASTContext::GetTypedefedType(lldb::opaque_compiler_type_t type) {
const clang::TypedefType *typedef_type =
llvm::dyn_cast<clang::TypedefType>(GetQualType(type));
if (typedef_type)
- return CompilerType(getASTContext(),
- typedef_type->getDecl()->getUnderlyingType());
+ return CompilerType(
+ this, typedef_type->getDecl()->getUnderlyingType().getAsOpaquePtr());
}
return CompilerType();
}
@@ -5018,6 +4940,22 @@ CompilerType ClangASTContext::GetBasicTypeFromAST(lldb::BasicType basic_type) {
}
// Exploring the type
+const llvm::fltSemantics &
+ClangASTContext::GetFloatTypeSemantics(size_t byte_size) {
+ if (auto *ast = getASTContext()) {
+ const size_t bit_size = byte_size * 8;
+ if (bit_size == ast->getTypeSize(ast->FloatTy))
+ return ast->getFloatTypeSemantics(ast->FloatTy);
+ else if (bit_size == ast->getTypeSize(ast->DoubleTy))
+ return ast->getFloatTypeSemantics(ast->DoubleTy);
+ else if (bit_size == ast->getTypeSize(ast->LongDoubleTy))
+ return ast->getFloatTypeSemantics(ast->LongDoubleTy);
+ else if (bit_size == ast->getTypeSize(ast->HalfTy))
+ return ast->getFloatTypeSemantics(ast->HalfTy);
+ }
+ return llvm::APFloatBase::Bogus();
+}
+
Optional<uint64_t>
ClangASTContext::GetBitSize(lldb::opaque_compiler_type_t type,
ExecutionContextScope *exe_scope) {
@@ -5041,7 +4979,7 @@ ClangASTContext::GetBitSize(lldb::opaque_compiler_type_t type,
if (objc_runtime) {
uint64_t bit_size = 0;
if (objc_runtime->GetTypeBitSize(
- CompilerType(getASTContext(), qual_type), bit_size))
+ CompilerType(this, qual_type.getAsOpaquePtr()), bit_size))
return bit_size;
}
} else {
@@ -5084,10 +5022,12 @@ ClangASTContext::GetBitSize(lldb::opaque_compiler_type_t type,
return None;
}
-size_t ClangASTContext::GetTypeBitAlign(lldb::opaque_compiler_type_t type) {
+llvm::Optional<size_t>
+ClangASTContext::GetTypeBitAlign(lldb::opaque_compiler_type_t type,
+ ExecutionContextScope *exe_scope) {
if (GetCompleteType(type))
return getASTContext()->getTypeAlign(GetQualType(type));
- return 0;
+ return {};
}
lldb::Encoding ClangASTContext::GetEncoding(lldb::opaque_compiler_type_t type,
@@ -5255,6 +5195,20 @@ lldb::Encoding ClangASTContext::GetEncoding(lldb::opaque_compiler_type_t type,
case clang::BuiltinType::OCLIntelSubgroupAVCImeSingleRefStreamin:
case clang::BuiltinType::OCLIntelSubgroupAVCImeDualRefStreamin:
break;
+
+ case clang::BuiltinType::SveBool:
+ case clang::BuiltinType::SveInt8:
+ case clang::BuiltinType::SveInt16:
+ case clang::BuiltinType::SveInt32:
+ case clang::BuiltinType::SveInt64:
+ case clang::BuiltinType::SveUint8:
+ case clang::BuiltinType::SveUint16:
+ case clang::BuiltinType::SveUint32:
+ case clang::BuiltinType::SveUint64:
+ case clang::BuiltinType::SveFloat16:
+ case clang::BuiltinType::SveFloat32:
+ case clang::BuiltinType::SveFloat64:
+ break;
}
break;
// All pointer types are represented as unsigned integer encodings. We may
@@ -5274,8 +5228,9 @@ lldb::Encoding ClangASTContext::GetEncoding(lldb::opaque_compiler_type_t type,
const clang::ComplexType *complex_type =
qual_type->getAsComplexIntegerType();
if (complex_type)
- encoding = CompilerType(getASTContext(), complex_type->getElementType())
- .GetEncoding(count);
+ encoding =
+ CompilerType(this, complex_type->getElementType().getAsOpaquePtr())
+ .GetEncoding(count);
else
encoding = lldb::eEncodingSint;
}
@@ -5290,43 +5245,44 @@ lldb::Encoding ClangASTContext::GetEncoding(lldb::opaque_compiler_type_t type,
case clang::Type::Enum:
return lldb::eEncodingSint;
case clang::Type::Typedef:
- return CompilerType(getASTContext(),
- llvm::cast<clang::TypedefType>(qual_type)
- ->getDecl()
- ->getUnderlyingType())
+ return CompilerType(this, llvm::cast<clang::TypedefType>(qual_type)
+ ->getDecl()
+ ->getUnderlyingType()
+ .getAsOpaquePtr())
.GetEncoding(count);
case clang::Type::Auto:
- return CompilerType(
- getASTContext(),
- llvm::cast<clang::AutoType>(qual_type)->getDeducedType())
+ return CompilerType(this, llvm::cast<clang::AutoType>(qual_type)
+ ->getDeducedType()
+ .getAsOpaquePtr())
.GetEncoding(count);
case clang::Type::Elaborated:
- return CompilerType(
- getASTContext(),
- llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType())
+ return CompilerType(this, llvm::cast<clang::ElaboratedType>(qual_type)
+ ->getNamedType()
+ .getAsOpaquePtr())
.GetEncoding(count);
case clang::Type::Paren:
- return CompilerType(getASTContext(),
- llvm::cast<clang::ParenType>(qual_type)->desugar())
+ return CompilerType(this, llvm::cast<clang::ParenType>(qual_type)
+ ->desugar()
+ .getAsOpaquePtr())
.GetEncoding(count);
case clang::Type::TypeOfExpr:
- return CompilerType(getASTContext(),
- llvm::cast<clang::TypeOfExprType>(qual_type)
- ->getUnderlyingExpr()
- ->getType())
+ return CompilerType(this, llvm::cast<clang::TypeOfExprType>(qual_type)
+ ->getUnderlyingExpr()
+ ->getType()
+ .getAsOpaquePtr())
.GetEncoding(count);
case clang::Type::TypeOf:
- return CompilerType(
- getASTContext(),
- llvm::cast<clang::TypeOfType>(qual_type)->getUnderlyingType())
+ return CompilerType(this, llvm::cast<clang::TypeOfType>(qual_type)
+ ->getUnderlyingType()
+ .getAsOpaquePtr())
.GetEncoding(count);
case clang::Type::Decltype:
- return CompilerType(
- getASTContext(),
- llvm::cast<clang::DecltypeType>(qual_type)->getUnderlyingType())
+ return CompilerType(this, llvm::cast<clang::DecltypeType>(qual_type)
+ ->getUnderlyingType()
+ .getAsOpaquePtr())
.GetEncoding(count);
case clang::Type::DependentSizedArray:
case clang::Type::DependentSizedExtVector:
@@ -5463,39 +5419,41 @@ lldb::Format ClangASTContext::GetFormat(lldb::opaque_compiler_type_t type) {
case clang::Type::Enum:
return lldb::eFormatEnum;
case clang::Type::Typedef:
- return CompilerType(getASTContext(),
- llvm::cast<clang::TypedefType>(qual_type)
- ->getDecl()
- ->getUnderlyingType())
+ return CompilerType(this, llvm::cast<clang::TypedefType>(qual_type)
+ ->getDecl()
+ ->getUnderlyingType()
+ .getAsOpaquePtr())
.GetFormat();
case clang::Type::Auto:
- return CompilerType(getASTContext(),
- llvm::cast<clang::AutoType>(qual_type)->desugar())
+ return CompilerType(this, llvm::cast<clang::AutoType>(qual_type)
+ ->desugar()
+ .getAsOpaquePtr())
.GetFormat();
case clang::Type::Paren:
- return CompilerType(getASTContext(),
- llvm::cast<clang::ParenType>(qual_type)->desugar())
+ return CompilerType(this, llvm::cast<clang::ParenType>(qual_type)
+ ->desugar()
+ .getAsOpaquePtr())
.GetFormat();
case clang::Type::Elaborated:
- return CompilerType(
- getASTContext(),
- llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType())
+ return CompilerType(this, llvm::cast<clang::ElaboratedType>(qual_type)
+ ->getNamedType()
+ .getAsOpaquePtr())
.GetFormat();
case clang::Type::TypeOfExpr:
- return CompilerType(getASTContext(),
- llvm::cast<clang::TypeOfExprType>(qual_type)
- ->getUnderlyingExpr()
- ->getType())
+ return CompilerType(this, llvm::cast<clang::TypeOfExprType>(qual_type)
+ ->getUnderlyingExpr()
+ ->getType()
+ .getAsOpaquePtr())
.GetFormat();
case clang::Type::TypeOf:
- return CompilerType(
- getASTContext(),
- llvm::cast<clang::TypeOfType>(qual_type)->getUnderlyingType())
+ return CompilerType(this, llvm::cast<clang::TypeOfType>(qual_type)
+ ->getUnderlyingType()
+ .getAsOpaquePtr())
.GetFormat();
case clang::Type::Decltype:
- return CompilerType(
- getASTContext(),
- llvm::cast<clang::DecltypeType>(qual_type)->getUnderlyingType())
+ return CompilerType(this, llvm::cast<clang::DecltypeType>(qual_type)
+ ->getUnderlyingType()
+ .getAsOpaquePtr())
.GetFormat();
case clang::Type::DependentSizedArray:
case clang::Type::DependentSizedExtVector:
@@ -5657,7 +5615,7 @@ uint32_t ClangASTContext::GetNumChildren(lldb::opaque_compiler_type_t type,
llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr());
clang::QualType pointee_type = pointer_type->getPointeeType();
uint32_t num_pointee_children =
- CompilerType(getASTContext(), pointee_type)
+ CompilerType(this, pointee_type.getAsOpaquePtr())
.GetNumChildren(omit_empty_base_classes, exe_ctx);
// If this type points to a simple type, then it has 1 child
if (num_pointee_children == 0)
@@ -5691,7 +5649,7 @@ uint32_t ClangASTContext::GetNumChildren(lldb::opaque_compiler_type_t type,
llvm::cast<clang::PointerType>(qual_type.getTypePtr());
clang::QualType pointee_type(pointer_type->getPointeeType());
uint32_t num_pointee_children =
- CompilerType(getASTContext(), pointee_type)
+ CompilerType(this, pointee_type.getAsOpaquePtr())
.GetNumChildren(omit_empty_base_classes, exe_ctx);
if (num_pointee_children == 0) {
// We have a pointer to a pointee type that claims it has no children. We
@@ -5707,7 +5665,7 @@ uint32_t ClangASTContext::GetNumChildren(lldb::opaque_compiler_type_t type,
llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
clang::QualType pointee_type = reference_type->getPointeeType();
uint32_t num_pointee_children =
- CompilerType(getASTContext(), pointee_type)
+ CompilerType(this, pointee_type.getAsOpaquePtr())
.GetNumChildren(omit_empty_base_classes, exe_ctx);
// If this type points to a simple type, then it has 1 child
if (num_pointee_children == 0)
@@ -5717,32 +5675,33 @@ uint32_t ClangASTContext::GetNumChildren(lldb::opaque_compiler_type_t type,
} break;
case clang::Type::Typedef:
- num_children =
- CompilerType(getASTContext(), llvm::cast<clang::TypedefType>(qual_type)
+ num_children = CompilerType(this, llvm::cast<clang::TypedefType>(qual_type)
->getDecl()
- ->getUnderlyingType())
- .GetNumChildren(omit_empty_base_classes, exe_ctx);
+ ->getUnderlyingType()
+ .getAsOpaquePtr())
+ .GetNumChildren(omit_empty_base_classes, exe_ctx);
break;
case clang::Type::Auto:
- num_children =
- CompilerType(getASTContext(),
- llvm::cast<clang::AutoType>(qual_type)->getDeducedType())
- .GetNumChildren(omit_empty_base_classes, exe_ctx);
+ num_children = CompilerType(this, llvm::cast<clang::AutoType>(qual_type)
+ ->getDeducedType()
+ .getAsOpaquePtr())
+ .GetNumChildren(omit_empty_base_classes, exe_ctx);
break;
case clang::Type::Elaborated:
num_children =
- CompilerType(
- getASTContext(),
- llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType())
+ CompilerType(this, llvm::cast<clang::ElaboratedType>(qual_type)
+ ->getNamedType()
+ .getAsOpaquePtr())
.GetNumChildren(omit_empty_base_classes, exe_ctx);
break;
case clang::Type::Paren:
num_children =
- CompilerType(getASTContext(),
- llvm::cast<clang::ParenType>(qual_type)->desugar())
+ CompilerType(
+ this,
+ llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr())
.GetNumChildren(omit_empty_base_classes, exe_ctx);
break;
default:
@@ -5883,31 +5842,33 @@ uint32_t ClangASTContext::GetNumFields(lldb::opaque_compiler_type_t type) {
break;
case clang::Type::Typedef:
- count =
- CompilerType(getASTContext(), llvm::cast<clang::TypedefType>(qual_type)
- ->getDecl()
- ->getUnderlyingType())
- .GetNumFields();
+ count = CompilerType(this, llvm::cast<clang::TypedefType>(qual_type)
+ ->getDecl()
+ ->getUnderlyingType()
+ .getAsOpaquePtr())
+ .GetNumFields();
break;
case clang::Type::Auto:
- count =
- CompilerType(getASTContext(),
- llvm::cast<clang::AutoType>(qual_type)->getDeducedType())
- .GetNumFields();
+ count = CompilerType(this, llvm::cast<clang::AutoType>(qual_type)
+ ->getDeducedType()
+ .getAsOpaquePtr())
+ .GetNumFields();
break;
case clang::Type::Elaborated:
- count = CompilerType(
- getASTContext(),
- llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType())
+ count = CompilerType(this, llvm::cast<clang::ElaboratedType>(qual_type)
+ ->getNamedType()
+ .getAsOpaquePtr())
.GetNumFields();
break;
case clang::Type::Paren:
- count = CompilerType(getASTContext(),
- llvm::cast<clang::ParenType>(qual_type)->desugar())
- .GetNumFields();
+ count =
+ CompilerType(
+ this,
+ llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr())
+ .GetNumFields();
break;
case clang::Type::ObjCObjectPointer: {
@@ -6053,7 +6014,7 @@ CompilerType ClangASTContext::GetFieldAtIndex(lldb::opaque_compiler_type_t type,
if (is_bitfield_ptr)
*is_bitfield_ptr = is_bitfield;
- return CompilerType(getASTContext(), field->getType());
+ return CompilerType(this, field->getType().getAsOpaquePtr());
}
}
}
@@ -6097,30 +6058,31 @@ CompilerType ClangASTContext::GetFieldAtIndex(lldb::opaque_compiler_type_t type,
break;
case clang::Type::Typedef:
- return CompilerType(getASTContext(),
- llvm::cast<clang::TypedefType>(qual_type)
- ->getDecl()
- ->getUnderlyingType())
+ return CompilerType(this, llvm::cast<clang::TypedefType>(qual_type)
+ ->getDecl()
+ ->getUnderlyingType()
+ .getAsOpaquePtr())
.GetFieldAtIndex(idx, name, bit_offset_ptr, bitfield_bit_size_ptr,
is_bitfield_ptr);
case clang::Type::Auto:
- return CompilerType(
- getASTContext(),
- llvm::cast<clang::AutoType>(qual_type)->getDeducedType())
+ return CompilerType(this, llvm::cast<clang::AutoType>(qual_type)
+ ->getDeducedType()
+ .getAsOpaquePtr())
.GetFieldAtIndex(idx, name, bit_offset_ptr, bitfield_bit_size_ptr,
is_bitfield_ptr);
case clang::Type::Elaborated:
- return CompilerType(
- getASTContext(),
- llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType())
+ return CompilerType(this, llvm::cast<clang::ElaboratedType>(qual_type)
+ ->getNamedType()
+ .getAsOpaquePtr())
.GetFieldAtIndex(idx, name, bit_offset_ptr, bitfield_bit_size_ptr,
is_bitfield_ptr);
case clang::Type::Paren:
- return CompilerType(getASTContext(),
- llvm::cast<clang::ParenType>(qual_type)->desugar())
+ return CompilerType(this, llvm::cast<clang::ParenType>(qual_type)
+ ->desugar()
+ .getAsOpaquePtr())
.GetFieldAtIndex(idx, name, bit_offset_ptr, bitfield_bit_size_ptr,
is_bitfield_ptr);
@@ -6311,9 +6273,9 @@ CompilerType ClangASTContext::GetDirectBaseClassAtIndex(
if (superclass_interface_decl) {
if (bit_offset_ptr)
*bit_offset_ptr = 0;
- return CompilerType(getASTContext(),
+ return CompilerType(this,
getASTContext()->getObjCInterfaceType(
- superclass_interface_decl));
+ superclass_interface_decl).getAsOpaquePtr());
}
}
}
@@ -6333,9 +6295,10 @@ CompilerType ClangASTContext::GetDirectBaseClassAtIndex(
if (superclass_interface_decl) {
if (bit_offset_ptr)
*bit_offset_ptr = 0;
- return CompilerType(getASTContext(),
- getASTContext()->getObjCInterfaceType(
- superclass_interface_decl));
+ return CompilerType(
+ this, getASTContext()
+ ->getObjCInterfaceType(superclass_interface_decl)
+ .getAsOpaquePtr());
}
}
}
@@ -6638,8 +6601,8 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex(
child_byte_size =
getASTContext()->getTypeSize(getASTContext()->ObjCBuiltinClassTy) /
CHAR_BIT;
- return CompilerType(getASTContext(),
- getASTContext()->ObjCBuiltinClassTy);
+ return CompilerType(
+ this, getASTContext()->ObjCBuiltinClassTy.getAsOpaquePtr());
default:
break;
@@ -6702,8 +6665,8 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex(
// Base classes should be a multiple of 8 bits in size
child_byte_offset = bit_offset / 8;
- CompilerType base_class_clang_type(getASTContext(),
- base_class->getType());
+ CompilerType base_class_clang_type(
+ this, base_class->getType().getAsOpaquePtr());
child_name = base_class_clang_type.GetTypeName().AsCString("");
Optional<uint64_t> size =
base_class_clang_type.GetBitSize(get_exe_scope());
@@ -6735,7 +6698,8 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex(
// Figure out the type byte size (field_type_info.first) and
// alignment (field_type_info.second) from the AST context.
- CompilerType field_clang_type(getASTContext(), field->getType());
+ CompilerType field_clang_type(this,
+ field->getType().getAsOpaquePtr());
assert(field_idx < record_layout.getFieldCount());
Optional<uint64_t> size =
field_clang_type.GetByteSize(get_exe_scope());
@@ -6783,8 +6747,9 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex(
if (superclass_interface_decl) {
if (omit_empty_base_classes) {
CompilerType base_class_clang_type(
- getASTContext(), getASTContext()->getObjCInterfaceType(
- superclass_interface_decl));
+ this, getASTContext()
+ ->getObjCInterfaceType(superclass_interface_decl)
+ .getAsOpaquePtr());
if (base_class_clang_type.GetNumChildren(omit_empty_base_classes,
exe_ctx) > 0) {
if (idx == 0) {
@@ -6802,7 +6767,7 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex(
child_byte_offset = 0;
child_is_base_class = true;
- return CompilerType(getASTContext(), ivar_qual_type);
+ return CompilerType(this, ivar_qual_type.getAsOpaquePtr());
}
++child_idx;
@@ -6846,8 +6811,8 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex(
ObjCLanguageRuntime *objc_runtime =
ObjCLanguageRuntime::Get(*process);
if (objc_runtime != nullptr) {
- CompilerType parent_ast_type(getASTContext(),
- parent_qual_type);
+ CompilerType parent_ast_type(
+ this, parent_qual_type.getAsOpaquePtr());
child_byte_offset = objc_runtime->GetByteOffsetForIvar(
parent_ast_type, ivar_decl->getNameAsString().c_str());
}
@@ -6878,7 +6843,7 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex(
child_bitfield_bit_offset = bit_offset % 8;
}
- return CompilerType(getASTContext(), ivar_qual_type);
+ return CompilerType(this, ivar_qual_type.getAsOpaquePtr());
}
++child_idx;
}
@@ -6929,7 +6894,8 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex(
const clang::VectorType *array =
llvm::cast<clang::VectorType>(parent_qual_type.getTypePtr());
if (array) {
- CompilerType element_type(getASTContext(), array->getElementType());
+ CompilerType element_type(this,
+ array->getElementType().getAsOpaquePtr());
if (element_type.GetCompleteType()) {
char element_name[64];
::snprintf(element_name, sizeof(element_name), "[%" PRIu64 "]",
@@ -6951,7 +6917,8 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex(
if (ignore_array_bounds || idx_is_valid) {
const clang::ArrayType *array = GetQualType(type)->getAsArrayTypeUnsafe();
if (array) {
- CompilerType element_type(getASTContext(), array->getElementType());
+ CompilerType element_type(this,
+ array->getElementType().getAsOpaquePtr());
if (element_type.GetCompleteType()) {
child_name = llvm::formatv("[{0}]", idx);
if (Optional<uint64_t> size =
@@ -7009,8 +6976,8 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex(
if (idx_is_valid) {
const clang::ReferenceType *reference_type =
llvm::cast<clang::ReferenceType>(parent_qual_type.getTypePtr());
- CompilerType pointee_clang_type(getASTContext(),
- reference_type->getPointeeType());
+ CompilerType pointee_clang_type(
+ this, reference_type->getPointeeType().getAsOpaquePtr());
if (transparent_pointers && pointee_clang_type.IsAggregateType()) {
child_is_deref_of_parent = false;
bool tmp_child_is_deref_of_parent = false;
@@ -7043,9 +7010,10 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex(
case clang::Type::Typedef: {
CompilerType typedefed_clang_type(
- getASTContext(), llvm::cast<clang::TypedefType>(parent_qual_type)
- ->getDecl()
- ->getUnderlyingType());
+ this, llvm::cast<clang::TypedefType>(parent_qual_type)
+ ->getDecl()
+ ->getUnderlyingType()
+ .getAsOpaquePtr());
return typedefed_clang_type.GetChildCompilerTypeAtIndex(
exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
@@ -7055,8 +7023,9 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex(
case clang::Type::Auto: {
CompilerType elaborated_clang_type(
- getASTContext(),
- llvm::cast<clang::AutoType>(parent_qual_type)->getDeducedType());
+ this, llvm::cast<clang::AutoType>(parent_qual_type)
+ ->getDeducedType()
+ .getAsOpaquePtr());
return elaborated_clang_type.GetChildCompilerTypeAtIndex(
exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
@@ -7066,8 +7035,9 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex(
case clang::Type::Elaborated: {
CompilerType elaborated_clang_type(
- getASTContext(),
- llvm::cast<clang::ElaboratedType>(parent_qual_type)->getNamedType());
+ this, llvm::cast<clang::ElaboratedType>(parent_qual_type)
+ ->getNamedType()
+ .getAsOpaquePtr());
return elaborated_clang_type.GetChildCompilerTypeAtIndex(
exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
@@ -7076,9 +7046,10 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex(
}
case clang::Type::Paren: {
- CompilerType paren_clang_type(
- getASTContext(),
- llvm::cast<clang::ParenType>(parent_qual_type)->desugar());
+ CompilerType paren_clang_type(this,
+ llvm::cast<clang::ParenType>(parent_qual_type)
+ ->desugar()
+ .getAsOpaquePtr());
return paren_clang_type.GetChildCompilerTypeAtIndex(
exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
ignore_array_bounds, child_name, child_byte_size, child_byte_offset,
@@ -7207,7 +7178,7 @@ size_t ClangASTContext::GetIndexOfChildMemberWithName(
field != field_end; ++field, ++child_idx) {
llvm::StringRef field_name = field->getName();
if (field_name.empty()) {
- CompilerType field_type(getASTContext(), field->getType());
+ CompilerType field_type(this, field->getType().getAsOpaquePtr());
child_indexes.push_back(child_idx);
if (field_type.GetIndexOfChildMemberWithName(
name, omit_empty_base_classes, child_indexes))
@@ -7319,8 +7290,9 @@ size_t ClangASTContext::GetIndexOfChildMemberWithName(
child_indexes.push_back(0);
CompilerType superclass_clang_type(
- getASTContext(), getASTContext()->getObjCInterfaceType(
- superclass_interface_decl));
+ this, getASTContext()
+ ->getObjCInterfaceType(superclass_interface_decl)
+ .getAsOpaquePtr());
if (superclass_clang_type.GetIndexOfChildMemberWithName(
name, omit_empty_base_classes, child_indexes)) {
// We did find an ivar in a superclass so just return the
@@ -7339,9 +7311,9 @@ size_t ClangASTContext::GetIndexOfChildMemberWithName(
case clang::Type::ObjCObjectPointer: {
CompilerType objc_object_clang_type(
- getASTContext(),
- llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
- ->getPointeeType());
+ this, llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
+ ->getPointeeType()
+ .getAsOpaquePtr());
return objc_object_clang_type.GetIndexOfChildMemberWithName(
name, omit_empty_base_classes, child_indexes);
} break;
@@ -7391,7 +7363,7 @@ size_t ClangASTContext::GetIndexOfChildMemberWithName(
const clang::ReferenceType *reference_type =
llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
clang::QualType pointee_type(reference_type->getPointeeType());
- CompilerType pointee_clang_type(getASTContext(), pointee_type);
+ CompilerType pointee_clang_type(this, pointee_type.getAsOpaquePtr());
if (pointee_clang_type.IsAggregateType()) {
return pointee_clang_type.GetIndexOfChildMemberWithName(
@@ -7409,30 +7381,31 @@ size_t ClangASTContext::GetIndexOfChildMemberWithName(
} break;
case clang::Type::Typedef:
- return CompilerType(getASTContext(),
- llvm::cast<clang::TypedefType>(qual_type)
- ->getDecl()
- ->getUnderlyingType())
+ return CompilerType(this, llvm::cast<clang::TypedefType>(qual_type)
+ ->getDecl()
+ ->getUnderlyingType()
+ .getAsOpaquePtr())
.GetIndexOfChildMemberWithName(name, omit_empty_base_classes,
child_indexes);
case clang::Type::Auto:
- return CompilerType(
- getASTContext(),
- llvm::cast<clang::AutoType>(qual_type)->getDeducedType())
+ return CompilerType(this, llvm::cast<clang::AutoType>(qual_type)
+ ->getDeducedType()
+ .getAsOpaquePtr())
.GetIndexOfChildMemberWithName(name, omit_empty_base_classes,
child_indexes);
case clang::Type::Elaborated:
- return CompilerType(
- getASTContext(),
- llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType())
+ return CompilerType(this, llvm::cast<clang::ElaboratedType>(qual_type)
+ ->getNamedType()
+ .getAsOpaquePtr())
.GetIndexOfChildMemberWithName(name, omit_empty_base_classes,
child_indexes);
case clang::Type::Paren:
- return CompilerType(getASTContext(),
- llvm::cast<clang::ParenType>(qual_type)->desugar())
+ return CompilerType(this, llvm::cast<clang::ParenType>(qual_type)
+ ->desugar()
+ .getAsOpaquePtr())
.GetIndexOfChildMemberWithName(name, omit_empty_base_classes,
child_indexes);
@@ -7485,8 +7458,8 @@ ClangASTContext::GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
!ClangASTContext::RecordHasFields(base_class_decl))
continue;
- CompilerType base_class_clang_type(getASTContext(),
- base_class->getType());
+ CompilerType base_class_clang_type(
+ this, base_class->getType().getAsOpaquePtr());
std::string base_class_type_name(
base_class_clang_type.GetTypeName().AsCString(""));
if (base_class_type_name == name)
@@ -7550,9 +7523,9 @@ ClangASTContext::GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
case clang::Type::ObjCObjectPointer: {
CompilerType pointee_clang_type(
- getASTContext(),
- llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
- ->getPointeeType());
+ this, llvm::cast<clang::ObjCObjectPointerType>(qual_type.getTypePtr())
+ ->getPointeeType()
+ .getAsOpaquePtr());
return pointee_clang_type.GetIndexOfChildWithName(
name, omit_empty_base_classes);
} break;
@@ -7601,8 +7574,8 @@ ClangASTContext::GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
case clang::Type::RValueReference: {
const clang::ReferenceType *reference_type =
llvm::cast<clang::ReferenceType>(qual_type.getTypePtr());
- CompilerType pointee_type(getASTContext(),
- reference_type->getPointeeType());
+ CompilerType pointee_type(
+ this, reference_type->getPointeeType().getAsOpaquePtr());
if (pointee_type.IsAggregateType()) {
return pointee_type.GetIndexOfChildWithName(name,
@@ -7613,8 +7586,8 @@ ClangASTContext::GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
case clang::Type::Pointer: {
const clang::PointerType *pointer_type =
llvm::cast<clang::PointerType>(qual_type.getTypePtr());
- CompilerType pointee_type(getASTContext(),
- pointer_type->getPointeeType());
+ CompilerType pointee_type(
+ this, pointer_type->getPointeeType().getAsOpaquePtr());
if (pointee_type.IsAggregateType()) {
return pointee_type.GetIndexOfChildWithName(name,
@@ -7640,27 +7613,28 @@ ClangASTContext::GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
} break;
case clang::Type::Auto:
- return CompilerType(
- getASTContext(),
- llvm::cast<clang::AutoType>(qual_type)->getDeducedType())
+ return CompilerType(this, llvm::cast<clang::AutoType>(qual_type)
+ ->getDeducedType()
+ .getAsOpaquePtr())
.GetIndexOfChildWithName(name, omit_empty_base_classes);
case clang::Type::Elaborated:
- return CompilerType(
- getASTContext(),
- llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType())
+ return CompilerType(this, llvm::cast<clang::ElaboratedType>(qual_type)
+ ->getNamedType()
+ .getAsOpaquePtr())
.GetIndexOfChildWithName(name, omit_empty_base_classes);
case clang::Type::Paren:
- return CompilerType(getASTContext(),
- llvm::cast<clang::ParenType>(qual_type)->desugar())
+ return CompilerType(this, llvm::cast<clang::ParenType>(qual_type)
+ ->desugar()
+ .getAsOpaquePtr())
.GetIndexOfChildWithName(name, omit_empty_base_classes);
case clang::Type::Typedef:
- return CompilerType(getASTContext(),
- llvm::cast<clang::TypedefType>(qual_type)
- ->getDecl()
- ->getUnderlyingType())
+ return CompilerType(this, llvm::cast<clang::TypedefType>(qual_type)
+ ->getDecl()
+ ->getUnderlyingType()
+ .getAsOpaquePtr())
.GetIndexOfChildWithName(name, omit_empty_base_classes);
default:
@@ -7693,27 +7667,28 @@ ClangASTContext::GetNumTemplateArguments(lldb::opaque_compiler_type_t type) {
break;
case clang::Type::Typedef:
- return (CompilerType(getASTContext(),
- llvm::cast<clang::TypedefType>(qual_type)
- ->getDecl()
- ->getUnderlyingType()))
+ return CompilerType(this, llvm::cast<clang::TypedefType>(qual_type)
+ ->getDecl()
+ ->getUnderlyingType()
+ .getAsOpaquePtr())
.GetNumTemplateArguments();
case clang::Type::Auto:
- return (CompilerType(
- getASTContext(),
- llvm::cast<clang::AutoType>(qual_type)->getDeducedType()))
+ return CompilerType(this, llvm::cast<clang::AutoType>(qual_type)
+ ->getDeducedType()
+ .getAsOpaquePtr())
.GetNumTemplateArguments();
case clang::Type::Elaborated:
- return (CompilerType(
- getASTContext(),
- llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType()))
+ return CompilerType(this, llvm::cast<clang::ElaboratedType>(qual_type)
+ ->getNamedType()
+ .getAsOpaquePtr())
.GetNumTemplateArguments();
case clang::Type::Paren:
- return (CompilerType(getASTContext(),
- llvm::cast<clang::ParenType>(qual_type)->desugar()))
+ return CompilerType(this, llvm::cast<clang::ParenType>(qual_type)
+ ->desugar()
+ .getAsOpaquePtr())
.GetNumTemplateArguments();
default:
@@ -7821,7 +7796,7 @@ ClangASTContext::GetTypeTemplateArgument(lldb::opaque_compiler_type_t type,
if (template_arg.getKind() != clang::TemplateArgument::Type)
return CompilerType();
- return CompilerType(getASTContext(), template_arg.getAsType());
+ return CompilerType(this, template_arg.getAsType().getAsOpaquePtr());
}
Optional<CompilerType::IntegralTemplateArgument>
@@ -7837,8 +7812,9 @@ ClangASTContext::GetIntegralTemplateArgument(lldb::opaque_compiler_type_t type,
if (template_arg.getKind() != clang::TemplateArgument::Integral)
return llvm::None;
- return {{template_arg.getAsIntegral(),
- CompilerType(getASTContext(), template_arg.getIntegralType())}};
+ return {
+ {template_arg.getAsIntegral(),
+ CompilerType(this, template_arg.getIntegralType().getAsOpaquePtr())}};
}
CompilerType ClangASTContext::GetTypeForFormatters(void *type) {
@@ -8201,7 +8177,8 @@ clang::CXXMethodDecl *ClangASTContext::AddMethodToCXXRecordType(
getASTContext()->DeclarationNames.getCXXDestructorName(
getASTContext()->getCanonicalType(record_qual_type)),
clang::SourceLocation()),
- method_qual_type, nullptr, is_inline, is_artificial);
+ method_qual_type, nullptr, is_inline, is_artificial,
+ ConstexprSpecKind::CSK_unspecified);
cxx_method_decl = cxx_dtor_decl;
} else if (decl_name == cxx_record_decl->getDeclName()) {
cxx_ctor_decl = clang::CXXConstructorDecl::Create(
@@ -8272,8 +8249,8 @@ clang::CXXMethodDecl *ClangASTContext::AddMethodToCXXRecordType(
cxx_method_decl->addAttr(clang::UsedAttr::CreateImplicit(*getASTContext()));
if (mangled_name != nullptr) {
- cxx_method_decl->addAttr(
- clang::AsmLabelAttr::CreateImplicit(*getASTContext(), mangled_name));
+ cxx_method_decl->addAttr(clang::AsmLabelAttr::CreateImplicit(
+ *getASTContext(), mangled_name, /*literal=*/false));
}
// Populate the method decl with parameter decls
@@ -8327,24 +8304,6 @@ clang::CXXMethodDecl *ClangASTContext::AddMethodToCXXRecordType(
VerifyDecl(cxx_method_decl);
#endif
- // printf ("decl->isPolymorphic() = %i\n",
- // cxx_record_decl->isPolymorphic());
- // printf ("decl->isAggregate() = %i\n",
- // cxx_record_decl->isAggregate());
- // printf ("decl->isPOD() = %i\n",
- // cxx_record_decl->isPOD());
- // printf ("decl->isEmpty() = %i\n",
- // cxx_record_decl->isEmpty());
- // printf ("decl->isAbstract() = %i\n",
- // cxx_record_decl->isAbstract());
- // printf ("decl->hasTrivialConstructor() = %i\n",
- // cxx_record_decl->hasTrivialConstructor());
- // printf ("decl->hasTrivialCopyConstructor() = %i\n",
- // cxx_record_decl->hasTrivialCopyConstructor());
- // printf ("decl->hasTrivialCopyAssignment() = %i\n",
- // cxx_record_decl->hasTrivialCopyAssignment());
- // printf ("decl->hasTrivialDestructor() = %i\n",
- // cxx_record_decl->hasTrivialDestructor());
return cxx_method_decl;
}
@@ -8364,7 +8323,7 @@ ClangASTContext::CreateBaseClassSpecifier(lldb::opaque_compiler_type_t type,
if (!type)
return nullptr;
- return llvm::make_unique<clang::CXXBaseSpecifier>(
+ return std::make_unique<clang::CXXBaseSpecifier>(
clang::SourceRange(), is_virtual, base_of_class,
ClangASTContext::ConvertAccessTypeToAccessSpecifier(access),
getASTContext()->getTrivialTypeSourceInfo(GetQualType(type)),
@@ -8435,7 +8394,7 @@ bool ClangASTContext::AddObjCClassProperty(
property_clang_type_to_access = property_clang_type;
else if (ivar_decl)
property_clang_type_to_access =
- CompilerType(clang_ast, ivar_decl->getType());
+ CompilerType(ast, ivar_decl->getType().getAsOpaquePtr());
if (class_interface_decl && property_clang_type_to_access.IsValid()) {
clang::TypeSourceInfo *prop_type_source;
@@ -8733,74 +8692,6 @@ clang::ObjCMethodDecl *ClangASTContext::AddMethodToObjCObjectType(
return objc_method_decl;
}
-bool ClangASTContext::GetHasExternalStorage(const CompilerType &type) {
- if (ClangUtil::IsClangType(type))
- return false;
-
- clang::QualType qual_type(ClangUtil::GetCanonicalQualType(type));
-
- const clang::Type::TypeClass type_class = qual_type->getTypeClass();
- switch (type_class) {
- case clang::Type::Record: {
- clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
- if (cxx_record_decl)
- return cxx_record_decl->hasExternalLexicalStorage() ||
- cxx_record_decl->hasExternalVisibleStorage();
- } break;
-
- case clang::Type::Enum: {
- clang::EnumDecl *enum_decl =
- llvm::cast<clang::EnumType>(qual_type)->getDecl();
- if (enum_decl)
- return enum_decl->hasExternalLexicalStorage() ||
- enum_decl->hasExternalVisibleStorage();
- } break;
-
- case clang::Type::ObjCObject:
- case clang::Type::ObjCInterface: {
- const clang::ObjCObjectType *objc_class_type =
- llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
- assert(objc_class_type);
- if (objc_class_type) {
- clang::ObjCInterfaceDecl *class_interface_decl =
- objc_class_type->getInterface();
-
- if (class_interface_decl)
- return class_interface_decl->hasExternalLexicalStorage() ||
- class_interface_decl->hasExternalVisibleStorage();
- }
- } break;
-
- case clang::Type::Typedef:
- return GetHasExternalStorage(CompilerType(
- type.GetTypeSystem(), llvm::cast<clang::TypedefType>(qual_type)
- ->getDecl()
- ->getUnderlyingType()
- .getAsOpaquePtr()));
-
- case clang::Type::Auto:
- return GetHasExternalStorage(CompilerType(
- type.GetTypeSystem(), llvm::cast<clang::AutoType>(qual_type)
- ->getDeducedType()
- .getAsOpaquePtr()));
-
- case clang::Type::Elaborated:
- return GetHasExternalStorage(CompilerType(
- type.GetTypeSystem(), llvm::cast<clang::ElaboratedType>(qual_type)
- ->getNamedType()
- .getAsOpaquePtr()));
-
- case clang::Type::Paren:
- return GetHasExternalStorage(CompilerType(
- type.GetTypeSystem(),
- llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr()));
-
- default:
- break;
- }
- return false;
-}
-
bool ClangASTContext::SetHasExternalStorage(lldb::opaque_compiler_type_t type,
bool has_extern) {
if (!type)
@@ -9041,7 +8932,7 @@ ClangASTContext::GetEnumerationIntegerType(lldb::opaque_compiler_type_t type) {
if (enutype) {
clang::EnumDecl *enum_decl = enutype->getDecl();
if (enum_decl)
- return CompilerType(getASTContext(), enum_decl->getIntegerType());
+ return CompilerType(this, enum_decl->getIntegerType().getAsOpaquePtr());
}
}
return CompilerType();
@@ -9056,47 +8947,15 @@ ClangASTContext::CreateMemberPointerType(const CompilerType &type,
llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem());
if (!ast)
return CompilerType();
- return CompilerType(ast->getASTContext(),
- ast->getASTContext()->getMemberPointerType(
- ClangUtil::GetQualType(pointee_type),
- ClangUtil::GetQualType(type).getTypePtr()));
+ return CompilerType(ast, ast->getASTContext()
+ ->getMemberPointerType(
+ ClangUtil::GetQualType(pointee_type),
+ ClangUtil::GetQualType(type).getTypePtr())
+ .getAsOpaquePtr());
}
return CompilerType();
}
-size_t
-ClangASTContext::ConvertStringToFloatValue(lldb::opaque_compiler_type_t type,
- const char *s, uint8_t *dst,
- size_t dst_size) {
- if (type) {
- clang::QualType qual_type(GetCanonicalQualType(type));
- uint32_t count = 0;
- bool is_complex = false;
- if (IsFloatingPointType(type, count, is_complex)) {
- // TODO: handle complex and vector types
- if (count != 1)
- return false;
-
- llvm::StringRef s_sref(s);
- llvm::APFloat ap_float(getASTContext()->getFloatTypeSemantics(qual_type),
- s_sref);
-
- const uint64_t bit_size = getASTContext()->getTypeSize(qual_type);
- const uint64_t byte_size = bit_size / 8;
- if (dst_size >= byte_size) {
- Scalar scalar = ap_float.bitcastToAPInt().zextOrTrunc(
- llvm::NextPowerOf2(byte_size) * 8);
- lldb_private::Status get_data_error;
- if (scalar.GetAsMemoryData(dst, byte_size,
- lldb_private::endian::InlHostByteOrder(),
- get_data_error))
- return byte_size;
- }
- }
- }
- return 0;
-}
-
// Dumping types
#define DEPTH_INCREMENT 2
@@ -9115,6 +8974,39 @@ void ClangASTContext::Dump(Stream &s) {
tu->dump(s.AsRawOstream());
}
+void ClangASTContext::DumpFromSymbolFile(Stream &s,
+ llvm::StringRef symbol_name) {
+ SymbolFile *symfile = GetSymbolFile();
+
+ if (!symfile)
+ return;
+
+ lldb_private::TypeList type_list;
+ symfile->GetTypes(nullptr, eTypeClassAny, type_list);
+ size_t ntypes = type_list.GetSize();
+
+ for (size_t i = 0; i < ntypes; ++i) {
+ TypeSP type = type_list.GetTypeAtIndex(i);
+
+ if (!symbol_name.empty())
+ if (symbol_name.compare(type->GetName().GetStringRef()) != 0)
+ continue;
+
+ s << type->GetName().AsCString() << "\n";
+
+ if (clang::TagDecl *tag_decl =
+ GetAsTagDecl(type->GetFullCompilerType()))
+ tag_decl->dump(s.AsRawOstream());
+ else if (clang::TypedefNameDecl *typedef_decl =
+ GetAsTypedefDecl(type->GetFullCompilerType()))
+ typedef_decl->dump(s.AsRawOstream());
+ else {
+ GetCanonicalQualType(type->GetFullCompilerType().GetOpaqueQualType())
+ .dump(s.AsRawOstream());
+ }
+ }
+}
+
void ClangASTContext::DumpValue(
lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, Stream *s,
lldb::Format format, const DataExtractor &data,
@@ -9182,7 +9074,8 @@ void ClangASTContext::DumpValue(
getASTContext()->getTypeInfo(base_class_qual_type);
// Dump the value of the member
- CompilerType base_clang_type(getASTContext(), base_class_qual_type);
+ CompilerType base_clang_type(this,
+ base_class_qual_type.getAsOpaquePtr());
base_clang_type.DumpValue(
exe_ctx,
s, // Stream to dump to
@@ -9249,7 +9142,7 @@ void ClangASTContext::DumpValue(
s->Printf("%s = ", field->getNameAsString().c_str());
// Dump the value of the member
- CompilerType field_clang_type(getASTContext(), field_type);
+ CompilerType field_clang_type(this, field_type.getAsOpaquePtr());
field_clang_type.DumpValue(
exe_ctx,
s, // Stream to dump to
@@ -9329,7 +9222,7 @@ void ClangASTContext::DumpValue(
s->PutChar('"');
return;
} else {
- CompilerType element_clang_type(getASTContext(), element_qual_type);
+ CompilerType element_clang_type(this, element_qual_type.getAsOpaquePtr());
lldb::Format element_format = element_clang_type.GetFormat();
for (element_idx = 0; element_idx < element_count; ++element_idx) {
@@ -9380,7 +9273,7 @@ void ClangASTContext::DumpValue(
->getDecl()
->getUnderlyingType();
- CompilerType typedef_clang_type(getASTContext(), typedef_qual_type);
+ CompilerType typedef_clang_type(this, typedef_qual_type.getAsOpaquePtr());
lldb::Format typedef_format = typedef_clang_type.GetFormat();
clang::TypeInfo typedef_type_info =
getASTContext()->getTypeInfo(typedef_qual_type);
@@ -9405,7 +9298,8 @@ void ClangASTContext::DumpValue(
case clang::Type::Auto: {
clang::QualType elaborated_qual_type =
llvm::cast<clang::AutoType>(qual_type)->getDeducedType();
- CompilerType elaborated_clang_type(getASTContext(), elaborated_qual_type);
+ CompilerType elaborated_clang_type(this,
+ elaborated_qual_type.getAsOpaquePtr());
lldb::Format elaborated_format = elaborated_clang_type.GetFormat();
clang::TypeInfo elaborated_type_info =
getASTContext()->getTypeInfo(elaborated_qual_type);
@@ -9430,7 +9324,8 @@ void ClangASTContext::DumpValue(
case clang::Type::Elaborated: {
clang::QualType elaborated_qual_type =
llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType();
- CompilerType elaborated_clang_type(getASTContext(), elaborated_qual_type);
+ CompilerType elaborated_clang_type(this,
+ elaborated_qual_type.getAsOpaquePtr());
lldb::Format elaborated_format = elaborated_clang_type.GetFormat();
clang::TypeInfo elaborated_type_info =
getASTContext()->getTypeInfo(elaborated_qual_type);
@@ -9455,7 +9350,7 @@ void ClangASTContext::DumpValue(
case clang::Type::Paren: {
clang::QualType desugar_qual_type =
llvm::cast<clang::ParenType>(qual_type)->desugar();
- CompilerType desugar_clang_type(getASTContext(), desugar_qual_type);
+ CompilerType desugar_clang_type(this, desugar_qual_type.getAsOpaquePtr());
lldb::Format desugar_format = desugar_clang_type.GetFormat();
clang::TypeInfo desugar_type_info =
@@ -9490,6 +9385,86 @@ void ClangASTContext::DumpValue(
}
}
+static bool DumpEnumValue(const clang::QualType &qual_type, Stream *s,
+ const DataExtractor &data, lldb::offset_t byte_offset,
+ size_t byte_size, uint32_t bitfield_bit_offset,
+ uint32_t bitfield_bit_size) {
+ const clang::EnumType *enutype =
+ llvm::cast<clang::EnumType>(qual_type.getTypePtr());
+ const clang::EnumDecl *enum_decl = enutype->getDecl();
+ assert(enum_decl);
+ lldb::offset_t offset = byte_offset;
+ const uint64_t enum_svalue = data.GetMaxS64Bitfield(
+ &offset, byte_size, bitfield_bit_size, bitfield_bit_offset);
+ bool can_be_bitfield = true;
+ uint64_t covered_bits = 0;
+ int num_enumerators = 0;
+
+ // Try to find an exact match for the value.
+ // At the same time, we're applying a heuristic to determine whether we want
+ // to print this enum as a bitfield. We're likely dealing with a bitfield if
+ // every enumrator is either a one bit value or a superset of the previous
+ // enumerators. Also 0 doesn't make sense when the enumerators are used as
+ // flags.
+ for (auto enumerator : enum_decl->enumerators()) {
+ uint64_t val = enumerator->getInitVal().getSExtValue();
+ val = llvm::SignExtend64(val, 8*byte_size);
+ if (llvm::countPopulation(val) != 1 && (val & ~covered_bits) != 0)
+ can_be_bitfield = false;
+ covered_bits |= val;
+ ++num_enumerators;
+ if (val == enum_svalue) {
+ // Found an exact match, that's all we need to do.
+ s->PutCString(enumerator->getNameAsString());
+ return true;
+ }
+ }
+
+ // Unsigned values make more sense for flags.
+ offset = byte_offset;
+ const uint64_t enum_uvalue = data.GetMaxU64Bitfield(
+ &offset, byte_size, bitfield_bit_size, bitfield_bit_offset);
+
+ // No exact match, but we don't think this is a bitfield. Print the value as
+ // decimal.
+ if (!can_be_bitfield) {
+ if (qual_type->isSignedIntegerOrEnumerationType())
+ s->Printf("%" PRIi64, enum_svalue);
+ else
+ s->Printf("%" PRIu64, enum_uvalue);
+ return true;
+ }
+
+ uint64_t remaining_value = enum_uvalue;
+ std::vector<std::pair<uint64_t, llvm::StringRef>> values;
+ values.reserve(num_enumerators);
+ for (auto enumerator : enum_decl->enumerators())
+ if (auto val = enumerator->getInitVal().getZExtValue())
+ values.emplace_back(val, enumerator->getName());
+
+ // Sort in reverse order of the number of the population count, so that in
+ // `enum {A, B, ALL = A|B }` we visit ALL first. Use a stable sort so that
+ // A | C where A is declared before C is displayed in this order.
+ std::stable_sort(values.begin(), values.end(), [](const auto &a, const auto &b) {
+ return llvm::countPopulation(a.first) > llvm::countPopulation(b.first);
+ });
+
+ for (const auto &val : values) {
+ if ((remaining_value & val.first) != val.first)
+ continue;
+ remaining_value &= ~val.first;
+ s->PutCString(val.second);
+ if (remaining_value)
+ s->PutCString(" | ");
+ }
+
+ // If there is a remainder that is not covered by the value, print it as hex.
+ if (remaining_value)
+ s->Printf("0x%" PRIx64, remaining_value);
+
+ return true;
+}
+
bool ClangASTContext::DumpTypeValue(
lldb::opaque_compiler_type_t type, Stream *s, lldb::Format format,
const DataExtractor &data, lldb::offset_t byte_offset, size_t byte_size,
@@ -9503,13 +9478,20 @@ bool ClangASTContext::DumpTypeValue(
clang::QualType qual_type(GetQualType(type));
const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+
+ if (type_class == clang::Type::Elaborated) {
+ qual_type = llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType();
+ return DumpTypeValue(qual_type.getAsOpaquePtr(), s, format, data, byte_offset, byte_size,
+ bitfield_bit_size, bitfield_bit_offset, exe_scope);
+ }
+
switch (type_class) {
case clang::Type::Typedef: {
clang::QualType typedef_qual_type =
llvm::cast<clang::TypedefType>(qual_type)
->getDecl()
->getUnderlyingType();
- CompilerType typedef_clang_type(getASTContext(), typedef_qual_type);
+ CompilerType typedef_clang_type(this, typedef_qual_type.getAsOpaquePtr());
if (format == eFormatDefault)
format = typedef_clang_type.GetFormat();
clang::TypeInfo typedef_type_info =
@@ -9533,45 +9515,9 @@ bool ClangASTContext::DumpTypeValue(
// If our format is enum or default, show the enumeration value as its
// enumeration string value, else just display it as requested.
if ((format == eFormatEnum || format == eFormatDefault) &&
- GetCompleteType(type)) {
- const clang::EnumType *enutype =
- llvm::cast<clang::EnumType>(qual_type.getTypePtr());
- const clang::EnumDecl *enum_decl = enutype->getDecl();
- assert(enum_decl);
- clang::EnumDecl::enumerator_iterator enum_pos, enum_end_pos;
- const bool is_signed = qual_type->isSignedIntegerOrEnumerationType();
- lldb::offset_t offset = byte_offset;
- if (is_signed) {
- const int64_t enum_svalue = data.GetMaxS64Bitfield(
- &offset, byte_size, bitfield_bit_size, bitfield_bit_offset);
- for (enum_pos = enum_decl->enumerator_begin(),
- enum_end_pos = enum_decl->enumerator_end();
- enum_pos != enum_end_pos; ++enum_pos) {
- if (enum_pos->getInitVal().getSExtValue() == enum_svalue) {
- s->PutCString(enum_pos->getNameAsString());
- return true;
- }
- }
- // If we have gotten here we didn't get find the enumerator in the
- // enum decl, so just print the integer.
- s->Printf("%" PRIi64, enum_svalue);
- } else {
- const uint64_t enum_uvalue = data.GetMaxU64Bitfield(
- &offset, byte_size, bitfield_bit_size, bitfield_bit_offset);
- for (enum_pos = enum_decl->enumerator_begin(),
- enum_end_pos = enum_decl->enumerator_end();
- enum_pos != enum_end_pos; ++enum_pos) {
- if (enum_pos->getInitVal().getZExtValue() == enum_uvalue) {
- s->PutCString(enum_pos->getNameAsString());
- return true;
- }
- }
- // If we have gotten here we didn't get find the enumerator in the
- // enum decl, so just print the integer.
- s->Printf("%" PRIu64, enum_uvalue);
- }
- return true;
- }
+ GetCompleteType(type))
+ return DumpEnumValue(qual_type, s, data, byte_offset, byte_size,
+ bitfield_bit_offset, bitfield_bit_size);
// format was not enum, just fall through and dump the value as
// requested....
LLVM_FALLTHROUGH;
@@ -9739,20 +9685,23 @@ void ClangASTContext::DumpTypeDescription(lldb::opaque_compiler_type_t type,
} break;
case clang::Type::Auto:
- CompilerType(getASTContext(),
- llvm::cast<clang::AutoType>(qual_type)->getDeducedType())
+ CompilerType(this, llvm::cast<clang::AutoType>(qual_type)
+ ->getDeducedType()
+ .getAsOpaquePtr())
.DumpTypeDescription(s);
return;
case clang::Type::Elaborated:
- CompilerType(getASTContext(),
- llvm::cast<clang::ElaboratedType>(qual_type)->getNamedType())
+ CompilerType(this, llvm::cast<clang::ElaboratedType>(qual_type)
+ ->getNamedType()
+ .getAsOpaquePtr())
.DumpTypeDescription(s);
return;
case clang::Type::Paren:
- CompilerType(getASTContext(),
- llvm::cast<clang::ParenType>(qual_type)->desugar())
+ CompilerType(
+ this,
+ llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr())
.DumpTypeDescription(s);
return;
@@ -10348,9 +10297,9 @@ ClangASTContext::DeclContextGetClangASTContext(const CompilerDeclContext &dc) {
return nullptr;
}
-ClangASTContextForExpressions::ClangASTContextForExpressions(Target &target)
- : ClangASTContext(target.GetArchitecture().GetTriple().getTriple().c_str()),
- m_target_wp(target.shared_from_this()),
+ClangASTContextForExpressions::ClangASTContextForExpressions(Target &target,
+ ArchSpec arch)
+ : ClangASTContext(arch), m_target_wp(target.shared_from_this()),
m_persistent_variables(new ClangPersistentVariables) {}
UserExpression *ClangASTContextForExpressions::GetUserExpression(
diff --git a/source/Symbol/ClangASTImporter.cpp b/source/Symbol/ClangASTImporter.cpp
index 32d0c47693b0..92d51f79a007 100644
--- a/source/Symbol/ClangASTImporter.cpp
+++ b/source/Symbol/ClangASTImporter.cpp
@@ -30,28 +30,28 @@ ClangASTMetrics::Counters ClangASTMetrics::local_counters = {0, 0, 0, 0, 0, 0};
void ClangASTMetrics::DumpCounters(Log *log,
ClangASTMetrics::Counters &counters) {
- log->Printf(" Number of visible Decl queries by name : %" PRIu64,
- counters.m_visible_query_count);
- log->Printf(" Number of lexical Decl queries : %" PRIu64,
- counters.m_lexical_query_count);
- log->Printf(" Number of imports initiated by LLDB : %" PRIu64,
- counters.m_lldb_import_count);
- log->Printf(" Number of imports conducted by Clang : %" PRIu64,
- counters.m_clang_import_count);
- log->Printf(" Number of Decls completed : %" PRIu64,
- counters.m_decls_completed_count);
- log->Printf(" Number of records laid out : %" PRIu64,
- counters.m_record_layout_count);
+ LLDB_LOGF(log, " Number of visible Decl queries by name : %" PRIu64,
+ counters.m_visible_query_count);
+ LLDB_LOGF(log, " Number of lexical Decl queries : %" PRIu64,
+ counters.m_lexical_query_count);
+ LLDB_LOGF(log, " Number of imports initiated by LLDB : %" PRIu64,
+ counters.m_lldb_import_count);
+ LLDB_LOGF(log, " Number of imports conducted by Clang : %" PRIu64,
+ counters.m_clang_import_count);
+ LLDB_LOGF(log, " Number of Decls completed : %" PRIu64,
+ counters.m_decls_completed_count);
+ LLDB_LOGF(log, " Number of records laid out : %" PRIu64,
+ counters.m_record_layout_count);
}
void ClangASTMetrics::DumpCounters(Log *log) {
if (!log)
return;
- log->Printf("== ClangASTMetrics output ==");
- log->Printf("-- Global metrics --");
+ LLDB_LOGF(log, "== ClangASTMetrics output ==");
+ LLDB_LOGF(log, "-- Global metrics --");
DumpCounters(log, global_counters);
- log->Printf("-- Local metrics --");
+ LLDB_LOGF(log, "-- Local metrics --");
DumpCounters(log, local_counters);
}
@@ -127,14 +127,16 @@ clang::Decl *ClangASTImporter::CopyDecl(clang::ASTContext *dst_ast,
user_id = metadata->GetUserID();
if (NamedDecl *named_decl = dyn_cast<NamedDecl>(decl))
- log->Printf(" [ClangASTImporter] WARNING: Failed to import a %s "
- "'%s', metadata 0x%" PRIx64,
- decl->getDeclKindName(),
- named_decl->getNameAsString().c_str(), user_id);
+ LLDB_LOGF(log,
+ " [ClangASTImporter] WARNING: Failed to import a %s "
+ "'%s', metadata 0x%" PRIx64,
+ decl->getDeclKindName(),
+ named_decl->getNameAsString().c_str(), user_id);
else
- log->Printf(" [ClangASTImporter] WARNING: Failed to import a %s, "
- "metadata 0x%" PRIx64,
- decl->getDeclKindName(), user_id);
+ LLDB_LOGF(log,
+ " [ClangASTImporter] WARNING: Failed to import a %s, "
+ "metadata 0x%" PRIx64,
+ decl->getDeclKindName(), user_id);
}
return nullptr;
}
@@ -211,12 +213,12 @@ private:
if (clang::Decl *escaped_child = GetEscapedChild(decl)) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
- if (log)
- log->Printf(" [ClangASTImporter] DeclContextOverride couldn't "
- "override (%sDecl*)%p - its child (%sDecl*)%p escapes",
- decl->getDeclKindName(), static_cast<void *>(decl),
- escaped_child->getDeclKindName(),
- static_cast<void *>(escaped_child));
+ LLDB_LOGF(log,
+ " [ClangASTImporter] DeclContextOverride couldn't "
+ "override (%sDecl*)%p - its child (%sDecl*)%p escapes",
+ decl->getDeclKindName(), static_cast<void *>(decl),
+ escaped_child->getDeclKindName(),
+ static_cast<void *>(escaped_child));
lldbassert(0 && "Couldn't override!");
}
@@ -248,40 +250,117 @@ public:
}
};
-lldb::opaque_compiler_type_t
-ClangASTImporter::DeportType(clang::ASTContext *dst_ctx,
- clang::ASTContext *src_ctx,
- lldb::opaque_compiler_type_t type) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+namespace {
+/// Completes all imported TagDecls at the end of the scope.
+///
+/// While in a CompleteTagDeclsScope, every decl that could be completed will
+/// be completed at the end of the scope (including all Decls that are
+/// imported while completing the original Decls).
+class CompleteTagDeclsScope : public ClangASTImporter::NewDeclListener {
+ ClangASTImporter::ImporterDelegateSP m_delegate;
+ // FIXME: Investigate how many decls we usually have in these sets and
+ // see if we can use SmallPtrSet instead here.
+ std::set<NamedDecl *> m_decls_to_complete;
+ std::set<NamedDecl *> m_decls_already_completed;
+ clang::ASTContext *m_dst_ctx;
+ clang::ASTContext *m_src_ctx;
+ ClangASTImporter &importer;
- if (log)
- log->Printf(" [ClangASTImporter] DeportType called on (%sType*)0x%llx "
- "from (ASTContext*)%p to (ASTContext*)%p",
- QualType::getFromOpaquePtr(type)->getTypeClassName(),
- (unsigned long long)type, static_cast<void *>(src_ctx),
- static_cast<void *>(dst_ctx));
+public:
+ /// Constructs a CompleteTagDeclsScope.
+ /// \param importer The ClangASTImporter that we should observe.
+ /// \param dst_ctx The ASTContext to which Decls are imported.
+ /// \param src_ctx The ASTContext from which Decls are imported.
+ explicit CompleteTagDeclsScope(ClangASTImporter &importer,
+ clang::ASTContext *dst_ctx,
+ clang::ASTContext *src_ctx)
+ : m_delegate(importer.GetDelegate(dst_ctx, src_ctx)), m_dst_ctx(dst_ctx),
+ m_src_ctx(src_ctx), importer(importer) {
+ m_delegate->SetImportListener(this);
+ }
- ImporterDelegateSP delegate_sp(GetDelegate(dst_ctx, src_ctx));
+ virtual ~CompleteTagDeclsScope() {
+ ClangASTImporter::ASTContextMetadataSP to_context_md =
+ importer.GetContextMetadata(m_dst_ctx);
- if (!delegate_sp)
- return nullptr;
+ // Complete all decls we collected until now.
+ while (!m_decls_to_complete.empty()) {
+ NamedDecl *decl = *m_decls_to_complete.begin();
- std::set<NamedDecl *> decls_to_deport;
- std::set<NamedDecl *> decls_already_deported;
+ m_decls_already_completed.insert(decl);
+ m_decls_to_complete.erase(decl);
- DeclContextOverride decl_context_override;
+ // We should only complete decls coming from the source context.
+ assert(to_context_md->m_origins[decl].ctx == m_src_ctx);
+
+ Decl *original_decl = to_context_md->m_origins[decl].decl;
+
+ // Complete the decl now.
+ ClangASTContext::GetCompleteDecl(m_src_ctx, original_decl);
+ if (auto *tag_decl = dyn_cast<TagDecl>(decl)) {
+ if (auto *original_tag_decl = dyn_cast<TagDecl>(original_decl)) {
+ if (original_tag_decl->isCompleteDefinition()) {
+ m_delegate->ImportDefinitionTo(tag_decl, original_tag_decl);
+ tag_decl->setCompleteDefinition(true);
+ }
+ }
+
+ tag_decl->setHasExternalLexicalStorage(false);
+ tag_decl->setHasExternalVisibleStorage(false);
+ } else if (auto *container_decl = dyn_cast<ObjCContainerDecl>(decl)) {
+ container_decl->setHasExternalLexicalStorage(false);
+ container_decl->setHasExternalVisibleStorage(false);
+ }
- if (const clang::TagType *tag_type =
- clang::QualType::getFromOpaquePtr(type)->getAs<TagType>()) {
- decl_context_override.OverrideAllDeclsFromContainingFunction(
- tag_type->getDecl());
+ to_context_md->m_origins.erase(decl);
+ }
+
+ // Stop listening to imported decls. We do this after clearing the
+ // Decls we needed to import to catch all Decls they might have pulled in.
+ m_delegate->RemoveImportListener();
}
- delegate_sp->InitDeportWorkQueues(&decls_to_deport, &decls_already_deported);
+ void NewDeclImported(clang::Decl *from, clang::Decl *to) override {
+ // Filter out decls that we can't complete later.
+ if (!isa<TagDecl>(to) && !isa<ObjCInterfaceDecl>(to))
+ return;
+ RecordDecl *from_record_decl = dyn_cast<RecordDecl>(from);
+ // We don't need to complete injected class name decls.
+ if (from_record_decl && from_record_decl->isInjectedClassName())
+ return;
+
+ NamedDecl *to_named_decl = dyn_cast<NamedDecl>(to);
+ // Check if we already completed this type.
+ if (m_decls_already_completed.count(to_named_decl) != 0)
+ return;
+ m_decls_to_complete.insert(to_named_decl);
+ }
+};
+} // namespace
+
+lldb::opaque_compiler_type_t
+ClangASTImporter::DeportType(clang::ASTContext *dst_ctx,
+ clang::ASTContext *src_ctx,
+ lldb::opaque_compiler_type_t type) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+
+ LLDB_LOGF(log,
+ " [ClangASTImporter] DeportType called on (%sType*)0x%llx "
+ "from (ASTContext*)%p to (ASTContext*)%p",
+ QualType::getFromOpaquePtr(type)->getTypeClassName(),
+ (unsigned long long)type, static_cast<void *>(src_ctx),
+ static_cast<void *>(dst_ctx));
+
+ DeclContextOverride decl_context_override;
- lldb::opaque_compiler_type_t result = CopyType(dst_ctx, src_ctx, type);
+ if (auto *t = QualType::getFromOpaquePtr(type)->getAs<TagType>())
+ decl_context_override.OverrideAllDeclsFromContainingFunction(t->getDecl());
- delegate_sp->ExecuteDeportWorkQueues();
+ lldb::opaque_compiler_type_t result;
+ {
+ CompleteTagDeclsScope complete_scope(*this, dst_ctx, src_ctx);
+ result = CopyType(dst_ctx, src_ctx, type);
+ }
if (!result)
return nullptr;
@@ -294,38 +373,30 @@ clang::Decl *ClangASTImporter::DeportDecl(clang::ASTContext *dst_ctx,
clang::Decl *decl) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
- if (log)
- log->Printf(" [ClangASTImporter] DeportDecl called on (%sDecl*)%p from "
- "(ASTContext*)%p to (ASTContext*)%p",
- decl->getDeclKindName(), static_cast<void *>(decl),
- static_cast<void *>(src_ctx), static_cast<void *>(dst_ctx));
-
- ImporterDelegateSP delegate_sp(GetDelegate(dst_ctx, src_ctx));
-
- if (!delegate_sp)
- return nullptr;
-
- std::set<NamedDecl *> decls_to_deport;
- std::set<NamedDecl *> decls_already_deported;
+ LLDB_LOGF(log,
+ " [ClangASTImporter] DeportDecl called on (%sDecl*)%p from "
+ "(ASTContext*)%p to (ASTContext*)%p",
+ decl->getDeclKindName(), static_cast<void *>(decl),
+ static_cast<void *>(src_ctx), static_cast<void *>(dst_ctx));
DeclContextOverride decl_context_override;
decl_context_override.OverrideAllDeclsFromContainingFunction(decl);
- delegate_sp->InitDeportWorkQueues(&decls_to_deport, &decls_already_deported);
-
- clang::Decl *result = CopyDecl(dst_ctx, src_ctx, decl);
-
- delegate_sp->ExecuteDeportWorkQueues();
+ clang::Decl *result;
+ {
+ CompleteTagDeclsScope complete_scope(*this, dst_ctx, src_ctx);
+ result = CopyDecl(dst_ctx, src_ctx, decl);
+ }
if (!result)
return nullptr;
- if (log)
- log->Printf(
- " [ClangASTImporter] DeportDecl deported (%sDecl*)%p to (%sDecl*)%p",
- decl->getDeclKindName(), static_cast<void *>(decl),
- result->getDeclKindName(), static_cast<void *>(result));
+ LLDB_LOGF(
+ log,
+ " [ClangASTImporter] DeportDecl deported (%sDecl*)%p to (%sDecl*)%p",
+ decl->getDeclKindName(), static_cast<void *>(decl),
+ result->getDeclKindName(), static_cast<void *>(result));
return result;
}
@@ -533,9 +604,8 @@ void ClangASTImporter::InsertRecordDecl(clang::RecordDecl *decl,
void ClangASTImporter::CompleteDecl(clang::Decl *decl) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
- if (log)
- log->Printf(" [ClangASTImporter] CompleteDecl called on (%sDecl*)%p",
- decl->getDeclKindName(), static_cast<void *>(decl));
+ LLDB_LOGF(log, " [ClangASTImporter] CompleteDecl called on (%sDecl*)%p",
+ decl->getDeclKindName(), static_cast<void *>(decl));
if (ObjCInterfaceDecl *interface_decl = dyn_cast<ObjCInterfaceDecl>(decl)) {
if (!interface_decl->getDefinition()) {
@@ -817,9 +887,9 @@ void ClangASTImporter::BuildNamespaceMap(const clang::NamespaceDecl *decl) {
void ClangASTImporter::ForgetDestination(clang::ASTContext *dst_ast) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
- if (log)
- log->Printf(" [ClangASTImporter] Forgetting destination (ASTContext*)%p",
- static_cast<void *>(dst_ast));
+ LLDB_LOGF(log,
+ " [ClangASTImporter] Forgetting destination (ASTContext*)%p",
+ static_cast<void *>(dst_ast));
m_metadata_map.erase(dst_ast);
}
@@ -830,10 +900,10 @@ void ClangASTImporter::ForgetSource(clang::ASTContext *dst_ast,
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
- if (log)
- log->Printf(" [ClangASTImporter] Forgetting source->dest "
- "(ASTContext*)%p->(ASTContext*)%p",
- static_cast<void *>(src_ast), static_cast<void *>(dst_ast));
+ LLDB_LOGF(log,
+ " [ClangASTImporter] Forgetting source->dest "
+ "(ASTContext*)%p->(ASTContext*)%p",
+ static_cast<void *>(src_ast), static_cast<void *>(dst_ast));
if (!md)
return;
@@ -869,63 +939,6 @@ ClangASTImporter::ASTImporterDelegate::ImportImpl(Decl *From) {
return ASTImporter::ImportImpl(From);
}
-void ClangASTImporter::ASTImporterDelegate::InitDeportWorkQueues(
- std::set<clang::NamedDecl *> *decls_to_deport,
- std::set<clang::NamedDecl *> *decls_already_deported) {
- assert(!m_decls_to_deport);
- assert(!m_decls_already_deported);
-
- m_decls_to_deport = decls_to_deport;
- m_decls_already_deported = decls_already_deported;
-}
-
-void ClangASTImporter::ASTImporterDelegate::ExecuteDeportWorkQueues() {
- assert(m_decls_to_deport);
- assert(m_decls_already_deported);
-
- ASTContextMetadataSP to_context_md =
- m_master.GetContextMetadata(&getToContext());
-
- while (!m_decls_to_deport->empty()) {
- NamedDecl *decl = *m_decls_to_deport->begin();
-
- m_decls_already_deported->insert(decl);
- m_decls_to_deport->erase(decl);
-
- DeclOrigin &origin = to_context_md->m_origins[decl];
- UNUSED_IF_ASSERT_DISABLED(origin);
-
- assert(origin.ctx ==
- m_source_ctx); // otherwise we should never have added this
- // because it doesn't need to be deported
-
- Decl *original_decl = to_context_md->m_origins[decl].decl;
-
- ClangASTContext::GetCompleteDecl(m_source_ctx, original_decl);
-
- if (TagDecl *tag_decl = dyn_cast<TagDecl>(decl)) {
- if (TagDecl *original_tag_decl = dyn_cast<TagDecl>(original_decl)) {
- if (original_tag_decl->isCompleteDefinition()) {
- ImportDefinitionTo(tag_decl, original_tag_decl);
- tag_decl->setCompleteDefinition(true);
- }
- }
-
- tag_decl->setHasExternalLexicalStorage(false);
- tag_decl->setHasExternalVisibleStorage(false);
- } else if (ObjCContainerDecl *container_decl =
- dyn_cast<ObjCContainerDecl>(decl)) {
- container_decl->setHasExternalLexicalStorage(false);
- container_decl->setHasExternalVisibleStorage(false);
- }
-
- to_context_md->m_origins.erase(decl);
- }
-
- m_decls_to_deport = nullptr;
- m_decls_already_deported = nullptr;
-}
-
void ClangASTImporter::ASTImporterDelegate::ImportDefinitionTo(
clang::Decl *to, clang::Decl *from) {
ASTImporter::Imported(from, to);
@@ -1045,15 +1058,17 @@ void ClangASTImporter::ASTImporterDelegate::Imported(clang::Decl *from,
from_named_decl->printName(name_stream);
name_stream.flush();
- log->Printf(" [ClangASTImporter] Imported (%sDecl*)%p, named %s (from "
- "(Decl*)%p), metadata 0x%" PRIx64,
- from->getDeclKindName(), static_cast<void *>(to),
- name_string.c_str(), static_cast<void *>(from), user_id);
+ LLDB_LOGF(log,
+ " [ClangASTImporter] Imported (%sDecl*)%p, named %s (from "
+ "(Decl*)%p), metadata 0x%" PRIx64,
+ from->getDeclKindName(), static_cast<void *>(to),
+ name_string.c_str(), static_cast<void *>(from), user_id);
} else {
- log->Printf(" [ClangASTImporter] Imported (%sDecl*)%p (from "
- "(Decl*)%p), metadata 0x%" PRIx64,
- from->getDeclKindName(), static_cast<void *>(to),
- static_cast<void *>(from), user_id);
+ LLDB_LOGF(log,
+ " [ClangASTImporter] Imported (%sDecl*)%p (from "
+ "(Decl*)%p), metadata 0x%" PRIx64,
+ from->getDeclKindName(), static_cast<void *>(to),
+ static_cast<void *>(from), user_id);
}
}
@@ -1080,37 +1095,27 @@ void ClangASTImporter::ASTImporterDelegate::Imported(clang::Decl *from,
if (direct_completer.get() != this)
direct_completer->ASTImporter::Imported(origin_iter->second.decl, to);
- if (log)
- log->Printf(" [ClangASTImporter] Propagated origin "
- "(Decl*)%p/(ASTContext*)%p from (ASTContext*)%p to "
- "(ASTContext*)%p",
- static_cast<void *>(origin_iter->second.decl),
- static_cast<void *>(origin_iter->second.ctx),
- static_cast<void *>(&from->getASTContext()),
- static_cast<void *>(&to->getASTContext()));
+ LLDB_LOGF(log,
+ " [ClangASTImporter] Propagated origin "
+ "(Decl*)%p/(ASTContext*)%p from (ASTContext*)%p to "
+ "(ASTContext*)%p",
+ static_cast<void *>(origin_iter->second.decl),
+ static_cast<void *>(origin_iter->second.ctx),
+ static_cast<void *>(&from->getASTContext()),
+ static_cast<void *>(&to->getASTContext()));
} else {
- if (m_decls_to_deport && m_decls_already_deported) {
- if (isa<TagDecl>(to) || isa<ObjCInterfaceDecl>(to)) {
- RecordDecl *from_record_decl = dyn_cast<RecordDecl>(from);
- if (from_record_decl == nullptr ||
- !from_record_decl->isInjectedClassName()) {
- NamedDecl *to_named_decl = dyn_cast<NamedDecl>(to);
-
- if (!m_decls_already_deported->count(to_named_decl))
- m_decls_to_deport->insert(to_named_decl);
- }
- }
- }
+ if (m_new_decl_listener)
+ m_new_decl_listener->NewDeclImported(from, to);
if (to_context_md->m_origins.find(to) == to_context_md->m_origins.end() ||
user_id != LLDB_INVALID_UID) {
to_context_md->m_origins[to] = DeclOrigin(m_source_ctx, from);
}
- if (log)
- log->Printf(" [ClangASTImporter] Decl has no origin information in "
- "(ASTContext*)%p",
- static_cast<void *>(&from->getASTContext()));
+ LLDB_LOGF(log,
+ " [ClangASTImporter] Decl has no origin information in "
+ "(ASTContext*)%p",
+ static_cast<void *>(&from->getASTContext()));
}
if (clang::NamespaceDecl *to_namespace =
@@ -1130,11 +1135,11 @@ void ClangASTImporter::ASTImporterDelegate::Imported(clang::Decl *from,
} else {
to_context_md->m_origins[to] = DeclOrigin(m_source_ctx, from);
- if (log)
- log->Printf(" [ClangASTImporter] Sourced origin "
- "(Decl*)%p/(ASTContext*)%p into (ASTContext*)%p",
- static_cast<void *>(from), static_cast<void *>(m_source_ctx),
- static_cast<void *>(&to->getASTContext()));
+ LLDB_LOGF(log,
+ " [ClangASTImporter] Sourced origin "
+ "(Decl*)%p/(ASTContext*)%p into (ASTContext*)%p",
+ static_cast<void *>(from), static_cast<void *>(m_source_ctx),
+ static_cast<void *>(&to->getASTContext()));
}
if (TagDecl *from_tag_decl = dyn_cast<TagDecl>(from)) {
@@ -1143,13 +1148,13 @@ void ClangASTImporter::ASTImporterDelegate::Imported(clang::Decl *from,
to_tag_decl->setHasExternalLexicalStorage();
to_tag_decl->getPrimaryContext()->setMustBuildLookupTable();
- if (log)
- log->Printf(
- " [ClangASTImporter] To is a TagDecl - attributes %s%s [%s->%s]",
- (to_tag_decl->hasExternalLexicalStorage() ? " Lexical" : ""),
- (to_tag_decl->hasExternalVisibleStorage() ? " Visible" : ""),
- (from_tag_decl->isCompleteDefinition() ? "complete" : "incomplete"),
- (to_tag_decl->isCompleteDefinition() ? "complete" : "incomplete"));
+ LLDB_LOGF(
+ log,
+ " [ClangASTImporter] To is a TagDecl - attributes %s%s [%s->%s]",
+ (to_tag_decl->hasExternalLexicalStorage() ? " Lexical" : ""),
+ (to_tag_decl->hasExternalVisibleStorage() ? " Visible" : ""),
+ (from_tag_decl->isCompleteDefinition() ? "complete" : "incomplete"),
+ (to_tag_decl->isCompleteDefinition() ? "complete" : "incomplete"));
}
if (isa<NamespaceDecl>(from)) {
@@ -1171,15 +1176,16 @@ void ClangASTImporter::ASTImporterDelegate::Imported(clang::Decl *from,
if (log) {
if (ObjCInterfaceDecl *to_interface_decl =
llvm::dyn_cast<ObjCInterfaceDecl>(to_container_decl)) {
- log->Printf(
+ LLDB_LOGF(
+ log,
" [ClangASTImporter] To is an ObjCInterfaceDecl - attributes "
"%s%s%s",
(to_interface_decl->hasExternalLexicalStorage() ? " Lexical" : ""),
(to_interface_decl->hasExternalVisibleStorage() ? " Visible" : ""),
(to_interface_decl->hasDefinition() ? " HasDefinition" : ""));
} else {
- log->Printf(
- " [ClangASTImporter] To is an %sDecl - attributes %s%s",
+ LLDB_LOGF(
+ log, " [ClangASTImporter] To is an %sDecl - attributes %s%s",
((Decl *)to_container_decl)->getDeclKindName(),
(to_container_decl->hasExternalLexicalStorage() ? " Lexical" : ""),
(to_container_decl->hasExternalVisibleStorage() ? " Visible" : ""));
diff --git a/source/Symbol/CompactUnwindInfo.cpp b/source/Symbol/CompactUnwindInfo.cpp
index 3a2a4d3a09e6..3eee7f785f36 100644
--- a/source/Symbol/CompactUnwindInfo.cpp
+++ b/source/Symbol/CompactUnwindInfo.cpp
@@ -190,8 +190,8 @@ bool CompactUnwindInfo::GetUnwindPlan(Target &target, Address addr,
Address::DumpStyle::DumpStyleResolvedDescriptionNoFunctionArguments,
Address::DumpStyle::DumpStyleFileAddress,
arch.GetAddressByteSize());
- log->Printf("Got compact unwind encoding 0x%x for function %s",
- function_info.encoding, strm.GetData());
+ LLDB_LOGF(log, "Got compact unwind encoding 0x%x for function %s",
+ function_info.encoding, strm.GetData());
}
if (function_info.valid_range_offset_start != 0 &&
@@ -213,7 +213,8 @@ bool CompactUnwindInfo::GetUnwindPlan(Target &target, Address addr,
return CreateUnwindPlan_x86_64(target, function_info, unwind_plan,
addr);
}
- if (arch.GetTriple().getArch() == llvm::Triple::aarch64) {
+ if (arch.GetTriple().getArch() == llvm::Triple::aarch64 ||
+ arch.GetTriple().getArch() == llvm::Triple::aarch64_32) {
return CreateUnwindPlan_arm64(target, function_info, unwind_plan, addr);
}
if (arch.GetTriple().getArch() == llvm::Triple::x86) {
@@ -737,6 +738,7 @@ bool CompactUnwindInfo::CreateUnwindPlan_x86_64(Target &target,
unwind_plan.SetSourceName("compact unwind info");
unwind_plan.SetSourcedFromCompiler(eLazyBoolYes);
unwind_plan.SetUnwindPlanValidAtAllInstructions(eLazyBoolNo);
+ unwind_plan.SetUnwindPlanForSignalTrap(eLazyBoolNo);
unwind_plan.SetRegisterKind(eRegisterKindEHFrame);
unwind_plan.SetLSDAAddress(function_info.lsda_address);
@@ -1008,6 +1010,7 @@ bool CompactUnwindInfo::CreateUnwindPlan_i386(Target &target,
unwind_plan.SetSourceName("compact unwind info");
unwind_plan.SetSourcedFromCompiler(eLazyBoolYes);
unwind_plan.SetUnwindPlanValidAtAllInstructions(eLazyBoolNo);
+ unwind_plan.SetUnwindPlanForSignalTrap(eLazyBoolNo);
unwind_plan.SetRegisterKind(eRegisterKindEHFrame);
unwind_plan.SetLSDAAddress(function_info.lsda_address);
@@ -1304,6 +1307,7 @@ bool CompactUnwindInfo::CreateUnwindPlan_arm64(Target &target,
unwind_plan.SetSourceName("compact unwind info");
unwind_plan.SetSourcedFromCompiler(eLazyBoolYes);
unwind_plan.SetUnwindPlanValidAtAllInstructions(eLazyBoolNo);
+ unwind_plan.SetUnwindPlanForSignalTrap(eLazyBoolNo);
unwind_plan.SetRegisterKind(eRegisterKindEHFrame);
unwind_plan.SetLSDAAddress(function_info.lsda_address);
@@ -1437,6 +1441,7 @@ bool CompactUnwindInfo::CreateUnwindPlan_armv7(Target &target,
unwind_plan.SetSourceName("compact unwind info");
unwind_plan.SetSourcedFromCompiler(eLazyBoolYes);
unwind_plan.SetUnwindPlanValidAtAllInstructions(eLazyBoolNo);
+ unwind_plan.SetUnwindPlanForSignalTrap(eLazyBoolNo);
unwind_plan.SetRegisterKind(eRegisterKindEHFrame);
unwind_plan.SetLSDAAddress(function_info.lsda_address);
diff --git a/source/Symbol/CompileUnit.cpp b/source/Symbol/CompileUnit.cpp
index 5fb9b6b9f729..41086d2df3df 100644
--- a/source/Symbol/CompileUnit.cpp
+++ b/source/Symbol/CompileUnit.cpp
@@ -9,7 +9,7 @@
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Core/Module.h"
#include "lldb/Symbol/LineTable.h"
-#include "lldb/Symbol/SymbolVendor.h"
+#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Symbol/VariableList.h"
#include "lldb/Target/Language.h"
@@ -119,49 +119,6 @@ void CompileUnit::AddFunction(FunctionSP &funcSP) {
m_functions_by_uid[funcSP->GetID()] = funcSP;
}
-// Find functions using the Mangled::Tokens token list. This function currently
-// implements an interactive approach designed to find all instances of certain
-// functions. It isn't designed to the quickest way to lookup functions as it
-// will need to iterate through all functions and see if they match, though it
-// does provide a powerful and context sensitive way to search for all
-// functions with a certain name, all functions in a namespace, or all
-// functions of a template type. See Mangled::Tokens::Parse() comments for more
-// information.
-//
-// The function prototype will need to change to return a list of results. It
-// was originally used to help debug the Mangled class and the
-// Mangled::Tokens::MatchesQuery() function and it currently will print out a
-// list of matching results for the functions that are currently in this
-// compile unit.
-//
-// A FindFunctions method should be called prior to this that takes
-// a regular function name (const char * or ConstString as a parameter) before
-// resorting to this slower but more complete function. The other FindFunctions
-// method should be able to take advantage of any accelerator tables available
-// in the debug information (which is parsed by the SymbolFile parser plug-ins
-// and registered with each Module).
-// void
-// CompileUnit::FindFunctions(const Mangled::Tokens& tokens)
-//{
-// if (!m_functions.empty())
-// {
-// Stream s(stdout);
-// std::vector<FunctionSP>::const_iterator pos;
-// std::vector<FunctionSP>::const_iterator end = m_functions.end();
-// for (pos = m_functions.begin(); pos != end; ++pos)
-// {
-// const ConstString& demangled = (*pos)->Mangled().Demangled();
-// if (demangled)
-// {
-// const Mangled::Tokens& func_tokens =
-// (*pos)->Mangled().GetTokens();
-// if (func_tokens.MatchesQuery (tokens))
-// s << "demangled MATCH found: " << demangled << "\n";
-// }
-// }
-// }
-//}
-
FunctionSP CompileUnit::FindFunctionByUID(lldb::user_id_t func_uid) {
auto it = m_functions_by_uid.find(func_uid);
if (it == m_functions_by_uid.end())
@@ -173,10 +130,8 @@ lldb::LanguageType CompileUnit::GetLanguage() {
if (m_language == eLanguageTypeUnknown) {
if (m_flags.IsClear(flagsParsedLanguage)) {
m_flags.Set(flagsParsedLanguage);
- SymbolVendor *symbol_vendor = GetModule()->GetSymbolVendor();
- if (symbol_vendor) {
- m_language = symbol_vendor->ParseLanguage(*this);
- }
+ if (SymbolFile *symfile = GetModule()->GetSymbolFile())
+ m_language = symfile->ParseLanguage(*this);
}
}
return m_language;
@@ -186,9 +141,8 @@ LineTable *CompileUnit::GetLineTable() {
if (m_line_table_up == nullptr) {
if (m_flags.IsClear(flagsParsedLineTable)) {
m_flags.Set(flagsParsedLineTable);
- SymbolVendor *symbol_vendor = GetModule()->GetSymbolVendor();
- if (symbol_vendor)
- symbol_vendor->ParseLineTable(*this);
+ if (SymbolFile *symfile = GetModule()->GetSymbolFile())
+ symfile->ParseLineTable(*this);
}
}
return m_line_table_up.get();
@@ -202,14 +156,16 @@ void CompileUnit::SetLineTable(LineTable *line_table) {
m_line_table_up.reset(line_table);
}
+void CompileUnit::SetSupportFiles(const FileSpecList &support_files) {
+ m_support_files = support_files;
+}
+
DebugMacros *CompileUnit::GetDebugMacros() {
if (m_debug_macros_sp.get() == nullptr) {
if (m_flags.IsClear(flagsParsedDebugMacros)) {
m_flags.Set(flagsParsedDebugMacros);
- SymbolVendor *symbol_vendor = GetModule()->GetSymbolVendor();
- if (symbol_vendor) {
- symbol_vendor->ParseDebugMacros(*this);
- }
+ if (SymbolFile *symfile = GetModule()->GetSymbolFile())
+ symfile->ParseDebugMacros(*this);
}
}
@@ -229,7 +185,7 @@ VariableListSP CompileUnit::GetVariableList(bool can_create) {
SymbolContext sc;
CalculateSymbolContext(&sc);
assert(sc.module_sp);
- sc.module_sp->GetSymbolVendor()->ParseVariablesForContext(sc);
+ sc.module_sp->GetSymbolFile()->ParseVariablesForContext(sc);
}
return m_variables;
@@ -372,8 +328,8 @@ uint32_t CompileUnit::ResolveSymbolContext(const FileSpec &file_spec,
bool CompileUnit::GetIsOptimized() {
if (m_is_optimized == eLazyBoolCalculate) {
m_is_optimized = eLazyBoolNo;
- if (SymbolVendor *symbol_vendor = GetModule()->GetSymbolVendor()) {
- if (symbol_vendor->ParseIsOptimized(*this))
+ if (SymbolFile *symfile = GetModule()->GetSymbolFile()) {
+ if (symfile->ParseIsOptimized(*this))
m_is_optimized = eLazyBoolYes;
}
}
@@ -388,23 +344,26 @@ const std::vector<SourceModule> &CompileUnit::GetImportedModules() {
if (m_imported_modules.empty() &&
m_flags.IsClear(flagsParsedImportedModules)) {
m_flags.Set(flagsParsedImportedModules);
- if (SymbolVendor *symbol_vendor = GetModule()->GetSymbolVendor()) {
+ if (SymbolFile *symfile = GetModule()->GetSymbolFile()) {
SymbolContext sc;
CalculateSymbolContext(&sc);
- symbol_vendor->ParseImportedModules(sc, m_imported_modules);
+ symfile->ParseImportedModules(sc, m_imported_modules);
}
}
return m_imported_modules;
}
+void CompileUnit::ForEachExternalModule(llvm::function_ref<void(ModuleSP)> f) {
+ if (SymbolFile *symfile = GetModule()->GetSymbolFile())
+ symfile->ForEachExternalModule(*this, f);
+}
+
const FileSpecList &CompileUnit::GetSupportFiles() {
if (m_support_files.GetSize() == 0) {
if (m_flags.IsClear(flagsParsedSupportFiles)) {
m_flags.Set(flagsParsedSupportFiles);
- SymbolVendor *symbol_vendor = GetModule()->GetSymbolVendor();
- if (symbol_vendor) {
- symbol_vendor->ParseSupportFiles(*this, m_support_files);
- }
+ if (SymbolFile *symfile = GetModule()->GetSymbolFile())
+ symfile->ParseSupportFiles(*this, m_support_files);
}
}
return m_support_files;
diff --git a/source/Symbol/CompilerType.cpp b/source/Symbol/CompilerType.cpp
index bb9a1a642e42..571a8570a43b 100644
--- a/source/Symbol/CompilerType.cpp
+++ b/source/Symbol/CompilerType.cpp
@@ -10,8 +10,6 @@
#include "lldb/Core/Debugger.h"
#include "lldb/Core/StreamFile.h"
-#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Symbol/ClangExternalASTSourceCommon.h"
#include "lldb/Symbol/Type.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
@@ -32,13 +30,6 @@ CompilerType::CompilerType(TypeSystem *type_system,
lldb::opaque_compiler_type_t type)
: m_type(type), m_type_system(type_system) {}
-CompilerType::CompilerType(clang::ASTContext *ast, clang::QualType qual_type)
- : m_type(qual_type.getAsOpaquePtr()),
- m_type_system(ClangASTContext::GetASTContext(ast)) {
- if (m_type)
- assert(m_type_system != nullptr);
-}
-
CompilerType::~CompilerType() {}
// Tests
@@ -333,12 +324,6 @@ void CompilerType::SetCompilerType(TypeSystem *type_system,
m_type = type;
}
-void CompilerType::SetCompilerType(clang::ASTContext *ast,
- clang::QualType qual_type) {
- m_type_system = ClangASTContext::GetASTContext(ast);
- m_type = qual_type.getAsOpaquePtr();
-}
-
unsigned CompilerType::GetTypeQualifiers() const {
if (IsValid())
return m_type_system->GetTypeQualifiers(m_type);
@@ -503,10 +488,10 @@ CompilerType::GetByteSize(ExecutionContextScope *exe_scope) const {
return {};
}
-size_t CompilerType::GetTypeBitAlign() const {
+llvm::Optional<size_t> CompilerType::GetTypeBitAlign(ExecutionContextScope *exe_scope) const {
if (IsValid())
- return m_type_system->GetTypeBitAlign(m_type);
- return 0;
+ return m_type_system->GetTypeBitAlign(m_type, exe_scope);
+ return {};
}
lldb::Encoding CompilerType::GetEncoding(uint64_t &count) const {
@@ -729,13 +714,6 @@ CompilerType::GetIndexOfChildWithName(const char *name,
return UINT32_MAX;
}
-size_t CompilerType::ConvertStringToFloatValue(const char *s, uint8_t *dst,
- size_t dst_size) const {
- if (IsValid())
- return m_type_system->ConvertStringToFloatValue(m_type, s, dst, dst_size);
- return 0;
-}
-
// Dumping types
#define DEPTH_INCREMENT 2
diff --git a/source/Symbol/CxxModuleHandler.cpp b/source/Symbol/CxxModuleHandler.cpp
index 68a2aab80bd6..19e80e5036bc 100644
--- a/source/Symbol/CxxModuleHandler.cpp
+++ b/source/Symbol/CxxModuleHandler.cpp
@@ -175,6 +175,8 @@ T *createDecl(ASTImporter &importer, Decl *from_d, Args &&... args) {
}
llvm::Optional<Decl *> CxxModuleHandler::tryInstantiateStdTemplate(Decl *d) {
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS);
+
// If we don't have a template to instiantiate, then there is nothing to do.
auto td = dyn_cast<ClassTemplateSpecializationDecl>(d);
if (!td)
@@ -196,9 +198,15 @@ llvm::Optional<Decl *> CxxModuleHandler::tryInstantiateStdTemplate(Decl *d) {
// Find the local DeclContext that corresponds to the DeclContext of our
// decl we want to import.
- auto to_context = getEqualLocalDeclContext(*m_sema, td->getDeclContext());
- if (!to_context)
+ llvm::Expected<DeclContext *> to_context =
+ getEqualLocalDeclContext(*m_sema, td->getDeclContext());
+ if (!to_context) {
+ LLDB_LOG_ERROR(log, to_context.takeError(),
+ "Got error while searching equal local DeclContext for decl "
+ "'{1}':\n{0}",
+ td->getName());
return {};
+ }
// Look up the template in our local context.
std::unique_ptr<LookupResult> lookup =
@@ -215,8 +223,6 @@ llvm::Optional<Decl *> CxxModuleHandler::tryInstantiateStdTemplate(Decl *d) {
// Import the foreign template arguments.
llvm::SmallVector<TemplateArgument, 4> imported_args;
- Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS);
-
// If this logic is changed, also update templateArgsAreSupported.
for (const TemplateArgument &arg : foreign_args.asArray()) {
switch (arg.getKind()) {
diff --git a/source/Symbol/DWARFCallFrameInfo.cpp b/source/Symbol/DWARFCallFrameInfo.cpp
index 0ab9fa4b7bbd..b4e74e9a2898 100644
--- a/source/Symbol/DWARFCallFrameInfo.cpp
+++ b/source/Symbol/DWARFCallFrameInfo.cpp
@@ -19,6 +19,7 @@
#include "lldb/Utility/Log.h"
#include "lldb/Utility/Timer.h"
#include <list>
+#include <cstring>
using namespace lldb;
using namespace lldb_private;
@@ -601,6 +602,9 @@ bool DWARFCallFrameInfo::FDEToUnwindPlan(dw_offset_t dwarf_offset,
}
offset += aug_data_len;
}
+ unwind_plan.SetUnwindPlanForSignalTrap(
+ strchr(cie->augmentation, 'S') ? eLazyBoolYes : eLazyBoolNo);
+
Address lsda_data;
Address personality_function_ptr;
@@ -769,13 +773,12 @@ bool DWARFCallFrameInfo::FDEToUnwindPlan(dw_offset_t dwarf_offset,
// useful for compilers that move epilogue code into the body of a
// function.)
if (stack.empty()) {
- if (log)
- log->Printf("DWARFCallFrameInfo::%s(dwarf_offset: %" PRIx32
- ", startaddr: %" PRIx64
- " encountered DW_CFA_restore_state but state stack "
- "is empty. Corrupt unwind info?",
- __FUNCTION__, dwarf_offset,
- startaddr.GetFileAddress());
+ LLDB_LOGF(log,
+ "DWARFCallFrameInfo::%s(dwarf_offset: %" PRIx32
+ ", startaddr: %" PRIx64
+ " encountered DW_CFA_restore_state but state stack "
+ "is empty. Corrupt unwind info?",
+ __FUNCTION__, dwarf_offset, startaddr.GetFileAddress());
break;
}
lldb::addr_t offset = row->GetOffset();
diff --git a/source/Symbol/DeclVendor.cpp b/source/Symbol/DeclVendor.cpp
index 0a912a2fd214..9ccf422e3bea 100644
--- a/source/Symbol/DeclVendor.cpp
+++ b/source/Symbol/DeclVendor.cpp
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "lldb/Symbol/DeclVendor.h"
-
-#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Symbol/CompilerDecl.h"
+#include "lldb/Symbol/TypeSystem.h"
#include <vector>
@@ -20,10 +20,11 @@ std::vector<CompilerType> DeclVendor::FindTypes(ConstString name,
// FIXME: This depends on clang, but should be able to support any
// TypeSystem.
std::vector<CompilerType> ret;
- std::vector<clang::NamedDecl *> decls;
+ std::vector<CompilerDecl> decls;
if (FindDecls(name, /*append*/ true, max_matches, decls))
- for (auto *decl : decls)
- if (auto type = ClangASTContext::GetTypeForDecl(decl))
+ for (auto decl : decls)
+ if (auto type =
+ decl.GetTypeSystem()->GetTypeForDecl(decl.GetOpaqueDecl()))
ret.push_back(type);
return ret;
}
diff --git a/source/Symbol/FuncUnwinders.cpp b/source/Symbol/FuncUnwinders.cpp
index 09cb9b00aaf3..f609bf7821e1 100644
--- a/source/Symbol/FuncUnwinders.cpp
+++ b/source/Symbol/FuncUnwinders.cpp
@@ -10,6 +10,7 @@
#include "lldb/Core/Address.h"
#include "lldb/Core/AddressRange.h"
#include "lldb/Symbol/ArmUnwindInfo.h"
+#include "lldb/Symbol/CallFrameInfo.h"
#include "lldb/Symbol/CompactUnwindInfo.h"
#include "lldb/Symbol/DWARFCallFrameInfo.h"
#include "lldb/Symbol/ObjectFile.h"
@@ -58,6 +59,8 @@ UnwindPlanSP FuncUnwinders::GetUnwindPlanAtCallSite(Target &target,
Thread &thread) {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ if (UnwindPlanSP plan_sp = GetObjectFileUnwindPlan(target))
+ return plan_sp;
if (UnwindPlanSP plan_sp = GetSymbolFileUnwindPlan(thread))
return plan_sp;
if (UnwindPlanSP plan_sp = GetDebugFrameUnwindPlan(target))
@@ -97,6 +100,26 @@ UnwindPlanSP FuncUnwinders::GetCompactUnwindUnwindPlan(Target &target) {
return UnwindPlanSP();
}
+lldb::UnwindPlanSP FuncUnwinders::GetObjectFileUnwindPlan(Target &target) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ if (m_unwind_plan_object_file_sp.get() ||
+ m_tried_unwind_plan_object_file)
+ return m_unwind_plan_object_file_sp;
+
+ m_tried_unwind_plan_object_file = true;
+ if (m_range.GetBaseAddress().IsValid()) {
+ CallFrameInfo *object_file_frame = m_unwind_table.GetObjectFileUnwindInfo();
+ if (object_file_frame) {
+ m_unwind_plan_object_file_sp =
+ std::make_shared<UnwindPlan>(lldb::eRegisterKindGeneric);
+ if (!object_file_frame->GetUnwindPlan(m_range,
+ *m_unwind_plan_object_file_sp))
+ m_unwind_plan_object_file_sp.reset();
+ }
+ }
+ return m_unwind_plan_object_file_sp;
+}
+
UnwindPlanSP FuncUnwinders::GetEHFrameUnwindPlan(Target &target) {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (m_unwind_plan_eh_frame_sp.get() || m_tried_unwind_plan_eh_frame)
@@ -185,6 +208,38 @@ UnwindPlanSP FuncUnwinders::GetSymbolFileUnwindPlan(Thread &thread) {
return m_unwind_plan_symbol_file_sp;
}
+UnwindPlanSP
+FuncUnwinders::GetObjectFileAugmentedUnwindPlan(Target &target,
+ Thread &thread) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ if (m_unwind_plan_object_file_augmented_sp.get() ||
+ m_tried_unwind_plan_object_file_augmented)
+ return m_unwind_plan_object_file_augmented_sp;
+
+ m_tried_unwind_plan_object_file_augmented = true;
+
+ UnwindPlanSP object_file_unwind_plan = GetObjectFileUnwindPlan(target);
+ if (!object_file_unwind_plan)
+ return m_unwind_plan_object_file_augmented_sp;
+
+ m_unwind_plan_object_file_augmented_sp =
+ std::make_shared<UnwindPlan>(*object_file_unwind_plan);
+
+ // Augment the instructions with epilogue descriptions if necessary
+ // so the UnwindPlan can be used at any instruction in the function.
+
+ UnwindAssemblySP assembly_profiler_sp(GetUnwindAssemblyProfiler(target));
+ if (assembly_profiler_sp) {
+ if (!assembly_profiler_sp->AugmentUnwindPlanFromCallSite(
+ m_range, thread, *m_unwind_plan_object_file_augmented_sp)) {
+ m_unwind_plan_object_file_augmented_sp.reset();
+ }
+ } else {
+ m_unwind_plan_object_file_augmented_sp.reset();
+ }
+ return m_unwind_plan_object_file_augmented_sp;
+}
+
UnwindPlanSP FuncUnwinders::GetEHFrameAugmentedUnwindPlan(Target &target,
Thread &thread) {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
@@ -328,6 +383,8 @@ UnwindPlanSP FuncUnwinders::GetUnwindPlanAtNonCallSite(Target &target,
UnwindPlanSP eh_frame_sp = GetEHFrameUnwindPlan(target);
if (!eh_frame_sp)
eh_frame_sp = GetDebugFrameUnwindPlan(target);
+ if (!eh_frame_sp)
+ eh_frame_sp = GetObjectFileUnwindPlan(target);
UnwindPlanSP arch_default_at_entry_sp =
GetUnwindPlanArchitectureDefaultAtFunctionEntry(thread);
UnwindPlanSP arch_default_sp = GetUnwindPlanArchitectureDefault(thread);
@@ -366,6 +423,8 @@ UnwindPlanSP FuncUnwinders::GetUnwindPlanAtNonCallSite(Target &target,
return plan_sp;
if (UnwindPlanSP plan_sp = GetEHFrameAugmentedUnwindPlan(target, thread))
return plan_sp;
+ if (UnwindPlanSP plan_sp = GetObjectFileAugmentedUnwindPlan(target, thread))
+ return plan_sp;
return assembly_sp;
}
@@ -473,6 +532,9 @@ Address FuncUnwinders::GetLSDAAddress(Target &target) {
if (unwind_plan_sp.get() == nullptr) {
unwind_plan_sp = GetCompactUnwindUnwindPlan(target);
}
+ if (unwind_plan_sp.get() == nullptr) {
+ unwind_plan_sp = GetObjectFileUnwindPlan(target);
+ }
if (unwind_plan_sp.get() && unwind_plan_sp->GetLSDAAddress().IsValid()) {
lsda_addr = unwind_plan_sp->GetLSDAAddress();
}
@@ -486,6 +548,9 @@ Address FuncUnwinders::GetPersonalityRoutinePtrAddress(Target &target) {
if (unwind_plan_sp.get() == nullptr) {
unwind_plan_sp = GetCompactUnwindUnwindPlan(target);
}
+ if (unwind_plan_sp.get() == nullptr) {
+ unwind_plan_sp = GetObjectFileUnwindPlan(target);
+ }
if (unwind_plan_sp.get() &&
unwind_plan_sp->GetPersonalityFunctionPtr().IsValid()) {
personality_addr = unwind_plan_sp->GetPersonalityFunctionPtr();
diff --git a/source/Symbol/Function.cpp b/source/Symbol/Function.cpp
index 951392c1f1bf..a4c2d3b4b44a 100644
--- a/source/Symbol/Function.cpp
+++ b/source/Symbol/Function.cpp
@@ -16,7 +16,6 @@
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/LineTable.h"
#include "lldb/Symbol/SymbolFile.h"
-#include "lldb/Symbol/SymbolVendor.h"
#include "lldb/Target/Language.h"
#include "lldb/Utility/Log.h"
#include "llvm/Support/Casting.h"
@@ -60,10 +59,11 @@ size_t FunctionInfo::MemorySize() const {
return m_name.MemorySize() + m_declaration.MemorySize();
}
-InlineFunctionInfo::InlineFunctionInfo(const char *name, const char *mangled,
+InlineFunctionInfo::InlineFunctionInfo(const char *name,
+ llvm::StringRef mangled,
const Declaration *decl_ptr,
const Declaration *call_decl_ptr)
- : FunctionInfo(name, decl_ptr), m_mangled(ConstString(mangled), true),
+ : FunctionInfo(name, decl_ptr), m_mangled(mangled),
m_call_decl(call_decl_ptr) {}
InlineFunctionInfo::InlineFunctionInfo(ConstString name,
@@ -128,11 +128,16 @@ size_t InlineFunctionInfo::MemorySize() const {
}
//
-CallEdge::CallEdge(const char *symbol_name, lldb::addr_t return_pc)
- : return_pc(return_pc), resolved(false) {
+CallEdge::CallEdge(const char *symbol_name, lldb::addr_t return_pc,
+ CallSiteParameterArray parameters)
+ : return_pc(return_pc), parameters(std::move(parameters)), resolved(false) {
lazy_callee.symbol_name = symbol_name;
}
+llvm::ArrayRef<CallSiteParameter> CallEdge::GetCallSiteParameters() const {
+ return parameters;
+}
+
void CallEdge::ParseSymbolFileAndResolve(ModuleList &images) {
if (resolved)
return;
@@ -144,8 +149,8 @@ void CallEdge::ParseSymbolFileAndResolve(ModuleList &images) {
auto resolve_lazy_callee = [&]() -> Function * {
ConstString callee_name{lazy_callee.symbol_name};
SymbolContextList sc_list;
- size_t num_matches =
- images.FindFunctionSymbols(callee_name, eFunctionNameTypeAuto, sc_list);
+ images.FindFunctionSymbols(callee_name, eFunctionNameTypeAuto, sc_list);
+ size_t num_matches = sc_list.GetSize();
if (num_matches == 0 || !sc_list[0].symbol) {
LLDB_LOG(log, "CallEdge: Found no symbols for {0}, cannot resolve it",
callee_name);
@@ -169,6 +174,7 @@ void CallEdge::ParseSymbolFileAndResolve(ModuleList &images) {
Function *CallEdge::GetCallee(ModuleList &images) {
ParseSymbolFileAndResolve(images);
+ assert(resolved && "Did not resolve lazy callee");
return lazy_callee.def;
}
@@ -277,11 +283,25 @@ llvm::MutableArrayRef<CallEdge> Function::GetTailCallingEdges() {
});
}
+CallEdge *Function::GetCallEdgeForReturnAddress(addr_t return_pc,
+ Target &target) {
+ auto edges = GetCallEdges();
+ auto edge_it =
+ std::lower_bound(edges.begin(), edges.end(), return_pc,
+ [&](const CallEdge &edge, addr_t pc) {
+ return edge.GetReturnPCAddress(*this, target) < pc;
+ });
+ if (edge_it == edges.end() ||
+ edge_it->GetReturnPCAddress(*this, target) != return_pc)
+ return nullptr;
+ return &const_cast<CallEdge &>(*edge_it);
+}
+
Block &Function::GetBlock(bool can_create) {
if (!m_block.BlockInfoHasBeenParsed() && can_create) {
ModuleSP module_sp = CalculateSymbolContextModule();
if (module_sp) {
- module_sp->GetSymbolVendor()->ParseBlocksRecursive(*this);
+ module_sp->GetSymbolFile()->ParseBlocksRecursive(*this);
} else {
Host::SystemLog(Host::eSystemLogError,
"error: unable to find module "
@@ -428,14 +448,8 @@ CompilerDeclContext Function::GetDeclContext() {
ModuleSP module_sp = CalculateSymbolContextModule();
if (module_sp) {
- SymbolVendor *sym_vendor = module_sp->GetSymbolVendor();
-
- if (sym_vendor) {
- SymbolFile *sym_file = sym_vendor->GetSymbolFile();
-
- if (sym_file)
- return sym_file->GetDeclContextForUID(GetID());
- }
+ if (SymbolFile *sym_file = module_sp->GetSymbolFile())
+ return sym_file->GetDeclContextForUID(GetID());
}
return CompilerDeclContext();
}
@@ -449,12 +463,7 @@ Type *Function::GetType() {
if (!sc.module_sp)
return nullptr;
- SymbolVendor *sym_vendor = sc.module_sp->GetSymbolVendor();
-
- if (sym_vendor == nullptr)
- return nullptr;
-
- SymbolFile *sym_file = sym_vendor->GetSymbolFile();
+ SymbolFile *sym_file = sc.module_sp->GetSymbolFile();
if (sym_file == nullptr)
return nullptr;
diff --git a/source/Symbol/LineTable.cpp b/source/Symbol/LineTable.cpp
index 8d4d72c9a2a2..1433dc156d91 100644
--- a/source/Symbol/LineTable.cpp
+++ b/source/Symbol/LineTable.cpp
@@ -241,33 +241,47 @@ bool LineTable::FindLineEntryByAddress(const Address &so_addr,
bool LineTable::ConvertEntryAtIndexToLineEntry(uint32_t idx,
LineEntry &line_entry) {
- if (idx < m_entries.size()) {
- const Entry &entry = m_entries[idx];
- ModuleSP module_sp(m_comp_unit->GetModule());
- if (module_sp &&
- module_sp->ResolveFileAddress(entry.file_addr,
- line_entry.range.GetBaseAddress())) {
- if (!entry.is_terminal_entry && idx + 1 < m_entries.size())
- line_entry.range.SetByteSize(m_entries[idx + 1].file_addr -
- entry.file_addr);
- else
- line_entry.range.SetByteSize(0);
-
- line_entry.file =
- m_comp_unit->GetSupportFiles().GetFileSpecAtIndex(entry.file_idx);
- line_entry.original_file =
- m_comp_unit->GetSupportFiles().GetFileSpecAtIndex(entry.file_idx);
- line_entry.line = entry.line;
- line_entry.column = entry.column;
- line_entry.is_start_of_statement = entry.is_start_of_statement;
- line_entry.is_start_of_basic_block = entry.is_start_of_basic_block;
- line_entry.is_prologue_end = entry.is_prologue_end;
- line_entry.is_epilogue_begin = entry.is_epilogue_begin;
- line_entry.is_terminal_entry = entry.is_terminal_entry;
- return true;
- }
- }
- return false;
+ if (idx >= m_entries.size())
+ return false;
+
+ const Entry &entry = m_entries[idx];
+ ModuleSP module_sp(m_comp_unit->GetModule());
+ if (!module_sp)
+ return false;
+
+ addr_t file_addr = entry.file_addr;
+
+ // A terminal entry can point outside of a module or a section. Decrement the
+ // address to ensure it resolves correctly.
+ if (entry.is_terminal_entry)
+ --file_addr;
+
+ if (!module_sp->ResolveFileAddress(file_addr,
+ line_entry.range.GetBaseAddress()))
+ return false;
+
+ // Now undo the decrement above.
+ if (entry.is_terminal_entry)
+ line_entry.range.GetBaseAddress().Slide(1);
+
+ if (!entry.is_terminal_entry && idx + 1 < m_entries.size())
+ line_entry.range.SetByteSize(m_entries[idx + 1].file_addr -
+ entry.file_addr);
+ else
+ line_entry.range.SetByteSize(0);
+
+ line_entry.file =
+ m_comp_unit->GetSupportFiles().GetFileSpecAtIndex(entry.file_idx);
+ line_entry.original_file =
+ m_comp_unit->GetSupportFiles().GetFileSpecAtIndex(entry.file_idx);
+ line_entry.line = entry.line;
+ line_entry.column = entry.column;
+ line_entry.is_start_of_statement = entry.is_start_of_statement;
+ line_entry.is_start_of_basic_block = entry.is_start_of_basic_block;
+ line_entry.is_prologue_end = entry.is_prologue_end;
+ line_entry.is_epilogue_begin = entry.is_epilogue_begin;
+ line_entry.is_terminal_entry = entry.is_terminal_entry;
+ return true;
}
uint32_t LineTable::FindLineEntryIndexByFileIndex(
diff --git a/source/Symbol/LocateSymbolFile.cpp b/source/Symbol/LocateSymbolFile.cpp
index bfdb6e705f4a..0d0e5300668f 100644
--- a/source/Symbol/LocateSymbolFile.cpp
+++ b/source/Symbol/LocateSymbolFile.cpp
@@ -157,8 +157,8 @@ static bool LocateDSYMInVincinityOfExecutable(const ModuleSpec &module_spec,
if (::LookForDsymNextToExecutablePath(module_spec, exec_fspec,
dsym_fspec)) {
if (log) {
- log->Printf("dSYM with matching UUID & arch found at %s",
- dsym_fspec.GetPath().c_str());
+ LLDB_LOGF(log, "dSYM with matching UUID & arch found at %s",
+ dsym_fspec.GetPath().c_str());
}
return true;
} else {
@@ -189,8 +189,8 @@ static bool LocateDSYMInVincinityOfExecutable(const ModuleSpec &module_spec,
if (::LookForDsymNextToExecutablePath(module_spec, parent_dirs,
dsym_fspec)) {
if (log) {
- log->Printf("dSYM with matching UUID & arch found at %s",
- dsym_fspec.GetPath().c_str());
+ LLDB_LOGF(log, "dSYM with matching UUID & arch found at %s",
+ dsym_fspec.GetPath().c_str());
}
return true;
}
@@ -261,107 +261,110 @@ Symbols::LocateExecutableSymbolFile(const ModuleSpec &module_spec,
FileSystem::Instance().Exists(symbol_file_spec))
return symbol_file_spec;
- const char *symbol_filename = symbol_file_spec.GetFilename().AsCString();
- if (symbol_filename && symbol_filename[0]) {
- FileSpecList debug_file_search_paths = default_search_paths;
+ FileSpecList debug_file_search_paths = default_search_paths;
- // Add module directory.
- FileSpec module_file_spec = module_spec.GetFileSpec();
- // We keep the unresolved pathname if it fails.
- FileSystem::Instance().ResolveSymbolicLink(module_file_spec,
- module_file_spec);
+ // Add module directory.
+ FileSpec module_file_spec = module_spec.GetFileSpec();
+ // We keep the unresolved pathname if it fails.
+ FileSystem::Instance().ResolveSymbolicLink(module_file_spec,
+ module_file_spec);
- ConstString file_dir = module_file_spec.GetDirectory();
+ ConstString file_dir = module_file_spec.GetDirectory();
+ {
+ FileSpec file_spec(file_dir.AsCString("."));
+ FileSystem::Instance().Resolve(file_spec);
+ debug_file_search_paths.AppendIfUnique(file_spec);
+ }
+
+ if (ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup()) {
+
+ // Add current working directory.
{
- FileSpec file_spec(file_dir.AsCString("."));
+ FileSpec file_spec(".");
FileSystem::Instance().Resolve(file_spec);
debug_file_search_paths.AppendIfUnique(file_spec);
}
- if (ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup()) {
-
- // Add current working directory.
- {
- FileSpec file_spec(".");
- FileSystem::Instance().Resolve(file_spec);
- debug_file_search_paths.AppendIfUnique(file_spec);
- }
-
#ifndef _WIN32
#if defined(__NetBSD__)
- // Add /usr/libdata/debug directory.
- {
- FileSpec file_spec("/usr/libdata/debug");
- FileSystem::Instance().Resolve(file_spec);
- debug_file_search_paths.AppendIfUnique(file_spec);
- }
+ // Add /usr/libdata/debug directory.
+ {
+ FileSpec file_spec("/usr/libdata/debug");
+ FileSystem::Instance().Resolve(file_spec);
+ debug_file_search_paths.AppendIfUnique(file_spec);
+ }
#else
- // Add /usr/lib/debug directory.
- {
- FileSpec file_spec("/usr/lib/debug");
- FileSystem::Instance().Resolve(file_spec);
- debug_file_search_paths.AppendIfUnique(file_spec);
- }
+ // Add /usr/lib/debug directory.
+ {
+ FileSpec file_spec("/usr/lib/debug");
+ FileSystem::Instance().Resolve(file_spec);
+ debug_file_search_paths.AppendIfUnique(file_spec);
+ }
#endif
#endif // _WIN32
- }
+ }
- std::string uuid_str;
- const UUID &module_uuid = module_spec.GetUUID();
- if (module_uuid.IsValid()) {
- // Some debug files are stored in the .build-id directory like this:
- // /usr/lib/debug/.build-id/ff/e7fe727889ad82bb153de2ad065b2189693315.debug
- uuid_str = module_uuid.GetAsString("");
- std::transform(uuid_str.begin(), uuid_str.end(), uuid_str.begin(),
- ::tolower);
- uuid_str.insert(2, 1, '/');
- uuid_str = uuid_str + ".debug";
- }
+ std::string uuid_str;
+ const UUID &module_uuid = module_spec.GetUUID();
+ if (module_uuid.IsValid()) {
+ // Some debug files are stored in the .build-id directory like this:
+ // /usr/lib/debug/.build-id/ff/e7fe727889ad82bb153de2ad065b2189693315.debug
+ uuid_str = module_uuid.GetAsString("");
+ std::transform(uuid_str.begin(), uuid_str.end(), uuid_str.begin(),
+ ::tolower);
+ uuid_str.insert(2, 1, '/');
+ uuid_str = uuid_str + ".debug";
+ }
- size_t num_directories = debug_file_search_paths.GetSize();
- for (size_t idx = 0; idx < num_directories; ++idx) {
- FileSpec dirspec = debug_file_search_paths.GetFileSpecAtIndex(idx);
- FileSystem::Instance().Resolve(dirspec);
- if (!FileSystem::Instance().IsDirectory(dirspec))
- continue;
+ size_t num_directories = debug_file_search_paths.GetSize();
+ for (size_t idx = 0; idx < num_directories; ++idx) {
+ FileSpec dirspec = debug_file_search_paths.GetFileSpecAtIndex(idx);
+ FileSystem::Instance().Resolve(dirspec);
+ if (!FileSystem::Instance().IsDirectory(dirspec))
+ continue;
- std::vector<std::string> files;
- std::string dirname = dirspec.GetPath();
+ std::vector<std::string> files;
+ std::string dirname = dirspec.GetPath();
- files.push_back(dirname + "/" + symbol_filename);
- files.push_back(dirname + "/.debug/" + symbol_filename);
+ if (!uuid_str.empty())
files.push_back(dirname + "/.build-id/" + uuid_str);
+ if (symbol_file_spec.GetFilename()) {
+ files.push_back(dirname + "/" +
+ symbol_file_spec.GetFilename().GetCString());
+ files.push_back(dirname + "/.debug/" +
+ symbol_file_spec.GetFilename().GetCString());
// Some debug files may stored in the module directory like this:
// /usr/lib/debug/usr/lib/library.so.debug
if (!file_dir.IsEmpty())
- files.push_back(dirname + file_dir.AsCString() + "/" + symbol_filename);
-
- const uint32_t num_files = files.size();
- for (size_t idx_file = 0; idx_file < num_files; ++idx_file) {
- const std::string &filename = files[idx_file];
- FileSpec file_spec(filename);
- FileSystem::Instance().Resolve(file_spec);
-
- if (llvm::sys::fs::equivalent(file_spec.GetPath(),
- module_file_spec.GetPath()))
- continue;
-
- if (FileSystem::Instance().Exists(file_spec)) {
- lldb_private::ModuleSpecList specs;
- const size_t num_specs =
- ObjectFile::GetModuleSpecifications(file_spec, 0, 0, specs);
- assert(num_specs <= 1 &&
- "Symbol Vendor supports only a single architecture");
- if (num_specs == 1) {
- ModuleSpec mspec;
- if (specs.GetModuleSpecAtIndex(0, mspec)) {
- // Skip the uuids check if module_uuid is invalid. For example,
- // this happens for *.dwp files since at the moment llvm-dwp
- // doesn't output build ids, nor does binutils dwp.
- if (!module_uuid.IsValid() || module_uuid == mspec.GetUUID())
- return file_spec;
- }
+ files.push_back(dirname + file_dir.AsCString() + "/" +
+ symbol_file_spec.GetFilename().GetCString());
+ }
+
+ const uint32_t num_files = files.size();
+ for (size_t idx_file = 0; idx_file < num_files; ++idx_file) {
+ const std::string &filename = files[idx_file];
+ FileSpec file_spec(filename);
+ FileSystem::Instance().Resolve(file_spec);
+
+ if (llvm::sys::fs::equivalent(file_spec.GetPath(),
+ module_file_spec.GetPath()))
+ continue;
+
+ if (FileSystem::Instance().Exists(file_spec)) {
+ lldb_private::ModuleSpecList specs;
+ const size_t num_specs =
+ ObjectFile::GetModuleSpecifications(file_spec, 0, 0, specs);
+ assert(num_specs <= 1 &&
+ "Symbol Vendor supports only a single architecture");
+ if (num_specs == 1) {
+ ModuleSpec mspec;
+ if (specs.GetModuleSpecAtIndex(0, mspec)) {
+ // Skip the uuids check if module_uuid is invalid. For example,
+ // this happens for *.dwp files since at the moment llvm-dwp
+ // doesn't output build ids, nor does binutils dwp.
+ if (!module_uuid.IsValid() || module_uuid == mspec.GetUUID())
+ return file_spec;
}
}
}
diff --git a/source/Symbol/LocateSymbolFileMacOSX.cpp b/source/Symbol/LocateSymbolFileMacOSX.cpp
index 4e16382d53e7..74718a8c5e30 100644
--- a/source/Symbol/LocateSymbolFileMacOSX.cpp
+++ b/source/Symbol/LocateSymbolFileMacOSX.cpp
@@ -23,7 +23,6 @@
#include "lldb/Host/Host.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Utility/ArchSpec.h"
-#include "lldb/Utility/CleanUp.h"
#include "lldb/Utility/DataBuffer.h"
#include "lldb/Utility/DataExtractor.h"
#include "lldb/Utility/Endian.h"
@@ -33,6 +32,7 @@
#include "lldb/Utility/UUID.h"
#include "mach/machine.h"
+#include "llvm/ADT/ScopeExit.h"
#include "llvm/Support/FileSystem.h"
using namespace lldb;
@@ -45,8 +45,7 @@ int LocateMacOSXFilesUsingDebugSymbols(const ModuleSpec &module_spec,
ModuleSpec &return_module_spec) {
Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
if (!ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup()) {
- if (log)
- log->Printf("Spotlight lookup for .dSYM bundles is disabled.");
+ LLDB_LOGF(log, "Spotlight lookup for .dSYM bundles is disabled.");
return 0;
}
@@ -102,9 +101,10 @@ int LocateMacOSXFilesUsingDebugSymbols(const ModuleSpec &module_spec,
if (::CFURLGetFileSystemRepresentation(
dsym_url.get(), true, (UInt8 *)path, sizeof(path) - 1)) {
if (log) {
- log->Printf("DebugSymbols framework returned dSYM path of %s for "
- "UUID %s -- looking for the dSYM",
- path, uuid->GetAsString().c_str());
+ LLDB_LOGF(log,
+ "DebugSymbols framework returned dSYM path of %s for "
+ "UUID %s -- looking for the dSYM",
+ path, uuid->GetAsString().c_str());
}
FileSpec dsym_filespec(path);
if (path[0] == '~')
@@ -124,9 +124,10 @@ int LocateMacOSXFilesUsingDebugSymbols(const ModuleSpec &module_spec,
if (log) {
if (::CFURLGetFileSystemRepresentation(
dsym_url.get(), true, (UInt8 *)path, sizeof(path) - 1)) {
- log->Printf("DebugSymbols framework returned dSYM path of %s for "
- "UUID %s -- looking for an exec file",
- path, uuid->GetAsString().c_str());
+ LLDB_LOGF(log,
+ "DebugSymbols framework returned dSYM path of %s for "
+ "UUID %s -- looking for an exec file",
+ path, uuid->GetAsString().c_str());
}
}
@@ -145,8 +146,8 @@ int LocateMacOSXFilesUsingDebugSymbols(const ModuleSpec &module_spec,
if (exec_cf_path && ::CFStringGetFileSystemRepresentation(
exec_cf_path, path, sizeof(path))) {
if (log) {
- log->Printf("plist bundle has exec path of %s for UUID %s",
- path, uuid->GetAsString().c_str());
+ LLDB_LOGF(log, "plist bundle has exec path of %s for UUID %s",
+ path, uuid->GetAsString().c_str());
}
++items_found;
FileSpec exec_filespec(path);
@@ -168,9 +169,10 @@ int LocateMacOSXFilesUsingDebugSymbols(const ModuleSpec &module_spec,
if (dsym_extension_pos) {
*dsym_extension_pos = '\0';
if (log) {
- log->Printf("Looking for executable binary next to dSYM "
- "bundle with name with name %s",
- path);
+ LLDB_LOGF(log,
+ "Looking for executable binary next to dSYM "
+ "bundle with name with name %s",
+ path);
}
FileSpec file_spec(path);
FileSystem::Instance().Resolve(file_spec);
@@ -199,9 +201,10 @@ int LocateMacOSXFilesUsingDebugSymbols(const ModuleSpec &module_spec,
++items_found;
return_module_spec.GetFileSpec() = bundle_exe_file_spec;
if (log) {
- log->Printf("Executable binary %s next to dSYM is "
- "compatible; using",
- path);
+ LLDB_LOGF(log,
+ "Executable binary %s next to dSYM is "
+ "compatible; using",
+ path);
}
}
}
@@ -228,9 +231,10 @@ int LocateMacOSXFilesUsingDebugSymbols(const ModuleSpec &module_spec,
++items_found;
return_module_spec.GetFileSpec() = file_spec;
if (log) {
- log->Printf("Executable binary %s next to dSYM is "
- "compatible; using",
- path);
+ LLDB_LOGF(log,
+ "Executable binary %s next to dSYM is "
+ "compatible; using",
+ path);
}
}
break;
@@ -260,7 +264,7 @@ FileSpec Symbols::FindSymbolFileInBundle(const FileSpec &dsym_bundle_fspec,
return {};
// Make sure we close the directory before exiting this scope.
- CleanUp cleanup_dir(closedir, dirp);
+ auto cleanup_dir = llvm::make_scope_exit([&]() { closedir(dirp); });
FileSpec dsym_fspec;
dsym_fspec.GetDirectory().SetCString(path);
@@ -315,9 +319,9 @@ static bool GetModuleSpecInfoFromUUIDDictionary(CFDictionaryRef uuid_dict,
module_spec.GetFileSpec().SetFile(str.c_str(), FileSpec::Style::native);
FileSystem::Instance().Resolve(module_spec.GetFileSpec());
if (log) {
- log->Printf(
- "From dsymForUUID plist: Symbol rich executable is at '%s'",
- str.c_str());
+ LLDB_LOGF(log,
+ "From dsymForUUID plist: Symbol rich executable is at '%s'",
+ str.c_str());
}
}
}
@@ -331,7 +335,8 @@ static bool GetModuleSpecInfoFromUUIDDictionary(CFDictionaryRef uuid_dict,
FileSystem::Instance().Resolve(module_spec.GetFileSpec());
success = true;
if (log) {
- log->Printf("From dsymForUUID plist: dSYM is at '%s'", str.c_str());
+ LLDB_LOGF(log, "From dsymForUUID plist: dSYM is at '%s'",
+ str.c_str());
}
}
}
@@ -582,11 +587,11 @@ bool Symbols::DownloadObjectAndSymbolFile(ModuleSpec &module_spec,
std::string command_output;
if (log) {
if (!uuid_str.empty())
- log->Printf("Calling %s with UUID %s to find dSYM",
- g_dsym_for_uuid_exe_path, uuid_str.c_str());
+ LLDB_LOGF(log, "Calling %s with UUID %s to find dSYM",
+ g_dsym_for_uuid_exe_path, uuid_str.c_str());
else if (file_path[0] != '\0')
- log->Printf("Calling %s with file %s to find dSYM",
- g_dsym_for_uuid_exe_path, file_path);
+ LLDB_LOGF(log, "Calling %s with file %s to find dSYM",
+ g_dsym_for_uuid_exe_path, file_path);
}
Status error = Host::RunShellCommand(
command.GetData(),
@@ -643,11 +648,11 @@ bool Symbols::DownloadObjectAndSymbolFile(ModuleSpec &module_spec,
} else {
if (log) {
if (!uuid_str.empty())
- log->Printf("Called %s on %s, no matches",
- g_dsym_for_uuid_exe_path, uuid_str.c_str());
+ LLDB_LOGF(log, "Called %s on %s, no matches",
+ g_dsym_for_uuid_exe_path, uuid_str.c_str());
else if (file_path[0] != '\0')
- log->Printf("Called %s on %s, no matches",
- g_dsym_for_uuid_exe_path, file_path);
+ LLDB_LOGF(log, "Called %s on %s, no matches",
+ g_dsym_for_uuid_exe_path, file_path);
}
}
}
diff --git a/source/Symbol/ObjectFile.cpp b/source/Symbol/ObjectFile.cpp
index 172d2b3f01e3..38bc7722d0d0 100644
--- a/source/Symbol/ObjectFile.cpp
+++ b/source/Symbol/ObjectFile.cpp
@@ -11,6 +11,7 @@
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Section.h"
+#include "lldb/Symbol/CallFrameInfo.h"
#include "lldb/Symbol/ObjectContainer.h"
#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Target/Process.h"
@@ -19,13 +20,14 @@
#include "lldb/Utility/DataBuffer.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/Log.h"
-#include "lldb/Utility/RegularExpression.h"
#include "lldb/Utility/Timer.h"
#include "lldb/lldb-private.h"
using namespace lldb;
using namespace lldb_private;
+char ObjectFile::ID;
+
ObjectFileSP
ObjectFile::FindPlugin(const lldb::ModuleSP &module_sp, const FileSpec *file,
lldb::offset_t file_offset, lldb::offset_t file_size,
@@ -81,9 +83,8 @@ ObjectFile::FindPlugin(const lldb::ModuleSP &module_sp, const FileSpec *file,
if (!data_sp || data_sp->GetByteSize() == 0) {
// Check for archive file with format "/path/to/archive.a(object.o)"
- char path_with_object[PATH_MAX * 2];
- module_sp->GetFileSpec().GetPath(path_with_object,
- sizeof(path_with_object));
+ llvm::SmallString<256> path_with_object;
+ module_sp->GetFileSpec().GetPath(path_with_object);
ConstString archive_object;
const bool must_exist = true;
@@ -271,13 +272,13 @@ ObjectFile::ObjectFile(const lldb::ModuleSP &module_sp,
if (data_sp)
m_data.SetData(data_sp, data_offset, length);
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
- if (log)
- log->Printf("%p ObjectFile::ObjectFile() module = %p (%s), file = %s, "
- "file_offset = 0x%8.8" PRIx64 ", size = %" PRIu64,
- static_cast<void *>(this), static_cast<void *>(module_sp.get()),
- module_sp->GetSpecificationDescription().c_str(),
- m_file ? m_file.GetPath().c_str() : "<NULL>", m_file_offset,
- m_length);
+ LLDB_LOGF(log,
+ "%p ObjectFile::ObjectFile() module = %p (%s), file = %s, "
+ "file_offset = 0x%8.8" PRIx64 ", size = %" PRIu64,
+ static_cast<void *>(this), static_cast<void *>(module_sp.get()),
+ module_sp->GetSpecificationDescription().c_str(),
+ m_file ? m_file.GetPath().c_str() : "<NULL>", m_file_offset,
+ m_length);
}
ObjectFile::ObjectFile(const lldb::ModuleSP &module_sp,
@@ -290,18 +291,17 @@ ObjectFile::ObjectFile(const lldb::ModuleSP &module_sp,
if (header_data_sp)
m_data.SetData(header_data_sp, 0, header_data_sp->GetByteSize());
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
- if (log)
- log->Printf("%p ObjectFile::ObjectFile() module = %p (%s), process = %p, "
- "header_addr = 0x%" PRIx64,
- static_cast<void *>(this), static_cast<void *>(module_sp.get()),
- module_sp->GetSpecificationDescription().c_str(),
- static_cast<void *>(process_sp.get()), m_memory_addr);
+ LLDB_LOGF(log,
+ "%p ObjectFile::ObjectFile() module = %p (%s), process = %p, "
+ "header_addr = 0x%" PRIx64,
+ static_cast<void *>(this), static_cast<void *>(module_sp.get()),
+ module_sp->GetSpecificationDescription().c_str(),
+ static_cast<void *>(process_sp.get()), m_memory_addr);
}
ObjectFile::~ObjectFile() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
- if (log)
- log->Printf("%p ObjectFile::~ObjectFile ()\n", static_cast<void *>(this));
+ LLDB_LOGF(log, "%p ObjectFile::~ObjectFile ()\n", static_cast<void *>(this));
}
bool ObjectFile::SetModulesArchitecture(const ArchSpec &new_arch) {
@@ -570,24 +570,22 @@ size_t ObjectFile::ReadSectionData(Section *section,
}
}
-bool ObjectFile::SplitArchivePathWithObject(const char *path_with_object,
+bool ObjectFile::SplitArchivePathWithObject(llvm::StringRef path_with_object,
FileSpec &archive_file,
ConstString &archive_object,
bool must_exist) {
- RegularExpression g_object_regex(llvm::StringRef("(.*)\\(([^\\)]+)\\)$"));
- RegularExpression::Match regex_match(2);
- if (g_object_regex.Execute(llvm::StringRef::withNullAsEmpty(path_with_object),
- &regex_match)) {
- std::string path;
- std::string obj;
- if (regex_match.GetMatchAtIndex(path_with_object, 1, path) &&
- regex_match.GetMatchAtIndex(path_with_object, 2, obj)) {
- archive_file.SetFile(path, FileSpec::Style::native);
- archive_object.SetCString(obj.c_str());
- return !(must_exist && !FileSystem::Instance().Exists(archive_file));
- }
- }
- return false;
+ size_t len = path_with_object.size();
+ if (len < 2 || path_with_object.back() != ')')
+ return false;
+ llvm::StringRef archive = path_with_object.substr(0, path_with_object.rfind('('));
+ if (archive.empty())
+ return false;
+ llvm::StringRef object = path_with_object.substr(archive.size() + 1).drop_back();
+ archive_file.SetFile(archive, FileSpec::Style::native);
+ if (must_exist && !FileSystem::Instance().Exists(archive_file))
+ return false;
+ archive_object.SetString(object);
+ return true;
}
void ObjectFile::ClearSymtab() {
@@ -595,10 +593,9 @@ void ObjectFile::ClearSymtab() {
if (module_sp) {
std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
- if (log)
- log->Printf("%p ObjectFile::ClearSymtab () symtab = %p",
- static_cast<void *>(this),
- static_cast<void *>(m_symtab_up.get()));
+ LLDB_LOGF(log, "%p ObjectFile::ClearSymtab () symtab = %p",
+ static_cast<void *>(this),
+ static_cast<void *>(m_symtab_up.get()));
m_symtab_up.reset();
}
}
@@ -674,6 +671,10 @@ ObjectFile::GetLoadableData(Target &target) {
return loadables;
}
+std::unique_ptr<CallFrameInfo> ObjectFile::CreateCallFrameInfo() {
+ return {};
+}
+
void ObjectFile::RelocateSection(lldb_private::Section *section)
{
}
diff --git a/source/Symbol/PostfixExpression.cpp b/source/Symbol/PostfixExpression.cpp
index 148653561a4e..8ecd571ed929 100644
--- a/source/Symbol/PostfixExpression.cpp
+++ b/source/Symbol/PostfixExpression.cpp
@@ -41,7 +41,8 @@ GetUnaryOpType(llvm::StringRef token) {
return llvm::None;
}
-Node *postfix::Parse(llvm::StringRef expr, llvm::BumpPtrAllocator &alloc) {
+Node *postfix::ParseOneExpression(llvm::StringRef expr,
+ llvm::BumpPtrAllocator &alloc) {
llvm::SmallVector<Node *, 4> stack;
llvm::StringRef token;
@@ -83,6 +84,26 @@ Node *postfix::Parse(llvm::StringRef expr, llvm::BumpPtrAllocator &alloc) {
return stack.back();
}
+std::vector<std::pair<llvm::StringRef, Node *>>
+postfix::ParseFPOProgram(llvm::StringRef prog, llvm::BumpPtrAllocator &alloc) {
+ llvm::SmallVector<llvm::StringRef, 4> exprs;
+ prog.split(exprs, '=');
+ if (exprs.empty() || !exprs.back().trim().empty())
+ return {};
+ exprs.pop_back();
+
+ std::vector<std::pair<llvm::StringRef, Node *>> result;
+ for (llvm::StringRef expr : exprs) {
+ llvm::StringRef lhs;
+ std::tie(lhs, expr) = getToken(expr);
+ Node *rhs = ParseOneExpression(expr, alloc);
+ if (!rhs)
+ return {};
+ result.emplace_back(lhs, rhs);
+ }
+ return result;
+}
+
namespace {
class SymbolResolver : public Visitor<bool> {
public:
diff --git a/source/Symbol/Symbol.cpp b/source/Symbol/Symbol.cpp
index 589f69244a48..3f2414335813 100644
--- a/source/Symbol/Symbol.cpp
+++ b/source/Symbol/Symbol.cpp
@@ -31,9 +31,8 @@ Symbol::Symbol()
m_is_weak(false), m_type(eSymbolTypeInvalid), m_mangled(), m_addr_range(),
m_flags() {}
-Symbol::Symbol(uint32_t symID, const char *name, bool name_is_mangled,
- SymbolType type, bool external, bool is_debug,
- bool is_trampoline, bool is_artificial,
+Symbol::Symbol(uint32_t symID, llvm::StringRef name, SymbolType type, bool external,
+ bool is_debug, bool is_trampoline, bool is_artificial,
const lldb::SectionSP &section_sp, addr_t offset, addr_t size,
bool size_is_valid, bool contains_linker_annotations,
uint32_t flags)
@@ -42,9 +41,9 @@ Symbol::Symbol(uint32_t symID, const char *name, bool name_is_mangled,
m_is_debug(is_debug), m_is_external(external), m_size_is_sibling(false),
m_size_is_synthesized(false), m_size_is_valid(size_is_valid || size > 0),
m_demangled_is_synthesized(false),
- m_contains_linker_annotations(contains_linker_annotations),
+ m_contains_linker_annotations(contains_linker_annotations),
m_is_weak(false), m_type(type),
- m_mangled(ConstString(name), name_is_mangled),
+ m_mangled(name),
m_addr_range(section_sp, offset, size), m_flags(flags) {}
Symbol::Symbol(uint32_t symID, const Mangled &mangled, SymbolType type,
diff --git a/source/Symbol/SymbolContext.cpp b/source/Symbol/SymbolContext.cpp
index a0b35cf3d0b9..31e0c89eed94 100644
--- a/source/Symbol/SymbolContext.cpp
+++ b/source/Symbol/SymbolContext.cpp
@@ -13,7 +13,6 @@
#include "lldb/Host/Host.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Symbol/Block.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/Symbol.h"
@@ -22,6 +21,7 @@
#include "lldb/Symbol/Variable.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
@@ -494,7 +494,8 @@ bool SymbolContext::GetParentOfInlinedScope(const Address &curr_frame_pc,
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SYMBOLS));
if (log) {
- log->Printf(
+ LLDB_LOGF(
+ log,
"warning: inlined block 0x%8.8" PRIx64
" doesn't have a range that contains file address 0x%" PRIx64,
curr_inlined_block->GetID(), curr_frame_pc.GetFileAddress());
@@ -503,12 +504,8 @@ bool SymbolContext::GetParentOfInlinedScope(const Address &curr_frame_pc,
else {
ObjectFile *objfile = nullptr;
if (module_sp) {
- SymbolVendor *symbol_vendor = module_sp->GetSymbolVendor();
- if (symbol_vendor) {
- SymbolFile *symbol_file = symbol_vendor->GetSymbolFile();
- if (symbol_file)
- objfile = symbol_file->GetObjectFile();
- }
+ if (SymbolFile *symbol_file = module_sp->GetSymbolFile())
+ objfile = symbol_file->GetObjectFile();
}
if (objfile) {
Host::SystemLog(
@@ -762,9 +759,8 @@ bool SymbolContext::GetAddressRangeFromHereToEndLine(uint32_t end_line,
}
Block *func_block = GetFunctionBlock();
- if (func_block &&
- func_block->GetRangeIndexContainingAddress(
- end_entry.range.GetBaseAddress()) == UINT32_MAX) {
+ if (func_block && func_block->GetRangeIndexContainingAddress(
+ end_entry.range.GetBaseAddress()) == UINT32_MAX) {
error.SetErrorStringWithFormat(
"end line number %d is not contained within the current function.",
end_line);
@@ -777,8 +773,8 @@ bool SymbolContext::GetAddressRangeFromHereToEndLine(uint32_t end_line,
return true;
}
-const Symbol *
-SymbolContext::FindBestGlobalDataSymbol(ConstString name, Status &error) {
+const Symbol *SymbolContext::FindBestGlobalDataSymbol(ConstString name,
+ Status &error) {
error.Clear();
if (!target_sp) {
@@ -788,8 +784,9 @@ SymbolContext::FindBestGlobalDataSymbol(ConstString name, Status &error) {
Target &target = *target_sp;
Module *module = module_sp.get();
- auto ProcessMatches = [this, &name, &target, module]
- (SymbolContextList &sc_list, Status &error) -> const Symbol* {
+ auto ProcessMatches = [this, &name, &target,
+ module](SymbolContextList &sc_list,
+ Status &error) -> const Symbol * {
llvm::SmallVector<const Symbol *, 1> external_symbols;
llvm::SmallVector<const Symbol *, 1> internal_symbols;
const uint32_t matches = sc_list.GetSize();
@@ -802,77 +799,77 @@ SymbolContext::FindBestGlobalDataSymbol(ConstString name, Status &error) {
if (sym_address.IsValid()) {
switch (symbol->GetType()) {
- case eSymbolTypeData:
- case eSymbolTypeRuntime:
- case eSymbolTypeAbsolute:
- case eSymbolTypeObjCClass:
- case eSymbolTypeObjCMetaClass:
- case eSymbolTypeObjCIVar:
- if (symbol->GetDemangledNameIsSynthesized()) {
- // If the demangled name was synthesized, then don't use it for
- // expressions. Only let the symbol match if the mangled named
- // matches for these symbols.
- if (symbol->GetMangled().GetMangledName() != name)
- break;
- }
- if (symbol->IsExternal()) {
- external_symbols.push_back(symbol);
- } else {
- internal_symbols.push_back(symbol);
- }
- break;
- case eSymbolTypeReExported: {
- ConstString reexport_name = symbol->GetReExportedSymbolName();
- if (reexport_name) {
- ModuleSP reexport_module_sp;
- ModuleSpec reexport_module_spec;
- reexport_module_spec.GetPlatformFileSpec() =
- symbol->GetReExportedSymbolSharedLibrary();
- if (reexport_module_spec.GetPlatformFileSpec()) {
- reexport_module_sp =
- target.GetImages().FindFirstModule(reexport_module_spec);
- if (!reexport_module_sp) {
- reexport_module_spec.GetPlatformFileSpec()
- .GetDirectory()
- .Clear();
- reexport_module_sp =
+ case eSymbolTypeData:
+ case eSymbolTypeRuntime:
+ case eSymbolTypeAbsolute:
+ case eSymbolTypeObjCClass:
+ case eSymbolTypeObjCMetaClass:
+ case eSymbolTypeObjCIVar:
+ if (symbol->GetDemangledNameIsSynthesized()) {
+ // If the demangled name was synthesized, then don't use it for
+ // expressions. Only let the symbol match if the mangled named
+ // matches for these symbols.
+ if (symbol->GetMangled().GetMangledName() != name)
+ break;
+ }
+ if (symbol->IsExternal()) {
+ external_symbols.push_back(symbol);
+ } else {
+ internal_symbols.push_back(symbol);
+ }
+ break;
+ case eSymbolTypeReExported: {
+ ConstString reexport_name = symbol->GetReExportedSymbolName();
+ if (reexport_name) {
+ ModuleSP reexport_module_sp;
+ ModuleSpec reexport_module_spec;
+ reexport_module_spec.GetPlatformFileSpec() =
+ symbol->GetReExportedSymbolSharedLibrary();
+ if (reexport_module_spec.GetPlatformFileSpec()) {
+ reexport_module_sp =
target.GetImages().FindFirstModule(reexport_module_spec);
- }
+ if (!reexport_module_sp) {
+ reexport_module_spec.GetPlatformFileSpec()
+ .GetDirectory()
+ .Clear();
+ reexport_module_sp =
+ target.GetImages().FindFirstModule(reexport_module_spec);
}
- // Don't allow us to try and resolve a re-exported symbol if it
- // is the same as the current symbol
- if (name == symbol->GetReExportedSymbolName() &&
- module == reexport_module_sp.get())
- return nullptr;
-
- return FindBestGlobalDataSymbol(
- symbol->GetReExportedSymbolName(), error);
}
- } break;
-
- case eSymbolTypeCode: // We already lookup functions elsewhere
- case eSymbolTypeVariable:
- case eSymbolTypeLocal:
- case eSymbolTypeParam:
- case eSymbolTypeTrampoline:
- case eSymbolTypeInvalid:
- case eSymbolTypeException:
- case eSymbolTypeSourceFile:
- case eSymbolTypeHeaderFile:
- case eSymbolTypeObjectFile:
- case eSymbolTypeCommonBlock:
- case eSymbolTypeBlock:
- case eSymbolTypeVariableType:
- case eSymbolTypeLineEntry:
- case eSymbolTypeLineHeader:
- case eSymbolTypeScopeBegin:
- case eSymbolTypeScopeEnd:
- case eSymbolTypeAdditional:
- case eSymbolTypeCompiler:
- case eSymbolTypeInstrumentation:
- case eSymbolTypeUndefined:
- case eSymbolTypeResolver:
- break;
+ // Don't allow us to try and resolve a re-exported symbol if it
+ // is the same as the current symbol
+ if (name == symbol->GetReExportedSymbolName() &&
+ module == reexport_module_sp.get())
+ return nullptr;
+
+ return FindBestGlobalDataSymbol(symbol->GetReExportedSymbolName(),
+ error);
+ }
+ } break;
+
+ case eSymbolTypeCode: // We already lookup functions elsewhere
+ case eSymbolTypeVariable:
+ case eSymbolTypeLocal:
+ case eSymbolTypeParam:
+ case eSymbolTypeTrampoline:
+ case eSymbolTypeInvalid:
+ case eSymbolTypeException:
+ case eSymbolTypeSourceFile:
+ case eSymbolTypeHeaderFile:
+ case eSymbolTypeObjectFile:
+ case eSymbolTypeCommonBlock:
+ case eSymbolTypeBlock:
+ case eSymbolTypeVariableType:
+ case eSymbolTypeLineEntry:
+ case eSymbolTypeLineHeader:
+ case eSymbolTypeScopeBegin:
+ case eSymbolTypeScopeEnd:
+ case eSymbolTypeAdditional:
+ case eSymbolTypeCompiler:
+ case eSymbolTypeInstrumentation:
+ case eSymbolTypeUndefined:
+ case eSymbolTypeResolver:
+ break;
}
}
}
@@ -933,7 +930,6 @@ SymbolContext::FindBestGlobalDataSymbol(ConstString name, Status &error) {
return nullptr; // no error; we just didn't find anything
}
-
//
// SymbolContextSpecifier
//
@@ -1296,6 +1292,8 @@ bool SymbolContextList::RemoveContextAtIndex(size_t idx) {
uint32_t SymbolContextList::GetSize() const { return m_symbol_contexts.size(); }
+bool SymbolContextList::IsEmpty() const { return m_symbol_contexts.empty(); }
+
uint32_t SymbolContextList::NumLineEntriesWithLine(uint32_t line) const {
uint32_t match_count = 0;
const size_t size = m_symbol_contexts.size();
diff --git a/source/Symbol/SymbolFile.cpp b/source/Symbol/SymbolFile.cpp
index 77ab2223ec07..c4f3a9c1a8c8 100644
--- a/source/Symbol/SymbolFile.cpp
+++ b/source/Symbol/SymbolFile.cpp
@@ -10,6 +10,7 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
+#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/TypeMap.h"
#include "lldb/Symbol/TypeSystem.h"
@@ -21,6 +22,7 @@
#include <future>
using namespace lldb_private;
+using namespace lldb;
void SymbolFile::PreloadSymbols() {
// No-op for most implementations.
@@ -29,21 +31,24 @@ void SymbolFile::PreloadSymbols() {
std::recursive_mutex &SymbolFile::GetModuleMutex() const {
return GetObjectFile()->GetModule()->GetMutex();
}
+ObjectFile *SymbolFile::GetMainObjectFile() {
+ return m_objfile_sp->GetModule()->GetObjectFile();
+}
-SymbolFile *SymbolFile::FindPlugin(ObjectFile *obj_file) {
+SymbolFile *SymbolFile::FindPlugin(ObjectFileSP objfile_sp) {
std::unique_ptr<SymbolFile> best_symfile_up;
- if (obj_file != nullptr) {
+ if (objfile_sp != nullptr) {
// We need to test the abilities of this section list. So create what it
- // would be with this new obj_file.
- lldb::ModuleSP module_sp(obj_file->GetModule());
+ // would be with this new objfile_sp.
+ lldb::ModuleSP module_sp(objfile_sp->GetModule());
if (module_sp) {
// Default to the main module section list.
ObjectFile *module_obj_file = module_sp->GetObjectFile();
- if (module_obj_file != obj_file) {
+ if (module_obj_file != objfile_sp.get()) {
// Make sure the main object file's sections are created
module_obj_file->GetSectionList();
- obj_file->CreateSections(*module_sp->GetUnifiedSectionList());
+ objfile_sp->CreateSections(*module_sp->GetUnifiedSectionList());
}
}
@@ -57,7 +62,7 @@ SymbolFile *SymbolFile::FindPlugin(ObjectFile *obj_file) {
(create_callback = PluginManager::GetSymbolFileCreateCallbackAtIndex(
idx)) != nullptr;
++idx) {
- std::unique_ptr<SymbolFile> curr_symfile_up(create_callback(obj_file));
+ std::unique_ptr<SymbolFile> curr_symfile_up(create_callback(objfile_sp));
if (curr_symfile_up) {
const uint32_t sym_file_abilities = curr_symfile_up->GetAbilities();
@@ -80,18 +85,14 @@ SymbolFile *SymbolFile::FindPlugin(ObjectFile *obj_file) {
return best_symfile_up.release();
}
-TypeList *SymbolFile::GetTypeList() {
- if (m_obj_file)
- return m_obj_file->GetModule()->GetTypeList();
- return nullptr;
-}
-
-TypeSystem *SymbolFile::GetTypeSystemForLanguage(lldb::LanguageType language) {
- TypeSystem *type_system =
- m_obj_file->GetModule()->GetTypeSystemForLanguage(language);
- if (type_system)
- type_system->SetSymbolFile(this);
- return type_system;
+llvm::Expected<TypeSystem &>
+SymbolFile::GetTypeSystemForLanguage(lldb::LanguageType language) {
+ auto type_system_or_err =
+ m_objfile_sp->GetModule()->GetTypeSystemForLanguage(language);
+ if (type_system_or_err) {
+ type_system_or_err->SetSymbolFile(this);
+ }
+ return type_system_or_err;
}
uint32_t SymbolFile::ResolveSymbolContext(const FileSpec &file_spec,
@@ -101,36 +102,24 @@ uint32_t SymbolFile::ResolveSymbolContext(const FileSpec &file_spec,
return 0;
}
-uint32_t
-SymbolFile::FindGlobalVariables(ConstString name,
- const CompilerDeclContext *parent_decl_ctx,
- uint32_t max_matches, VariableList &variables) {
- return 0;
-}
+void SymbolFile::FindGlobalVariables(ConstString name,
+ const CompilerDeclContext *parent_decl_ctx,
+ uint32_t max_matches,
+ VariableList &variables) {}
-uint32_t SymbolFile::FindGlobalVariables(const RegularExpression &regex,
- uint32_t max_matches,
- VariableList &variables) {
- return 0;
-}
+void SymbolFile::FindGlobalVariables(const RegularExpression &regex,
+ uint32_t max_matches,
+ VariableList &variables) {}
-uint32_t SymbolFile::FindFunctions(ConstString name,
- const CompilerDeclContext *parent_decl_ctx,
- lldb::FunctionNameType name_type_mask,
- bool include_inlines, bool append,
- SymbolContextList &sc_list) {
- if (!append)
- sc_list.Clear();
- return 0;
-}
+void SymbolFile::FindFunctions(ConstString name,
+ const CompilerDeclContext *parent_decl_ctx,
+ lldb::FunctionNameType name_type_mask,
+ bool include_inlines,
+ SymbolContextList &sc_list) {}
-uint32_t SymbolFile::FindFunctions(const RegularExpression &regex,
- bool include_inlines, bool append,
- SymbolContextList &sc_list) {
- if (!append)
- sc_list.Clear();
- return 0;
-}
+void SymbolFile::FindFunctions(const RegularExpression &regex,
+ bool include_inlines,
+ SymbolContextList &sc_list) {}
void SymbolFile::GetMangledNamesForFunction(
const std::string &scope_qualified_name,
@@ -138,22 +127,14 @@ void SymbolFile::GetMangledNamesForFunction(
return;
}
-uint32_t SymbolFile::FindTypes(
+void SymbolFile::FindTypes(
ConstString name, const CompilerDeclContext *parent_decl_ctx,
- bool append, uint32_t max_matches,
+ uint32_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
- TypeMap &types) {
- if (!append)
- types.Clear();
- return 0;
-}
+ TypeMap &types) {}
-size_t SymbolFile::FindTypes(const std::vector<CompilerContext> &context,
- bool append, TypeMap &types) {
- if (!append)
- types.Clear();
- return 0;
-}
+void SymbolFile::FindTypes(llvm::ArrayRef<CompilerContext> pattern,
+ LanguageSet languages, TypeMap &types) {}
void SymbolFile::AssertModuleLock() {
// The code below is too expensive to leave enabled in release builds. It's
@@ -169,4 +150,85 @@ void SymbolFile::AssertModuleLock() {
#endif
}
+uint32_t SymbolFile::GetNumCompileUnits() {
+ std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
+ if (!m_compile_units) {
+ // Create an array of compile unit shared pointers -- which will each
+ // remain NULL until someone asks for the actual compile unit information.
+ m_compile_units.emplace(CalculateNumCompileUnits());
+ }
+ return m_compile_units->size();
+}
+
+CompUnitSP SymbolFile::GetCompileUnitAtIndex(uint32_t idx) {
+ std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
+ uint32_t num = GetNumCompileUnits();
+ if (idx >= num)
+ return nullptr;
+ lldb::CompUnitSP &cu_sp = (*m_compile_units)[idx];
+ if (!cu_sp)
+ cu_sp = ParseCompileUnitAtIndex(idx);
+ return cu_sp;
+}
+
+void SymbolFile::SetCompileUnitAtIndex(uint32_t idx, const CompUnitSP &cu_sp) {
+ std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
+ const size_t num_compile_units = GetNumCompileUnits();
+ assert(idx < num_compile_units);
+ (void)num_compile_units;
+
+ // Fire off an assertion if this compile unit already exists for now. The
+ // partial parsing should take care of only setting the compile unit
+ // once, so if this assertion fails, we need to make sure that we don't
+ // have a race condition, or have a second parse of the same compile
+ // unit.
+ assert((*m_compile_units)[idx] == nullptr);
+ (*m_compile_units)[idx] = cu_sp;
+}
+
+Symtab *SymbolFile::GetSymtab() {
+ std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
+ if (m_symtab)
+ return m_symtab;
+
+ // Fetch the symtab from the main object file.
+ m_symtab = GetMainObjectFile()->GetSymtab();
+
+ // Then add our symbols to it.
+ if (m_symtab)
+ AddSymbols(*m_symtab);
+
+ return m_symtab;
+}
+
+void SymbolFile::SectionFileAddressesChanged() {
+ ObjectFile *module_objfile = GetMainObjectFile();
+ ObjectFile *symfile_objfile = GetObjectFile();
+ if (symfile_objfile != module_objfile)
+ symfile_objfile->SectionFileAddressesChanged();
+ if (m_symtab)
+ m_symtab->SectionFileAddressesChanged();
+}
+
+void SymbolFile::Dump(Stream &s) {
+ s.Format("SymbolFile {0} ({1})\n", GetPluginName(),
+ GetMainObjectFile()->GetFileSpec());
+ s.PutCString("Types:\n");
+ m_type_list.Dump(&s, /*show_context*/ false);
+ s.PutChar('\n');
+
+ s.PutCString("Compile units:\n");
+ if (m_compile_units) {
+ for (const CompUnitSP &cu_sp : *m_compile_units) {
+ // We currently only dump the compile units that have been parsed
+ if (cu_sp)
+ cu_sp->Dump(&s, /*show_context*/ false);
+ }
+ }
+ s.PutChar('\n');
+
+ if (Symtab *symtab = GetSymtab())
+ symtab->Dump(&s, nullptr, eSortOrderNone);
+}
+
SymbolFile::RegisterInfoResolver::~RegisterInfoResolver() = default;
diff --git a/source/Symbol/SymbolVendor.cpp b/source/Symbol/SymbolVendor.cpp
index b9f3a5fe3926..1e1dea71d7f3 100644
--- a/source/Symbol/SymbolVendor.cpp
+++ b/source/Symbol/SymbolVendor.cpp
@@ -58,8 +58,7 @@ SymbolVendor *SymbolVendor::FindPlugin(const lldb::ModuleSP &module_sp,
// SymbolVendor constructor
SymbolVendor::SymbolVendor(const lldb::ModuleSP &module_sp)
- : ModuleChild(module_sp), m_type_list(), m_compile_units(), m_sym_file_up(),
- m_symtab() {}
+ : ModuleChild(module_sp), m_sym_file_up() {}
// Destructor
SymbolVendor::~SymbolVendor() {}
@@ -69,414 +68,8 @@ void SymbolVendor::AddSymbolFileRepresentation(const ObjectFileSP &objfile_sp) {
ModuleSP module_sp(GetModule());
if (module_sp) {
std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (objfile_sp) {
- m_objfile_sp = objfile_sp;
- m_sym_file_up.reset(SymbolFile::FindPlugin(objfile_sp.get()));
- }
- }
-}
-
-bool SymbolVendor::SetCompileUnitAtIndex(size_t idx, const CompUnitSP &cu_sp) {
- ModuleSP module_sp(GetModule());
- if (module_sp) {
- std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- const size_t num_compile_units = GetNumCompileUnits();
- if (idx < num_compile_units) {
- // Fire off an assertion if this compile unit already exists for now. The
- // partial parsing should take care of only setting the compile unit
- // once, so if this assertion fails, we need to make sure that we don't
- // have a race condition, or have a second parse of the same compile
- // unit.
- assert(m_compile_units[idx].get() == nullptr);
- m_compile_units[idx] = cu_sp;
- return true;
- } else {
- // This should NOT happen, and if it does, we want to crash and know
- // about it
- assert(idx < num_compile_units);
- }
- }
- return false;
-}
-
-size_t SymbolVendor::GetNumCompileUnits() {
- ModuleSP module_sp(GetModule());
- if (module_sp) {
- std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_compile_units.empty()) {
- if (m_sym_file_up) {
- // Resize our array of compile unit shared pointers -- which will each
- // remain NULL until someone asks for the actual compile unit
- // information. When this happens, the symbol file will be asked to
- // parse this compile unit information.
- m_compile_units.resize(m_sym_file_up->GetNumCompileUnits());
- }
- }
- }
- return m_compile_units.size();
-}
-
-lldb::LanguageType SymbolVendor::ParseLanguage(CompileUnit &comp_unit) {
- ModuleSP module_sp(GetModule());
- if (module_sp) {
- std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_sym_file_up)
- return m_sym_file_up->ParseLanguage(comp_unit);
- }
- return eLanguageTypeUnknown;
-}
-
-size_t SymbolVendor::ParseFunctions(CompileUnit &comp_unit) {
- ModuleSP module_sp(GetModule());
- if (module_sp) {
- std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_sym_file_up)
- return m_sym_file_up->ParseFunctions(comp_unit);
- }
- return 0;
-}
-
-bool SymbolVendor::ParseLineTable(CompileUnit &comp_unit) {
- ModuleSP module_sp(GetModule());
- if (module_sp) {
- std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_sym_file_up)
- return m_sym_file_up->ParseLineTable(comp_unit);
- }
- return false;
-}
-
-bool SymbolVendor::ParseDebugMacros(CompileUnit &comp_unit) {
- ModuleSP module_sp(GetModule());
- if (module_sp) {
- std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_sym_file_up)
- return m_sym_file_up->ParseDebugMacros(comp_unit);
- }
- return false;
-}
-bool SymbolVendor::ParseSupportFiles(CompileUnit &comp_unit,
- FileSpecList &support_files) {
- ModuleSP module_sp(GetModule());
- if (module_sp) {
- std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_sym_file_up)
- return m_sym_file_up->ParseSupportFiles(comp_unit, support_files);
- }
- return false;
-}
-
-bool SymbolVendor::ParseIsOptimized(CompileUnit &comp_unit) {
- ModuleSP module_sp(GetModule());
- if (module_sp) {
- std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_sym_file_up)
- return m_sym_file_up->ParseIsOptimized(comp_unit);
- }
- return false;
-}
-
-bool SymbolVendor::ParseImportedModules(
- const SymbolContext &sc, std::vector<SourceModule> &imported_modules) {
- ModuleSP module_sp(GetModule());
- if (module_sp) {
- std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_sym_file_up)
- return m_sym_file_up->ParseImportedModules(sc, imported_modules);
- }
- return false;
-}
-
-size_t SymbolVendor::ParseBlocksRecursive(Function &func) {
- ModuleSP module_sp(GetModule());
- if (module_sp) {
- std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_sym_file_up)
- return m_sym_file_up->ParseBlocksRecursive(func);
- }
- return 0;
-}
-
-size_t SymbolVendor::ParseTypes(CompileUnit &comp_unit) {
- ModuleSP module_sp(GetModule());
- if (module_sp) {
- std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_sym_file_up)
- return m_sym_file_up->ParseTypes(comp_unit);
- }
- return 0;
-}
-
-size_t SymbolVendor::ParseVariablesForContext(const SymbolContext &sc) {
- ModuleSP module_sp(GetModule());
- if (module_sp) {
- std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_sym_file_up)
- return m_sym_file_up->ParseVariablesForContext(sc);
- }
- return 0;
-}
-
-Type *SymbolVendor::ResolveTypeUID(lldb::user_id_t type_uid) {
- ModuleSP module_sp(GetModule());
- if (module_sp) {
- std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_sym_file_up)
- return m_sym_file_up->ResolveTypeUID(type_uid);
- }
- return nullptr;
-}
-
-uint32_t SymbolVendor::ResolveSymbolContext(const Address &so_addr,
- SymbolContextItem resolve_scope,
- SymbolContext &sc) {
- ModuleSP module_sp(GetModule());
- if (module_sp) {
- std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_sym_file_up)
- return m_sym_file_up->ResolveSymbolContext(so_addr, resolve_scope, sc);
- }
- return 0;
-}
-
-uint32_t SymbolVendor::ResolveSymbolContext(const FileSpec &file_spec,
- uint32_t line, bool check_inlines,
- SymbolContextItem resolve_scope,
- SymbolContextList &sc_list) {
- ModuleSP module_sp(GetModule());
- if (module_sp) {
- std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_sym_file_up)
- return m_sym_file_up->ResolveSymbolContext(file_spec, line, check_inlines,
- resolve_scope, sc_list);
- }
- return 0;
-}
-
-size_t
-SymbolVendor::FindGlobalVariables(ConstString name,
- const CompilerDeclContext *parent_decl_ctx,
- size_t max_matches, VariableList &variables) {
- ModuleSP module_sp(GetModule());
- if (module_sp) {
- std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_sym_file_up)
- return m_sym_file_up->FindGlobalVariables(name, parent_decl_ctx,
- max_matches, variables);
- }
- return 0;
-}
-
-size_t SymbolVendor::FindGlobalVariables(const RegularExpression &regex,
- size_t max_matches,
- VariableList &variables) {
- ModuleSP module_sp(GetModule());
- if (module_sp) {
- std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_sym_file_up)
- return m_sym_file_up->FindGlobalVariables(regex, max_matches, variables);
- }
- return 0;
-}
-
-size_t SymbolVendor::FindFunctions(ConstString name,
- const CompilerDeclContext *parent_decl_ctx,
- FunctionNameType name_type_mask,
- bool include_inlines, bool append,
- SymbolContextList &sc_list) {
- ModuleSP module_sp(GetModule());
- if (module_sp) {
- std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_sym_file_up)
- return m_sym_file_up->FindFunctions(name, parent_decl_ctx, name_type_mask,
- include_inlines, append, sc_list);
- }
- return 0;
-}
-
-size_t SymbolVendor::FindFunctions(const RegularExpression &regex,
- bool include_inlines, bool append,
- SymbolContextList &sc_list) {
- ModuleSP module_sp(GetModule());
- if (module_sp) {
- std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_sym_file_up)
- return m_sym_file_up->FindFunctions(regex, include_inlines, append,
- sc_list);
- }
- return 0;
-}
-
-size_t SymbolVendor::FindTypes(
- ConstString name, const CompilerDeclContext *parent_decl_ctx,
- bool append, size_t max_matches,
- llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
- TypeMap &types) {
- ModuleSP module_sp(GetModule());
- if (module_sp) {
- std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_sym_file_up)
- return m_sym_file_up->FindTypes(name, parent_decl_ctx, append,
- max_matches, searched_symbol_files,
- types);
- }
- if (!append)
- types.Clear();
- return 0;
-}
-
-size_t SymbolVendor::FindTypes(const std::vector<CompilerContext> &context,
- bool append, TypeMap &types) {
- ModuleSP module_sp(GetModule());
- if (module_sp) {
- std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_sym_file_up)
- return m_sym_file_up->FindTypes(context, append, types);
- }
- if (!append)
- types.Clear();
- return 0;
-}
-
-size_t SymbolVendor::GetTypes(SymbolContextScope *sc_scope, TypeClass type_mask,
- lldb_private::TypeList &type_list) {
- ModuleSP module_sp(GetModule());
- if (module_sp) {
- std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_sym_file_up)
- return m_sym_file_up->GetTypes(sc_scope, type_mask, type_list);
- }
- return 0;
-}
-
-CompilerDeclContext
-SymbolVendor::FindNamespace(ConstString name,
- const CompilerDeclContext *parent_decl_ctx) {
- CompilerDeclContext namespace_decl_ctx;
- ModuleSP module_sp(GetModule());
- if (module_sp) {
- std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_sym_file_up)
- namespace_decl_ctx = m_sym_file_up->FindNamespace(name, parent_decl_ctx);
- }
- return namespace_decl_ctx;
-}
-
-void SymbolVendor::Dump(Stream *s) {
- ModuleSP module_sp(GetModule());
- if (module_sp) {
- std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
-
- bool show_context = false;
-
- s->Printf("%p: ", static_cast<void *>(this));
- s->Indent();
- s->PutCString("SymbolVendor");
- if (m_sym_file_up) {
- *s << " " << m_sym_file_up->GetPluginName();
- ObjectFile *objfile = m_sym_file_up->GetObjectFile();
- if (objfile) {
- const FileSpec &objfile_file_spec = objfile->GetFileSpec();
- if (objfile_file_spec) {
- s->PutCString(" (");
- objfile_file_spec.Dump(s);
- s->PutChar(')');
- }
- }
- }
- s->EOL();
- if (m_sym_file_up)
- m_sym_file_up->Dump(*s);
- s->IndentMore();
- m_type_list.Dump(s, show_context);
-
- CompileUnitConstIter cu_pos, cu_end;
- cu_end = m_compile_units.end();
- for (cu_pos = m_compile_units.begin(); cu_pos != cu_end; ++cu_pos) {
- // We currently only dump the compile units that have been parsed
- if (*cu_pos)
- (*cu_pos)->Dump(s, show_context);
- }
-
- if (Symtab *symtab = GetSymtab())
- symtab->Dump(s, nullptr, eSortOrderNone);
-
- s->IndentLess();
- }
-}
-
-CompUnitSP SymbolVendor::GetCompileUnitAtIndex(size_t idx) {
- CompUnitSP cu_sp;
- ModuleSP module_sp(GetModule());
- if (module_sp) {
- std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- const size_t num_compile_units = GetNumCompileUnits();
- if (idx < num_compile_units) {
- cu_sp = m_compile_units[idx];
- if (cu_sp.get() == nullptr) {
- m_compile_units[idx] = m_sym_file_up->ParseCompileUnitAtIndex(idx);
- cu_sp = m_compile_units[idx];
- }
- }
- }
- return cu_sp;
-}
-
-FileSpec SymbolVendor::GetMainFileSpec() const {
- if (m_sym_file_up) {
- const ObjectFile *symfile_objfile = m_sym_file_up->GetObjectFile();
- if (symfile_objfile)
- return symfile_objfile->GetFileSpec();
- }
-
- return FileSpec();
-}
-
-Symtab *SymbolVendor::GetSymtab() {
- ModuleSP module_sp(GetModule());
- if (!module_sp)
- return nullptr;
-
- std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
-
- if (m_symtab)
- return m_symtab;
-
- ObjectFile *objfile = module_sp->GetObjectFile();
- if (!objfile)
- return nullptr;
-
- m_symtab = objfile->GetSymtab();
- if (m_symtab && m_sym_file_up)
- m_sym_file_up->AddSymbols(*m_symtab);
-
- return m_symtab;
-}
-
-void SymbolVendor::ClearSymtab() {
- ModuleSP module_sp(GetModule());
- if (module_sp) {
- ObjectFile *objfile = module_sp->GetObjectFile();
- if (objfile) {
- // Clear symbol table from unified section list.
- objfile->ClearSymtab();
- }
- }
-}
-
-void SymbolVendor::SectionFileAddressesChanged() {
- ModuleSP module_sp(GetModule());
- if (module_sp) {
- ObjectFile *module_objfile = module_sp->GetObjectFile();
- if (m_sym_file_up) {
- ObjectFile *symfile_objfile = m_sym_file_up->GetObjectFile();
- if (symfile_objfile != module_objfile)
- symfile_objfile->SectionFileAddressesChanged();
- }
- Symtab *symtab = GetSymtab();
- if (symtab) {
- symtab->SectionFileAddressesChanged();
- }
+ if (objfile_sp)
+ m_sym_file_up.reset(SymbolFile::FindPlugin(objfile_sp));
}
}
diff --git a/source/Symbol/Symtab.cpp b/source/Symbol/Symtab.cpp
index 29c390e83878..c4e6c2ccfb09 100644
--- a/source/Symbol/Symtab.cpp
+++ b/source/Symbol/Symtab.cpp
@@ -738,7 +738,7 @@ Symbol *Symtab::FindSymbolWithType(SymbolType symbol_type,
return nullptr;
}
-size_t
+void
Symtab::FindAllSymbolsWithNameAndType(ConstString name,
SymbolType symbol_type,
std::vector<uint32_t> &symbol_indexes) {
@@ -756,10 +756,9 @@ Symtab::FindAllSymbolsWithNameAndType(ConstString name,
// the symbols and match the symbol_type if any was given.
AppendSymbolIndexesWithNameAndType(name, symbol_type, symbol_indexes);
}
- return symbol_indexes.size();
}
-size_t Symtab::FindAllSymbolsWithNameAndType(
+void Symtab::FindAllSymbolsWithNameAndType(
ConstString name, SymbolType symbol_type, Debug symbol_debug_type,
Visibility symbol_visibility, std::vector<uint32_t> &symbol_indexes) {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
@@ -777,10 +776,9 @@ size_t Symtab::FindAllSymbolsWithNameAndType(
AppendSymbolIndexesWithNameAndType(name, symbol_type, symbol_debug_type,
symbol_visibility, symbol_indexes);
}
- return symbol_indexes.size();
}
-size_t Symtab::FindAllSymbolsMatchingRexExAndType(
+void Symtab::FindAllSymbolsMatchingRexExAndType(
const RegularExpression &regex, SymbolType symbol_type,
Debug symbol_debug_type, Visibility symbol_visibility,
std::vector<uint32_t> &symbol_indexes) {
@@ -788,7 +786,6 @@ size_t Symtab::FindAllSymbolsMatchingRexExAndType(
AppendSymbolIndexesMatchingRegExAndType(regex, symbol_type, symbol_debug_type,
symbol_visibility, symbol_indexes);
- return symbol_indexes.size();
}
Symbol *Symtab::FindFirstSymbolWithNameAndType(ConstString name,
@@ -1024,10 +1021,8 @@ void Symtab::SymbolIndicesToSymbolContextList(
}
}
-size_t Symtab::FindFunctionSymbols(ConstString name,
- uint32_t name_type_mask,
- SymbolContextList &sc_list) {
- size_t count = 0;
+void Symtab::FindFunctionSymbols(ConstString name, uint32_t name_type_mask,
+ SymbolContextList &sc_list) {
std::vector<uint32_t> symbol_indexes;
// eFunctionNameTypeAuto should be pre-resolved by a call to
@@ -1108,11 +1103,8 @@ size_t Symtab::FindFunctionSymbols(ConstString name,
symbol_indexes.erase(
std::unique(symbol_indexes.begin(), symbol_indexes.end()),
symbol_indexes.end());
- count = symbol_indexes.size();
SymbolIndicesToSymbolContextList(symbol_indexes, sc_list);
}
-
- return count;
}
const Symbol *Symtab::GetParent(Symbol *child_symbol) const {
diff --git a/source/Symbol/Type.cpp b/source/Symbol/Type.cpp
index 4ee8330ce288..5666590c2246 100644
--- a/source/Symbol/Type.cpp
+++ b/source/Symbol/Type.cpp
@@ -11,6 +11,7 @@
#include "lldb/Core/Module.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Log.h"
#include "lldb/Utility/Scalar.h"
#include "lldb/Utility/StreamString.h"
@@ -29,15 +30,41 @@
#include "llvm/ADT/StringRef.h"
-#include "clang/AST/Decl.h"
-#include "clang/AST/DeclObjC.h"
-
using namespace lldb;
using namespace lldb_private;
+bool lldb_private::contextMatches(llvm::ArrayRef<CompilerContext> context_chain,
+ llvm::ArrayRef<CompilerContext> pattern) {
+ auto ctx = context_chain.begin();
+ auto ctx_end = context_chain.end();
+ for (const CompilerContext &pat : pattern) {
+ // Early exit if the pattern is too long.
+ if (ctx == ctx_end)
+ return false;
+ if (*ctx != pat) {
+ // Skip any number of module matches.
+ if (pat.kind == CompilerContextKind::AnyModule) {
+ // Greedily match 0..n modules.
+ ctx = std::find_if(ctx, ctx_end, [](const CompilerContext &ctx) {
+ return ctx.kind != CompilerContextKind::Module;
+ });
+ continue;
+ }
+ // See if there is a kind mismatch; they should have 1 bit in common.
+ if (((uint16_t)ctx->kind & (uint16_t)pat.kind) == 0)
+ return false;
+ // The name is ignored for AnyModule, but not for AnyType.
+ if (pat.kind != CompilerContextKind::AnyModule && ctx->name != pat.name)
+ return false;
+ }
+ ++ctx;
+ }
+ return true;
+}
+
void CompilerContext::Dump() const {
- switch (type) {
- case CompilerContextKind::Invalid:
+ switch (kind) {
+ default:
printf("Invalid");
break;
case CompilerContextKind::TranslationUnit:
@@ -52,7 +79,7 @@ void CompilerContext::Dump() const {
case CompilerContextKind::Class:
printf("Class");
break;
- case CompilerContextKind::Structure:
+ case CompilerContextKind::Struct:
printf("Structure");
break;
case CompilerContextKind::Union:
@@ -64,12 +91,18 @@ void CompilerContext::Dump() const {
case CompilerContextKind::Variable:
printf("Variable");
break;
- case CompilerContextKind::Enumeration:
+ case CompilerContextKind::Enum:
printf("Enumeration");
break;
case CompilerContextKind::Typedef:
printf("Typedef");
break;
+ case CompilerContextKind::AnyModule:
+ printf("AnyModule");
+ break;
+ case CompilerContextKind::AnyType:
+ printf("AnyType");
+ break;
}
printf("(\"%s\")\n", name.GetCString());
}
@@ -425,8 +458,6 @@ bool Type::WriteToMemory(ExecutionContext *exe_ctx, lldb::addr_t addr,
return false;
}
-TypeList *Type::GetTypeList() { return GetSymbolFile()->GetTypeList(); }
-
const Declaration &Type::GetDeclaration() const { return m_decl; }
bool Type::ResolveClangType(ResolveState compiler_type_resolve_state) {
@@ -488,47 +519,54 @@ bool Type::ResolveClangType(ResolveState compiler_type_resolve_state) {
}
} else {
// We have no encoding type, return void?
- TypeSystem *type_system =
+ auto type_system_or_err =
m_symbol_file->GetTypeSystemForLanguage(eLanguageTypeC);
- CompilerType void_compiler_type =
- type_system->GetBasicTypeFromAST(eBasicTypeVoid);
- switch (m_encoding_uid_type) {
- case eEncodingIsUID:
- m_compiler_type = void_compiler_type;
- break;
+ if (auto err = type_system_or_err.takeError()) {
+ LLDB_LOG_ERROR(
+ lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_SYMBOLS),
+ std::move(err),
+ "Unable to construct void type from ClangASTContext");
+ } else {
+ CompilerType void_compiler_type =
+ type_system_or_err->GetBasicTypeFromAST(eBasicTypeVoid);
+ switch (m_encoding_uid_type) {
+ case eEncodingIsUID:
+ m_compiler_type = void_compiler_type;
+ break;
- case eEncodingIsConstUID:
- m_compiler_type = void_compiler_type.AddConstModifier();
- break;
+ case eEncodingIsConstUID:
+ m_compiler_type = void_compiler_type.AddConstModifier();
+ break;
- case eEncodingIsRestrictUID:
- m_compiler_type = void_compiler_type.AddRestrictModifier();
- break;
+ case eEncodingIsRestrictUID:
+ m_compiler_type = void_compiler_type.AddRestrictModifier();
+ break;
- case eEncodingIsVolatileUID:
- m_compiler_type = void_compiler_type.AddVolatileModifier();
- break;
+ case eEncodingIsVolatileUID:
+ m_compiler_type = void_compiler_type.AddVolatileModifier();
+ break;
- case eEncodingIsTypedefUID:
- m_compiler_type = void_compiler_type.CreateTypedef(
- m_name.AsCString("__lldb_invalid_typedef_name"),
- GetSymbolFile()->GetDeclContextContainingUID(GetID()));
- break;
+ case eEncodingIsTypedefUID:
+ m_compiler_type = void_compiler_type.CreateTypedef(
+ m_name.AsCString("__lldb_invalid_typedef_name"),
+ GetSymbolFile()->GetDeclContextContainingUID(GetID()));
+ break;
- case eEncodingIsPointerUID:
- m_compiler_type = void_compiler_type.GetPointerType();
- break;
+ case eEncodingIsPointerUID:
+ m_compiler_type = void_compiler_type.GetPointerType();
+ break;
- case eEncodingIsLValueReferenceUID:
- m_compiler_type = void_compiler_type.GetLValueReferenceType();
- break;
+ case eEncodingIsLValueReferenceUID:
+ m_compiler_type = void_compiler_type.GetLValueReferenceType();
+ break;
- case eEncodingIsRValueReferenceUID:
- m_compiler_type = void_compiler_type.GetRValueReferenceType();
- break;
+ case eEncodingIsRValueReferenceUID:
+ m_compiler_type = void_compiler_type.GetRValueReferenceType();
+ break;
- default:
- llvm_unreachable("Unhandled encoding_data_type.");
+ default:
+ llvm_unreachable("Unhandled encoding_data_type.");
+ }
}
}
diff --git a/source/Symbol/TypeMap.cpp b/source/Symbol/TypeMap.cpp
index bc6e272449f0..4ee1026bed24 100644
--- a/source/Symbol/TypeMap.cpp
+++ b/source/Symbol/TypeMap.cpp
@@ -8,18 +8,6 @@
#include <vector>
-#include "clang/AST/ASTConsumer.h"
-#include "clang/AST/ASTContext.h"
-#include "clang/AST/Decl.h"
-#include "clang/AST/DeclCXX.h"
-#include "clang/AST/DeclGroup.h"
-
-#include "clang/Basic/Builtins.h"
-#include "clang/Basic/IdentifierTable.h"
-#include "clang/Basic/LangOptions.h"
-#include "clang/Basic/SourceManager.h"
-#include "clang/Basic/TargetInfo.h"
-
#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/raw_ostream.h"
@@ -30,7 +18,6 @@
using namespace lldb;
using namespace lldb_private;
-using namespace clang;
TypeMap::TypeMap() : m_types() {}
diff --git a/source/Symbol/TypeSystem.cpp b/source/Symbol/TypeSystem.cpp
index fb9c8e71acb3..c63f24aea335 100644
--- a/source/Symbol/TypeSystem.cpp
+++ b/source/Symbol/TypeSystem.cpp
@@ -20,10 +20,29 @@
#include "lldb/Core/PluginManager.h"
#include "lldb/Symbol/CompilerType.h"
+#include "lldb/Target/Language.h"
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 g_num_small_bitvector_bits = 64 - 8;
+static_assert(eNumLanguageTypes < g_num_small_bitvector_bits,
+ "Languages bit vector is no longer small on 64 bit systems");
+LanguageSet::LanguageSet() : bitvector(eNumLanguageTypes, 0) {}
+
+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() {}
@@ -198,65 +217,140 @@ void TypeSystemMap::ForEach(std::function<bool(TypeSystem *)> const &callback) {
}
}
-TypeSystem *TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType language,
- Module *module,
- bool can_create) {
+llvm::Expected<TypeSystem &>
+TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType language,
+ Module *module, bool can_create) {
+ llvm::Error error = llvm::Error::success();
+ assert(!error); // Check the success value when assertions are enabled
std::lock_guard<std::mutex> guard(m_mutex);
- collection::iterator pos = m_map.find(language);
- if (pos != m_map.end())
- return pos->second.get();
-
- for (const auto &pair : m_map) {
- if (pair.second && pair.second->SupportsLanguage(language)) {
- // Add a new mapping for "language" to point to an already existing
- // TypeSystem that supports this language
- AddToMap(language, pair.second);
- return pair.second.get();
+ if (m_clear_in_progress) {
+ error = llvm::make_error<llvm::StringError>(
+ "Unable to get TypeSystem because TypeSystemMap is being cleared",
+ llvm::inconvertibleErrorCode());
+ } else {
+ collection::iterator pos = m_map.find(language);
+ if (pos != m_map.end()) {
+ auto *type_system = pos->second.get();
+ if (type_system) {
+ llvm::consumeError(std::move(error));
+ return *type_system;
+ }
+ error = llvm::make_error<llvm::StringError>(
+ "TypeSystem for language " +
+ llvm::toStringRef(Language::GetNameForLanguageType(language)) +
+ " doesn't exist",
+ llvm::inconvertibleErrorCode());
+ return std::move(error);
}
- }
- if (!can_create)
- return nullptr;
+ for (const auto &pair : m_map) {
+ if (pair.second && pair.second->SupportsLanguage(language)) {
+ // Add a new mapping for "language" to point to an already existing
+ // TypeSystem that supports this language
+ m_map[language] = pair.second;
+ if (pair.second.get()) {
+ llvm::consumeError(std::move(error));
+ return *pair.second.get();
+ }
+ error = llvm::make_error<llvm::StringError>(
+ "TypeSystem for language " +
+ llvm::toStringRef(Language::GetNameForLanguageType(language)) +
+ " doesn't exist",
+ llvm::inconvertibleErrorCode());
+ return std::move(error);
+ }
+ }
+
+ if (!can_create) {
+ error = llvm::make_error<llvm::StringError>(
+ "Unable to find type system for language " +
+ llvm::toStringRef(Language::GetNameForLanguageType(language)),
+ llvm::inconvertibleErrorCode());
+ } else {
+ // Cache even if we get a shared pointer that contains a null type system
+ // back
+ auto type_system_sp = TypeSystem::CreateInstance(language, module);
+ m_map[language] = type_system_sp;
+ if (type_system_sp.get()) {
+ llvm::consumeError(std::move(error));
+ return *type_system_sp.get();
+ }
+ error = llvm::make_error<llvm::StringError>(
+ "TypeSystem for language " +
+ llvm::toStringRef(Language::GetNameForLanguageType(language)) +
+ " doesn't exist",
+ llvm::inconvertibleErrorCode());
+ }
+ }
- // Cache even if we get a shared pointer that contains null type system back
- lldb::TypeSystemSP type_system_sp =
- TypeSystem::CreateInstance(language, module);
- AddToMap(language, type_system_sp);
- return type_system_sp.get();
+ return std::move(error);
}
-TypeSystem *TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType language,
- Target *target,
- bool can_create) {
+llvm::Expected<TypeSystem &>
+TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType language,
+ Target *target, bool can_create) {
+ llvm::Error error = llvm::Error::success();
+ assert(!error); // Check the success value when assertions are enabled
std::lock_guard<std::mutex> guard(m_mutex);
- collection::iterator pos = m_map.find(language);
- if (pos != m_map.end())
- return pos->second.get();
+ if (m_clear_in_progress) {
+ error = llvm::make_error<llvm::StringError>(
+ "Unable to get TypeSystem because TypeSystemMap is being cleared",
+ llvm::inconvertibleErrorCode());
+ } else {
+ collection::iterator pos = m_map.find(language);
+ if (pos != m_map.end()) {
+ auto *type_system = pos->second.get();
+ if (type_system) {
+ llvm::consumeError(std::move(error));
+ return *type_system;
+ }
+ error = llvm::make_error<llvm::StringError>(
+ "TypeSystem for language " +
+ llvm::toStringRef(Language::GetNameForLanguageType(language)) +
+ " doesn't exist",
+ llvm::inconvertibleErrorCode());
+ return std::move(error);
+ }
- for (const auto &pair : m_map) {
- if (pair.second && pair.second->SupportsLanguage(language)) {
- // Add a new mapping for "language" to point to an already existing
- // TypeSystem that supports this language
+ for (const auto &pair : m_map) {
+ if (pair.second && pair.second->SupportsLanguage(language)) {
+ // Add a new mapping for "language" to point to an already existing
+ // TypeSystem that supports this language
+ m_map[language] = pair.second;
+ if (pair.second.get()) {
+ llvm::consumeError(std::move(error));
+ return *pair.second.get();
+ }
+ error = llvm::make_error<llvm::StringError>(
+ "TypeSystem for language " +
+ llvm::toStringRef(Language::GetNameForLanguageType(language)) +
+ " doesn't exist",
+ llvm::inconvertibleErrorCode());
+ return std::move(error);
+ }
+ }
- AddToMap(language, pair.second);
- return pair.second.get();
+ if (!can_create) {
+ error = llvm::make_error<llvm::StringError>(
+ "Unable to find type system for language " +
+ llvm::toStringRef(Language::GetNameForLanguageType(language)),
+ llvm::inconvertibleErrorCode());
+ } else {
+ // Cache even if we get a shared pointer that contains a null type system
+ // back
+ auto type_system_sp = TypeSystem::CreateInstance(language, target);
+ m_map[language] = type_system_sp;
+ if (type_system_sp.get()) {
+ llvm::consumeError(std::move(error));
+ return *type_system_sp.get();
+ }
+ error = llvm::make_error<llvm::StringError>(
+ "TypeSystem for language " +
+ llvm::toStringRef(Language::GetNameForLanguageType(language)) +
+ " doesn't exist",
+ llvm::inconvertibleErrorCode());
}
}
- if (!can_create)
- return nullptr;
-
- // Cache even if we get a shared pointer that contains null type system back
- lldb::TypeSystemSP type_system_sp;
- if (!m_clear_in_progress)
- type_system_sp = TypeSystem::CreateInstance(language, target);
-
- AddToMap(language, type_system_sp);
- return type_system_sp.get();
-}
-
-void TypeSystemMap::AddToMap(lldb::LanguageType language,
- lldb::TypeSystemSP const &type_system_sp) {
- if (!m_clear_in_progress)
- m_map[language] = type_system_sp;
+ return std::move(error);
}
diff --git a/source/Symbol/UnwindPlan.cpp b/source/Symbol/UnwindPlan.cpp
index 774f9cb587ee..15443ce5d8ac 100644
--- a/source/Symbol/UnwindPlan.cpp
+++ b/source/Symbol/UnwindPlan.cpp
@@ -170,7 +170,8 @@ operator==(const UnwindPlan::Row::FAValue &rhs) const {
if (m_type == rhs.m_type) {
switch (m_type) {
case unspecified:
- return true;
+ case isRaSearch:
+ return m_value.ra_search_offset == rhs.m_value.ra_search_offset;
case isRegisterPlusOffset:
return m_value.reg.offset == rhs.m_value.reg.offset;
@@ -205,9 +206,12 @@ void UnwindPlan::Row::FAValue::Dump(Stream &s, const UnwindPlan *unwind_plan,
llvm::makeArrayRef(m_value.expr.opcodes, m_value.expr.length),
thread);
break;
- default:
+ case unspecified:
s.PutCString("unspecified");
break;
+ case isRaSearch:
+ s.Printf("RaSearch@SP%+d", m_value.ra_search_offset);
+ break;
}
}
@@ -402,10 +406,10 @@ const UnwindPlan::RowSP UnwindPlan::GetRowAtIndex(uint32_t idx) const {
return m_row_list[idx];
else {
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_UNWIND));
- if (log)
- log->Printf("error: UnwindPlan::GetRowAtIndex(idx = %u) invalid index "
- "(number rows is %u)",
- idx, (uint32_t)m_row_list.size());
+ LLDB_LOGF(log,
+ "error: UnwindPlan::GetRowAtIndex(idx = %u) invalid index "
+ "(number rows is %u)",
+ idx, (uint32_t)m_row_list.size());
return UnwindPlan::RowSP();
}
}
@@ -413,8 +417,7 @@ const UnwindPlan::RowSP UnwindPlan::GetRowAtIndex(uint32_t idx) const {
const UnwindPlan::RowSP UnwindPlan::GetLastRow() const {
if (m_row_list.empty()) {
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_UNWIND));
- if (log)
- log->Printf("UnwindPlan::GetLastRow() when rows are empty");
+ LLDB_LOGF(log, "UnwindPlan::GetLastRow() when rows are empty");
return UnwindPlan::RowSP();
}
return m_row_list.back();
@@ -434,13 +437,14 @@ bool UnwindPlan::PlanValidAtAddress(Address addr) {
if (log) {
StreamString s;
if (addr.Dump(&s, nullptr, Address::DumpStyleSectionNameOffset)) {
- log->Printf("UnwindPlan is invalid -- no unwind rows for UnwindPlan "
- "'%s' at address %s",
- m_source_name.GetCString(), s.GetData());
+ LLDB_LOGF(log,
+ "UnwindPlan is invalid -- no unwind rows for UnwindPlan "
+ "'%s' at address %s",
+ m_source_name.GetCString(), s.GetData());
} else {
- log->Printf(
- "UnwindPlan is invalid -- no unwind rows for UnwindPlan '%s'",
- m_source_name.GetCString());
+ LLDB_LOGF(log,
+ "UnwindPlan is invalid -- no unwind rows for UnwindPlan '%s'",
+ m_source_name.GetCString());
}
}
return false;
@@ -456,13 +460,15 @@ bool UnwindPlan::PlanValidAtAddress(Address addr) {
if (log) {
StreamString s;
if (addr.Dump(&s, nullptr, Address::DumpStyleSectionNameOffset)) {
- log->Printf("UnwindPlan is invalid -- no CFA register defined in row 0 "
- "for UnwindPlan '%s' at address %s",
- m_source_name.GetCString(), s.GetData());
+ LLDB_LOGF(log,
+ "UnwindPlan is invalid -- no CFA register defined in row 0 "
+ "for UnwindPlan '%s' at address %s",
+ m_source_name.GetCString(), s.GetData());
} else {
- log->Printf("UnwindPlan is invalid -- no CFA register defined in row 0 "
- "for UnwindPlan '%s'",
- m_source_name.GetCString());
+ LLDB_LOGF(log,
+ "UnwindPlan is invalid -- no CFA register defined in row 0 "
+ "for UnwindPlan '%s'",
+ m_source_name.GetCString());
}
}
return false;
diff --git a/source/Symbol/UnwindTable.cpp b/source/Symbol/UnwindTable.cpp
index a8f451dc4643..045957a67b3b 100644
--- a/source/Symbol/UnwindTable.cpp
+++ b/source/Symbol/UnwindTable.cpp
@@ -13,6 +13,7 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/Section.h"
#include "lldb/Symbol/ArmUnwindInfo.h"
+#include "lldb/Symbol/CallFrameInfo.h"
#include "lldb/Symbol/CompactUnwindInfo.h"
#include "lldb/Symbol/DWARFCallFrameInfo.h"
#include "lldb/Symbol/FuncUnwinders.h"
@@ -29,7 +30,8 @@ using namespace lldb_private;
UnwindTable::UnwindTable(Module &module)
: m_module(module), m_unwinds(), m_initialized(false), m_mutex(),
- m_eh_frame_up(), m_compact_unwind_up(), m_arm_unwind_up() {}
+ m_object_file_unwind_up(), m_eh_frame_up(), m_compact_unwind_up(),
+ m_arm_unwind_up() {}
// We can't do some of this initialization when the ObjectFile is running its
// ctor; delay doing it until needed for something.
@@ -47,6 +49,8 @@ void UnwindTable::Initialize() {
if (!object_file)
return;
+ m_object_file_unwind_up = object_file->CreateCallFrameInfo();
+
SectionList *sl = m_module.GetSectionList();
if (!sl)
return;
@@ -83,7 +87,12 @@ llvm::Optional<AddressRange> UnwindTable::GetAddressRange(const Address &addr,
SymbolContext &sc) {
AddressRange range;
- // First check the symbol context
+ // First check the unwind info from the object file plugin
+ if (m_object_file_unwind_up &&
+ m_object_file_unwind_up->GetAddressRange(addr, range))
+ return range;
+
+ // Check the symbol context
if (sc.GetAddressRange(eSymbolContextFunction | eSymbolContextSymbol, 0,
false, range) &&
range.GetBaseAddress().IsValid())
@@ -162,6 +171,11 @@ void UnwindTable::Dump(Stream &s) {
s.EOL();
}
+lldb_private::CallFrameInfo *UnwindTable::GetObjectFileUnwindInfo() {
+ Initialize();
+ return m_object_file_unwind_up.get();
+}
+
DWARFCallFrameInfo *UnwindTable::GetEHFrameInfo() {
Initialize();
return m_eh_frame_up.get();
@@ -182,11 +196,7 @@ ArmUnwindInfo *UnwindTable::GetArmUnwindInfo() {
return m_arm_unwind_up.get();
}
-SymbolFile *UnwindTable::GetSymbolFile() {
- if (SymbolVendor *vendor = m_module.GetSymbolVendor())
- return vendor->GetSymbolFile();
- return nullptr;
-}
+SymbolFile *UnwindTable::GetSymbolFile() { return m_module.GetSymbolFile(); }
ArchSpec UnwindTable::GetArchitecture() { return m_module.GetArchitecture(); }
diff --git a/source/Symbol/Variable.cpp b/source/Symbol/Variable.cpp
index 29a7a5191f61..3f3d7c198f15 100644
--- a/source/Symbol/Variable.cpp
+++ b/source/Symbol/Variable.cpp
@@ -35,14 +35,12 @@
using namespace lldb;
using namespace lldb_private;
-// Variable constructor
-Variable::Variable(
- lldb::user_id_t uid, const char *name,
- const char *mangled, // The mangled or fully qualified name of the variable.
- const lldb::SymbolFileTypeSP &symfile_type_sp, ValueType scope,
- SymbolContextScope *context, const RangeList &scope_range,
- Declaration *decl_ptr, const DWARFExpression &location, bool external,
- bool artificial, bool static_member)
+Variable::Variable(lldb::user_id_t uid, const char *name, const char *mangled,
+ const lldb::SymbolFileTypeSP &symfile_type_sp,
+ ValueType scope, SymbolContextScope *context,
+ const RangeList &scope_range, Declaration *decl_ptr,
+ const DWARFExpression &location, bool external,
+ bool artificial, bool static_member)
: UserID(uid), m_name(name), m_mangled(ConstString(mangled)),
m_symfile_type_sp(symfile_type_sp), m_scope(scope),
m_owner_scope(context), m_scope_range(scope_range),
@@ -50,14 +48,22 @@ Variable::Variable(
m_artificial(artificial), m_loc_is_const_data(false),
m_static_member(static_member) {}
-// Destructor
Variable::~Variable() {}
lldb::LanguageType Variable::GetLanguage() const {
- SymbolContext variable_sc;
- m_owner_scope->CalculateSymbolContext(&variable_sc);
- if (variable_sc.comp_unit)
- return variable_sc.comp_unit->GetLanguage();
+ lldb::LanguageType lang = m_mangled.GuessLanguage();
+ if (lang != lldb::eLanguageTypeUnknown)
+ return lang;
+
+ if (auto *func = m_owner_scope->CalculateSymbolContextFunction()) {
+ if ((lang = func->GetLanguage()) != lldb::eLanguageTypeUnknown)
+ return lang;
+ } else if (auto *comp_unit =
+ m_owner_scope->CalculateSymbolContextCompileUnit()) {
+ if ((lang = comp_unit->GetLanguage()) != lldb::eLanguageTypeUnknown)
+ return lang;
+ }
+
return lldb::eLanguageTypeUnknown;
}
@@ -381,21 +387,15 @@ Status Variable::GetValuesForVariableExpressionPath(
default: {
static RegularExpression g_regex(
llvm::StringRef("^([A-Za-z_:][A-Za-z_0-9:]*)(.*)"));
- RegularExpression::Match regex_match(1);
- std::string variable_name;
+ llvm::SmallVector<llvm::StringRef, 2> matches;
variable_list.Clear();
- if (!g_regex.Execute(variable_expr_path, &regex_match)) {
- error.SetErrorStringWithFormat(
- "unable to extract a variable name from '%s'",
- variable_expr_path.str().c_str());
- return error;
- }
- if (!regex_match.GetMatchAtIndex(variable_expr_path, 1, variable_name)) {
+ if (!g_regex.Execute(variable_expr_path, &matches)) {
error.SetErrorStringWithFormat(
"unable to extract a variable name from '%s'",
variable_expr_path.str().c_str());
return error;
}
+ std::string variable_name = matches[1].str();
if (!callback(baton, variable_name.c_str(), variable_list)) {
error.SetErrorString("unknown error");
return error;
@@ -485,24 +485,21 @@ static void PrivateAutoComplete(
StackFrame *frame, llvm::StringRef partial_path,
const llvm::Twine
&prefix_path, // Anything that has been resolved already will be in here
- const CompilerType &compiler_type,
- StringList &matches, bool &word_complete);
+ const CompilerType &compiler_type, CompletionRequest &request);
static void PrivateAutoCompleteMembers(
StackFrame *frame, const std::string &partial_member_name,
llvm::StringRef partial_path,
const llvm::Twine
&prefix_path, // Anything that has been resolved already will be in here
- const CompilerType &compiler_type,
- StringList &matches, bool &word_complete);
+ const CompilerType &compiler_type, CompletionRequest &request);
static void PrivateAutoCompleteMembers(
StackFrame *frame, const std::string &partial_member_name,
llvm::StringRef partial_path,
const llvm::Twine
&prefix_path, // Anything that has been resolved already will be in here
- const CompilerType &compiler_type,
- StringList &matches, bool &word_complete) {
+ const CompilerType &compiler_type, CompletionRequest &request) {
// We are in a type parsing child members
const uint32_t num_bases = compiler_type.GetNumDirectBaseClasses();
@@ -512,9 +509,9 @@ static void PrivateAutoCompleteMembers(
CompilerType base_class_type =
compiler_type.GetDirectBaseClassAtIndex(i, nullptr);
- PrivateAutoCompleteMembers(
- frame, partial_member_name, partial_path, prefix_path,
- base_class_type.GetCanonicalType(), matches, word_complete);
+ PrivateAutoCompleteMembers(frame, partial_member_name, partial_path,
+ prefix_path,
+ base_class_type.GetCanonicalType(), request);
}
}
@@ -525,9 +522,9 @@ static void PrivateAutoCompleteMembers(
CompilerType vbase_class_type =
compiler_type.GetVirtualBaseClassAtIndex(i, nullptr);
- PrivateAutoCompleteMembers(
- frame, partial_member_name, partial_path, prefix_path,
- vbase_class_type.GetCanonicalType(), matches, word_complete);
+ PrivateAutoCompleteMembers(frame, partial_member_name, partial_path,
+ prefix_path,
+ vbase_class_type.GetCanonicalType(), request);
}
}
@@ -548,9 +545,9 @@ static void PrivateAutoCompleteMembers(
frame, partial_path,
prefix_path + member_name, // Anything that has been resolved
// already will be in here
- member_compiler_type.GetCanonicalType(), matches, word_complete);
+ member_compiler_type.GetCanonicalType(), request);
} else {
- matches.AppendString((prefix_path + member_name).str());
+ request.AddCompletion((prefix_path + member_name).str());
}
}
}
@@ -561,8 +558,7 @@ static void PrivateAutoComplete(
StackFrame *frame, llvm::StringRef partial_path,
const llvm::Twine
&prefix_path, // Anything that has been resolved already will be in here
- const CompilerType &compiler_type,
- StringList &matches, bool &word_complete) {
+ const CompilerType &compiler_type, CompletionRequest &request) {
// printf ("\nPrivateAutoComplete()\n\tprefix_path = '%s'\n\tpartial_path =
// '%s'\n", prefix_path.c_str(), partial_path.c_str());
std::string remaining_partial_path;
@@ -583,15 +579,14 @@ static void PrivateAutoComplete(
case eTypeClassReference:
case eTypeClassTypedef:
case eTypeClassVector: {
- matches.AppendString(prefix_path.str());
- word_complete = matches.GetSize() == 1;
+ request.AddCompletion(prefix_path.str());
} break;
case eTypeClassClass:
case eTypeClassStruct:
case eTypeClassUnion:
if (prefix_path.str().back() != '.')
- matches.AppendString((prefix_path + ".").str());
+ request.AddCompletion((prefix_path + ".").str());
break;
case eTypeClassObjCObject:
@@ -601,10 +596,9 @@ static void PrivateAutoComplete(
case eTypeClassPointer: {
bool omit_empty_base_classes = true;
if (compiler_type.GetNumChildren(omit_empty_base_classes, nullptr) > 0)
- matches.AppendString((prefix_path + "->").str());
+ request.AddCompletion((prefix_path + "->").str());
else {
- matches.AppendString(prefix_path.str());
- word_complete = true;
+ request.AddCompletion(prefix_path.str());
}
} break;
}
@@ -618,7 +612,7 @@ static void PrivateAutoComplete(
const size_t num_variables = variable_list->GetSize();
for (size_t i = 0; i < num_variables; ++i) {
Variable *variable = variable_list->GetVariableAtIndex(i).get();
- matches.AppendString(variable->GetName().AsCString());
+ request.AddCompletion(variable->GetName().AsCString());
}
}
}
@@ -629,14 +623,14 @@ static void PrivateAutoComplete(
case '*':
if (prefix_path.str().empty()) {
PrivateAutoComplete(frame, partial_path.substr(1), "*", compiler_type,
- matches, word_complete);
+ request);
}
break;
case '&':
if (prefix_path.isTriviallyEmpty()) {
PrivateAutoComplete(frame, partial_path.substr(1), std::string("&"),
- compiler_type, matches, word_complete);
+ compiler_type, request);
}
break;
@@ -648,14 +642,14 @@ static void PrivateAutoComplete(
CompilerType pointee_type(compiler_type.GetPointeeType());
if (partial_path.size() > 2 && partial_path[2]) {
// If there is more after the "->", then search deeper
- PrivateAutoComplete(
- frame, partial_path.substr(2), prefix_path + "->",
- pointee_type.GetCanonicalType(), matches, word_complete);
+ PrivateAutoComplete(frame, partial_path.substr(2),
+ prefix_path + "->",
+ pointee_type.GetCanonicalType(), request);
} else {
// Nothing after the "->", so list all members
PrivateAutoCompleteMembers(
frame, std::string(), std::string(), prefix_path + "->",
- pointee_type.GetCanonicalType(), matches, word_complete);
+ pointee_type.GetCanonicalType(), request);
}
} break;
default:
@@ -673,14 +667,13 @@ static void PrivateAutoComplete(
if (partial_path.size() > 1 && partial_path[1]) {
// If there is more after the ".", then search deeper
PrivateAutoComplete(frame, partial_path.substr(1),
- prefix_path + ".", compiler_type, matches,
- word_complete);
+ prefix_path + ".", compiler_type, request);
} else {
// Nothing after the ".", so list all members
PrivateAutoCompleteMembers(frame, std::string(), partial_path,
prefix_path + ".", compiler_type,
- matches, word_complete);
+ request);
}
break;
default:
@@ -706,8 +699,7 @@ static void PrivateAutoComplete(
if (compiler_type.IsValid()) {
PrivateAutoCompleteMembers(frame, token, remaining_partial_path,
- prefix_path, compiler_type, matches,
- word_complete);
+ prefix_path, compiler_type, request);
} else if (frame) {
// We haven't found our variable yet
const bool get_file_globals = true;
@@ -736,13 +728,12 @@ static void PrivateAutoComplete(
frame, remaining_partial_path,
prefix_path + token, // Anything that has been resolved
// already will be in here
- variable_compiler_type.GetCanonicalType(), matches,
- word_complete);
+ variable_compiler_type.GetCanonicalType(), request);
} else {
- matches.AppendString((prefix_path + variable_name).str());
+ request.AddCompletion((prefix_path + variable_name).str());
}
} else if (remaining_partial_path.empty()) {
- matches.AppendString((prefix_path + variable_name).str());
+ request.AddCompletion((prefix_path + variable_name).str());
}
}
}
@@ -753,16 +744,10 @@ static void PrivateAutoComplete(
}
}
-size_t Variable::AutoComplete(const ExecutionContext &exe_ctx,
- CompletionRequest &request) {
+void Variable::AutoComplete(const ExecutionContext &exe_ctx,
+ CompletionRequest &request) {
CompilerType compiler_type;
- bool word_complete = false;
- StringList matches;
PrivateAutoComplete(exe_ctx.GetFramePtr(), request.GetCursorArgumentPrefix(),
- "", compiler_type, matches, word_complete);
- request.SetWordComplete(word_complete);
- request.AddCompletions(matches);
-
- return request.GetNumberOfMatches();
+ "", compiler_type, request);
}
diff --git a/source/Symbol/VerifyDecl.cpp b/source/Symbol/VerifyDecl.cpp
deleted file mode 100644
index 1873d3a5d03c..000000000000
--- a/source/Symbol/VerifyDecl.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-//===-- VerifyDecl.cpp ------------------------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "lldb/Symbol/VerifyDecl.h"
-#include "clang/AST/DeclBase.h"
-
-void lldb_private::VerifyDecl(clang::Decl *decl) {
- assert(decl && "VerifyDecl called with nullptr?");
- decl->getAccess();
-}