aboutsummaryrefslogtreecommitdiffstats
path: root/source/Symbol/ClangASTContext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Symbol/ClangASTContext.cpp')
-rw-r--r--source/Symbol/ClangASTContext.cpp1935
1 files changed, 942 insertions, 993 deletions
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(