mirror of
https://github.com/intel/llvm.git
synced 2026-01-26 12:26:52 +08:00
[lldb][NFC] Return a reference from ClangASTContext::getASTContext and remove dead nullptr checks
ClangASTContext::getASTContext() currently returns a ptr but we have an assert there since a while that the ASTContext is not a nullptr. This causes that we still have a lot of code that is doing nullptr checks on the result of getASTContext() which is all unreachable code. This patch changes the return value to a reference to make it clear this can't be a nullptr and deletes all the nullptr checks.
This commit is contained in:
@@ -100,7 +100,7 @@ public:
|
||||
return llvm::dyn_cast<ClangASTContext>(&type_system_or_err.get());
|
||||
}
|
||||
|
||||
clang::ASTContext *getASTContext();
|
||||
clang::ASTContext &getASTContext();
|
||||
|
||||
clang::MangleContext *getMangleContext();
|
||||
|
||||
@@ -117,7 +117,7 @@ public:
|
||||
llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> &ast_source_up);
|
||||
|
||||
bool GetCompleteDecl(clang::Decl *decl) {
|
||||
return ClangASTContext::GetCompleteDecl(getASTContext(), decl);
|
||||
return ClangASTContext::GetCompleteDecl(&getASTContext(), decl);
|
||||
}
|
||||
|
||||
static void DumpDeclHiearchy(clang::Decl *decl);
|
||||
@@ -134,14 +134,14 @@ public:
|
||||
void SetMetadata(const clang::Decl *object, ClangASTMetadata &meta_data);
|
||||
void SetMetadata(const clang::Type *object, ClangASTMetadata &meta_data);
|
||||
ClangASTMetadata *GetMetadata(const clang::Decl *object) {
|
||||
return GetMetadata(getASTContext(), object);
|
||||
return GetMetadata(&getASTContext(), object);
|
||||
}
|
||||
|
||||
static ClangASTMetadata *GetMetadata(clang::ASTContext *ast,
|
||||
const clang::Decl *object);
|
||||
|
||||
ClangASTMetadata *GetMetadata(const clang::Type *object) {
|
||||
return GetMetadata(getASTContext(), object);
|
||||
return GetMetadata(&getASTContext(), object);
|
||||
}
|
||||
|
||||
static ClangASTMetadata *GetMetadata(clang::ASTContext *ast,
|
||||
@@ -170,7 +170,7 @@ public:
|
||||
static clang::DeclContext *GetTranslationUnitDecl(clang::ASTContext *ast);
|
||||
|
||||
clang::DeclContext *GetTranslationUnitDecl() {
|
||||
return GetTranslationUnitDecl(getASTContext());
|
||||
return GetTranslationUnitDecl(&getASTContext());
|
||||
}
|
||||
|
||||
static clang::Decl *CopyDecl(clang::ASTContext *dest_context,
|
||||
@@ -193,27 +193,23 @@ public:
|
||||
CompilerType compiler_type;
|
||||
|
||||
if (type_name.GetLength()) {
|
||||
clang::ASTContext *ast = getASTContext();
|
||||
if (ast) {
|
||||
if (!decl_context)
|
||||
decl_context = ast->getTranslationUnitDecl();
|
||||
clang::ASTContext &ast = getASTContext();
|
||||
if (!decl_context)
|
||||
decl_context = ast.getTranslationUnitDecl();
|
||||
|
||||
clang::IdentifierInfo &myIdent =
|
||||
ast->Idents.get(type_name.GetCString());
|
||||
clang::DeclarationName myName =
|
||||
ast->DeclarationNames.getIdentifier(&myIdent);
|
||||
clang::IdentifierInfo &myIdent = ast.Idents.get(type_name.GetCString());
|
||||
clang::DeclarationName myName =
|
||||
ast.DeclarationNames.getIdentifier(&myIdent);
|
||||
|
||||
clang::DeclContext::lookup_result result =
|
||||
decl_context->lookup(myName);
|
||||
clang::DeclContext::lookup_result result = decl_context->lookup(myName);
|
||||
|
||||
if (!result.empty()) {
|
||||
clang::NamedDecl *named_decl = result[0];
|
||||
if (const RecordDeclType *record_decl =
|
||||
llvm::dyn_cast<RecordDeclType>(named_decl))
|
||||
compiler_type.SetCompilerType(
|
||||
this, clang::QualType(record_decl->getTypeForDecl(), 0)
|
||||
.getAsOpaquePtr());
|
||||
}
|
||||
if (!result.empty()) {
|
||||
clang::NamedDecl *named_decl = result[0];
|
||||
if (const RecordDeclType *record_decl =
|
||||
llvm::dyn_cast<RecordDeclType>(named_decl))
|
||||
compiler_type.SetCompilerType(
|
||||
this, clang::QualType(record_decl->getTypeForDecl(), 0)
|
||||
.getAsOpaquePtr());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -355,14 +351,14 @@ public:
|
||||
const CompilerType *args, unsigned num_args,
|
||||
bool is_variadic, unsigned type_quals) {
|
||||
return ClangASTContext::CreateFunctionType(
|
||||
getASTContext(), result_type, args, num_args, is_variadic, type_quals);
|
||||
&getASTContext(), result_type, args, num_args, is_variadic, type_quals);
|
||||
}
|
||||
|
||||
CompilerType CreateFunctionType(const CompilerType &result_type,
|
||||
const CompilerType *args, unsigned num_args,
|
||||
bool is_variadic, unsigned type_quals,
|
||||
clang::CallingConv cc) {
|
||||
return ClangASTContext::CreateFunctionType(getASTContext(), result_type,
|
||||
return ClangASTContext::CreateFunctionType(&getASTContext(), result_type,
|
||||
args, num_args, is_variadic,
|
||||
type_quals, cc);
|
||||
}
|
||||
@@ -396,7 +392,7 @@ public:
|
||||
size_t bit_size, bool is_signed);
|
||||
|
||||
CompilerType GetPointerSizedIntType(bool is_signed) {
|
||||
return GetPointerSizedIntType(getASTContext(), is_signed);
|
||||
return GetPointerSizedIntType(&getASTContext(), is_signed);
|
||||
}
|
||||
|
||||
static CompilerType GetPointerSizedIntType(clang::ASTContext *ast,
|
||||
|
||||
@@ -453,7 +453,7 @@ void ASTResultSynthesizer::CommitPersistentDecls() {
|
||||
ConstString name_cs(name.str().c_str());
|
||||
|
||||
Decl *D_scratch = m_target.GetClangASTImporter()->DeportDecl(
|
||||
ClangASTContext::GetScratch(m_target)->getASTContext(), decl);
|
||||
&ClangASTContext::GetScratch(m_target)->getASTContext(), decl);
|
||||
|
||||
if (!D_scratch) {
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
|
||||
|
||||
@@ -57,7 +57,7 @@ ClangASTSource::ClangASTSource(const lldb::TargetSP &target,
|
||||
}
|
||||
|
||||
void ClangASTSource::InstallASTContext(ClangASTContext &clang_ast_context) {
|
||||
m_ast_context = clang_ast_context.getASTContext();
|
||||
m_ast_context = &clang_ast_context.getASTContext();
|
||||
m_clang_ast_context = &clang_ast_context;
|
||||
m_file_manager = &m_ast_context->getSourceManager().getFileManager();
|
||||
m_ast_importer_sp->InstallMapCompleter(m_ast_context, *this);
|
||||
@@ -80,14 +80,11 @@ ClangASTSource::~ClangASTSource() {
|
||||
if (!scratch_clang_ast_context)
|
||||
return;
|
||||
|
||||
clang::ASTContext *scratch_ast_context =
|
||||
clang::ASTContext &scratch_ast_context =
|
||||
scratch_clang_ast_context->getASTContext();
|
||||
|
||||
if (!scratch_ast_context)
|
||||
return;
|
||||
|
||||
if (m_ast_context != scratch_ast_context && m_ast_importer_sp)
|
||||
m_ast_importer_sp->ForgetSource(scratch_ast_context, m_ast_context);
|
||||
if (m_ast_context != &scratch_ast_context && m_ast_importer_sp)
|
||||
m_ast_importer_sp->ForgetSource(&scratch_ast_context, m_ast_context);
|
||||
}
|
||||
|
||||
void ClangASTSource::StartTranslationUnit(ASTConsumer *Consumer) {
|
||||
@@ -1880,10 +1877,10 @@ clang::NamedDecl *NameSearchContext::AddVarDecl(const CompilerType &type) {
|
||||
|
||||
IdentifierInfo *ii = m_decl_name.getAsIdentifierInfo();
|
||||
|
||||
clang::ASTContext *ast = lldb_ast->getASTContext();
|
||||
clang::ASTContext &ast = lldb_ast->getASTContext();
|
||||
|
||||
clang::NamedDecl *Decl = VarDecl::Create(
|
||||
*ast, const_cast<DeclContext *>(m_decl_context), SourceLocation(),
|
||||
ast, const_cast<DeclContext *>(m_decl_context), SourceLocation(),
|
||||
SourceLocation(), ii, ClangUtil::GetQualType(type), nullptr, SC_Static);
|
||||
m_decls.push_back(Decl);
|
||||
|
||||
@@ -1909,7 +1906,7 @@ clang::NamedDecl *NameSearchContext::AddFunDecl(const CompilerType &type,
|
||||
|
||||
QualType qual_type(ClangUtil::GetQualType(type));
|
||||
|
||||
clang::ASTContext *ast = lldb_ast->getASTContext();
|
||||
clang::ASTContext &ast = lldb_ast->getASTContext();
|
||||
|
||||
const bool isInlineSpecified = false;
|
||||
const bool hasWrittenPrototype = true;
|
||||
@@ -1919,7 +1916,7 @@ clang::NamedDecl *NameSearchContext::AddFunDecl(const CompilerType &type,
|
||||
|
||||
if (extern_c) {
|
||||
context = LinkageSpecDecl::Create(
|
||||
*ast, context, SourceLocation(), SourceLocation(),
|
||||
ast, context, SourceLocation(), SourceLocation(),
|
||||
clang::LinkageSpecDecl::LanguageIDs::lang_c, false);
|
||||
}
|
||||
|
||||
@@ -1931,7 +1928,7 @@ clang::NamedDecl *NameSearchContext::AddFunDecl(const CompilerType &type,
|
||||
: m_decl_name;
|
||||
|
||||
clang::FunctionDecl *func_decl = FunctionDecl::Create(
|
||||
*ast, context, SourceLocation(), SourceLocation(), decl_name, qual_type,
|
||||
ast, context, SourceLocation(), SourceLocation(), decl_name, qual_type,
|
||||
nullptr, SC_Extern, isInlineSpecified, hasWrittenPrototype,
|
||||
isConstexprSpecified ? CSK_constexpr : CSK_unspecified);
|
||||
|
||||
@@ -1952,7 +1949,7 @@ clang::NamedDecl *NameSearchContext::AddFunDecl(const CompilerType &type,
|
||||
QualType arg_qual_type(func_proto_type->getParamType(ArgIndex));
|
||||
|
||||
parm_var_decls.push_back(
|
||||
ParmVarDecl::Create(*ast, const_cast<DeclContext *>(context),
|
||||
ParmVarDecl::Create(ast, const_cast<DeclContext *>(context),
|
||||
SourceLocation(), SourceLocation(), nullptr,
|
||||
arg_qual_type, nullptr, SC_Static, nullptr));
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ TypeFromUser ClangExpressionDeclMap::DeportType(ClangASTContext &target,
|
||||
TypeFromParser parser_type) {
|
||||
assert(&target == ClangASTContext::GetScratch(*m_target));
|
||||
assert((TypeSystem *)&source == parser_type.GetTypeSystem());
|
||||
assert(source.getASTContext() == m_ast_context);
|
||||
assert(&source.getASTContext() == m_ast_context);
|
||||
|
||||
if (m_ast_importer_sp) {
|
||||
return TypeFromUser(m_ast_importer_sp->DeportType(target, parser_type));
|
||||
@@ -741,16 +741,7 @@ clang::NamedDecl *ClangExpressionDeclMap::GetPersistentDecl(ConstString name) {
|
||||
if (!target)
|
||||
return nullptr;
|
||||
|
||||
ClangASTContext *scratch_clang_ast_context =
|
||||
ClangASTContext::GetScratch(*target);
|
||||
|
||||
if (!scratch_clang_ast_context)
|
||||
return nullptr;
|
||||
|
||||
ASTContext *scratch_ast_context = scratch_clang_ast_context->getASTContext();
|
||||
|
||||
if (!scratch_ast_context)
|
||||
return nullptr;
|
||||
ClangASTContext::GetScratch(*target);
|
||||
|
||||
return m_parser_vars->m_persistent_vars->GetPersistentDecl(name);
|
||||
}
|
||||
@@ -1528,15 +1519,6 @@ bool ClangExpressionDeclMap::GetVariableValue(VariableSP &var,
|
||||
return false;
|
||||
}
|
||||
|
||||
ASTContext *ast = clang_ast->getASTContext();
|
||||
|
||||
if (!ast) {
|
||||
if (log)
|
||||
log->PutCString(
|
||||
"There is no AST context for the current execution context");
|
||||
return false;
|
||||
}
|
||||
|
||||
DWARFExpression &var_location_expr = var->LocationExpression();
|
||||
|
||||
Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
|
||||
|
||||
@@ -466,7 +466,7 @@ lldb_private::formatters::NSArrayMSyntheticFrontEndBase::NSArrayMSyntheticFrontE
|
||||
if (clang_ast_context)
|
||||
m_id_type = CompilerType(
|
||||
clang_ast_context,
|
||||
clang_ast_context->getASTContext()->ObjCBuiltinIdTy.getAsOpaquePtr());
|
||||
clang_ast_context->getASTContext().ObjCBuiltinIdTy.getAsOpaquePtr());
|
||||
if (valobj_sp->GetProcessSP())
|
||||
m_ptr_size = valobj_sp->GetProcessSP()->GetAddressByteSize();
|
||||
}
|
||||
@@ -614,7 +614,7 @@ lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<D32, D64, Inline>::
|
||||
if (clang_ast_context)
|
||||
m_id_type = CompilerType(clang_ast_context,
|
||||
clang_ast_context->getASTContext()
|
||||
->ObjCBuiltinIdTy.getAsOpaquePtr());
|
||||
.ObjCBuiltinIdTy.getAsOpaquePtr());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ public:
|
||||
|
||||
void StartTranslationUnit(clang::ASTConsumer *Consumer) override {
|
||||
clang::TranslationUnitDecl *translation_unit_decl =
|
||||
m_decl_vendor.m_ast_ctx.getASTContext()->getTranslationUnitDecl();
|
||||
m_decl_vendor.m_ast_ctx.getASTContext().getTranslationUnitDecl();
|
||||
translation_unit_decl->setHasExternalVisibleStorage();
|
||||
translation_unit_decl->setHasExternalLexicalStorage();
|
||||
}
|
||||
@@ -153,7 +153,7 @@ AppleObjCDeclVendor::AppleObjCDeclVendor(ObjCLanguageRuntime &runtime)
|
||||
m_external_source = new AppleObjCExternalASTSource(*this);
|
||||
llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> external_source_owning_ptr(
|
||||
m_external_source);
|
||||
m_ast_ctx.getASTContext()->setExternalSource(external_source_owning_ptr);
|
||||
m_ast_ctx.getASTContext().setExternalSource(external_source_owning_ptr);
|
||||
}
|
||||
|
||||
clang::ObjCInterfaceDecl *
|
||||
@@ -163,7 +163,7 @@ AppleObjCDeclVendor::GetDeclForISA(ObjCLanguageRuntime::ObjCISA isa) {
|
||||
if (iter != m_isa_to_interface.end())
|
||||
return iter->second;
|
||||
|
||||
clang::ASTContext *ast_ctx = m_ast_ctx.getASTContext();
|
||||
clang::ASTContext &ast_ctx = m_ast_ctx.getASTContext();
|
||||
|
||||
ObjCLanguageRuntime::ClassDescriptorSP descriptor =
|
||||
m_runtime.GetClassDescriptorFromISA(isa);
|
||||
@@ -174,10 +174,10 @@ AppleObjCDeclVendor::GetDeclForISA(ObjCLanguageRuntime::ObjCISA isa) {
|
||||
ConstString name(descriptor->GetClassName());
|
||||
|
||||
clang::IdentifierInfo &identifier_info =
|
||||
ast_ctx->Idents.get(name.GetStringRef());
|
||||
ast_ctx.Idents.get(name.GetStringRef());
|
||||
|
||||
clang::ObjCInterfaceDecl *new_iface_decl = clang::ObjCInterfaceDecl::Create(
|
||||
*ast_ctx, ast_ctx->getTranslationUnitDecl(), clang::SourceLocation(),
|
||||
ast_ctx, ast_ctx.getTranslationUnitDecl(), clang::SourceLocation(),
|
||||
&identifier_info, nullptr, nullptr);
|
||||
|
||||
ClangASTMetadata meta_data;
|
||||
@@ -187,7 +187,7 @@ AppleObjCDeclVendor::GetDeclForISA(ObjCLanguageRuntime::ObjCISA isa) {
|
||||
new_iface_decl->setHasExternalVisibleStorage();
|
||||
new_iface_decl->setHasExternalLexicalStorage();
|
||||
|
||||
ast_ctx->getTranslationUnitDecl()->addDecl(new_iface_decl);
|
||||
ast_ctx.getTranslationUnitDecl()->addDecl(new_iface_decl);
|
||||
|
||||
m_isa_to_interface[isa] = new_iface_decl;
|
||||
|
||||
@@ -443,9 +443,9 @@ bool AppleObjCDeclVendor::FinishDecl(clang::ObjCInterfaceDecl *interface_decl) {
|
||||
return;
|
||||
|
||||
FinishDecl(superclass_decl);
|
||||
clang::ASTContext *context = m_ast_ctx.getASTContext();
|
||||
interface_decl->setSuperClass(context->getTrivialTypeSourceInfo(
|
||||
context->getObjCInterfaceType(superclass_decl)));
|
||||
clang::ASTContext &context = m_ast_ctx.getASTContext();
|
||||
interface_decl->setSuperClass(context.getTrivialTypeSourceInfo(
|
||||
context.getObjCInterfaceType(superclass_decl)));
|
||||
};
|
||||
|
||||
auto instance_method_func =
|
||||
@@ -503,8 +503,8 @@ bool AppleObjCDeclVendor::FinishDecl(clang::ObjCInterfaceDecl *interface_decl) {
|
||||
clang::TypeSourceInfo *const type_source_info = nullptr;
|
||||
const bool is_synthesized = false;
|
||||
clang::ObjCIvarDecl *ivar_decl = clang::ObjCIvarDecl::Create(
|
||||
*m_ast_ctx.getASTContext(), interface_decl, clang::SourceLocation(),
|
||||
clang::SourceLocation(), &m_ast_ctx.getASTContext()->Idents.get(name),
|
||||
m_ast_ctx.getASTContext(), interface_decl, clang::SourceLocation(),
|
||||
clang::SourceLocation(), &m_ast_ctx.getASTContext().Idents.get(name),
|
||||
ClangUtil::GetQualType(ivar_type),
|
||||
type_source_info, // TypeSourceInfo *
|
||||
clang::ObjCIvarDecl::Public, nullptr, is_synthesized);
|
||||
@@ -559,22 +559,22 @@ AppleObjCDeclVendor::FindDecls(ConstString name, bool append,
|
||||
do {
|
||||
// See if the type is already in our ASTContext.
|
||||
|
||||
clang::ASTContext *ast_ctx = m_ast_ctx.getASTContext();
|
||||
clang::ASTContext &ast_ctx = m_ast_ctx.getASTContext();
|
||||
|
||||
clang::IdentifierInfo &identifier_info =
|
||||
ast_ctx->Idents.get(name.GetStringRef());
|
||||
ast_ctx.Idents.get(name.GetStringRef());
|
||||
clang::DeclarationName decl_name =
|
||||
ast_ctx->DeclarationNames.getIdentifier(&identifier_info);
|
||||
ast_ctx.DeclarationNames.getIdentifier(&identifier_info);
|
||||
|
||||
clang::DeclContext::lookup_result lookup_result =
|
||||
ast_ctx->getTranslationUnitDecl()->lookup(decl_name);
|
||||
ast_ctx.getTranslationUnitDecl()->lookup(decl_name);
|
||||
|
||||
if (!lookup_result.empty()) {
|
||||
if (clang::ObjCInterfaceDecl *result_iface_decl =
|
||||
llvm::dyn_cast<clang::ObjCInterfaceDecl>(lookup_result[0])) {
|
||||
if (log) {
|
||||
clang::QualType result_iface_type =
|
||||
ast_ctx->getObjCInterfaceType(result_iface_decl);
|
||||
ast_ctx.getObjCInterfaceType(result_iface_decl);
|
||||
|
||||
uint64_t isa_value = LLDB_INVALID_ADDRESS;
|
||||
ClangASTMetadata *metadata =
|
||||
@@ -625,8 +625,7 @@ AppleObjCDeclVendor::FindDecls(ConstString name, bool append,
|
||||
}
|
||||
|
||||
if (log) {
|
||||
clang::QualType new_iface_type =
|
||||
ast_ctx->getObjCInterfaceType(iface_decl);
|
||||
clang::QualType new_iface_type = ast_ctx.getObjCInterfaceType(iface_decl);
|
||||
|
||||
LLDB_LOG(log, "AOCTV::FT [{0}] Created {1} (isa 0x{2:x})", current_id,
|
||||
new_iface_type.getAsString(), (uint64_t)isa);
|
||||
|
||||
@@ -315,10 +315,8 @@ ObjCLanguageRuntime::EncodingToType::RealizeType(const char *name,
|
||||
|
||||
CompilerType ObjCLanguageRuntime::EncodingToType::RealizeType(
|
||||
ClangASTContext &ast_ctx, const char *name, bool for_expression) {
|
||||
clang::ASTContext *clang_ast = ast_ctx.getASTContext();
|
||||
if (!clang_ast)
|
||||
return CompilerType();
|
||||
return RealizeType(*clang_ast, name, for_expression);
|
||||
clang::ASTContext &clang_ast = ast_ctx.getASTContext();
|
||||
return RealizeType(clang_ast, name, for_expression);
|
||||
}
|
||||
|
||||
ObjCLanguageRuntime::EncodingToType::~EncodingToType() {}
|
||||
|
||||
@@ -1909,7 +1909,7 @@ bool DWARFASTParserClang::ParseTemplateDIE(
|
||||
}
|
||||
}
|
||||
|
||||
clang::ASTContext *ast = m_ast.getASTContext();
|
||||
clang::ASTContext &ast = m_ast.getASTContext();
|
||||
if (!clang_type)
|
||||
clang_type = m_ast.GetBasicType(eBasicTypeVoid);
|
||||
|
||||
@@ -1929,7 +1929,7 @@ bool DWARFASTParserClang::ParseTemplateDIE(
|
||||
return false;
|
||||
llvm::APInt apint(*size, uval64, is_signed);
|
||||
template_param_infos.args.push_back(
|
||||
clang::TemplateArgument(*ast, llvm::APSInt(apint, !is_signed),
|
||||
clang::TemplateArgument(ast, llvm::APSInt(apint, !is_signed),
|
||||
ClangUtil::GetQualType(clang_type)));
|
||||
} else {
|
||||
template_param_infos.args.push_back(
|
||||
@@ -3570,18 +3570,20 @@ DWARFASTParserClang::ResolveNamespaceDIE(const DWARFDIE &die) {
|
||||
SymbolFileDWARF *dwarf = die.GetDWARF();
|
||||
if (namespace_name) {
|
||||
dwarf->GetObjectFile()->GetModule()->LogMessage(
|
||||
log, "ASTContext => %p: 0x%8.8" PRIx64
|
||||
": DW_TAG_namespace with DW_AT_name(\"%s\") => "
|
||||
"clang::NamespaceDecl *%p (original = %p)",
|
||||
static_cast<void *>(m_ast.getASTContext()), die.GetID(),
|
||||
log,
|
||||
"ASTContext => %p: 0x%8.8" PRIx64
|
||||
": DW_TAG_namespace with DW_AT_name(\"%s\") => "
|
||||
"clang::NamespaceDecl *%p (original = %p)",
|
||||
static_cast<void *>(&m_ast.getASTContext()), die.GetID(),
|
||||
namespace_name, static_cast<void *>(namespace_decl),
|
||||
static_cast<void *>(namespace_decl->getOriginalNamespace()));
|
||||
} else {
|
||||
dwarf->GetObjectFile()->GetModule()->LogMessage(
|
||||
log, "ASTContext => %p: 0x%8.8" PRIx64
|
||||
": DW_TAG_namespace (anonymous) => clang::NamespaceDecl *%p "
|
||||
"(original = %p)",
|
||||
static_cast<void *>(m_ast.getASTContext()), die.GetID(),
|
||||
log,
|
||||
"ASTContext => %p: 0x%8.8" PRIx64
|
||||
": DW_TAG_namespace (anonymous) => clang::NamespaceDecl *%p "
|
||||
"(original = %p)",
|
||||
static_cast<void *>(&m_ast.getASTContext()), die.GetID(),
|
||||
static_cast<void *>(namespace_decl),
|
||||
static_cast<void *>(namespace_decl->getOriginalNamespace()));
|
||||
}
|
||||
|
||||
@@ -655,7 +655,7 @@ bool PdbAstBuilder::CompleteTagDecl(clang::TagDecl &tag) {
|
||||
|
||||
lldbassert(IsTagRecord(type_id, m_index.tpi()));
|
||||
|
||||
clang::QualType tag_qt = m_clang.getASTContext()->getTypeDeclType(&tag);
|
||||
clang::QualType tag_qt = m_clang.getASTContext().getTypeDeclType(&tag);
|
||||
ClangASTContext::SetHasExternalStorage(tag_qt.getAsOpaquePtr(), false);
|
||||
|
||||
TypeIndex tag_ti = type_id.index;
|
||||
@@ -700,7 +700,7 @@ clang::QualType PdbAstBuilder::CreateSimpleType(TypeIndex ti) {
|
||||
|
||||
if (ti.getSimpleMode() != SimpleTypeMode::Direct) {
|
||||
clang::QualType direct_type = GetOrCreateType(ti.makeDirect());
|
||||
return m_clang.getASTContext()->getPointerType(direct_type);
|
||||
return m_clang.getASTContext().getPointerType(direct_type);
|
||||
}
|
||||
|
||||
if (ti.getSimpleKind() == SimpleTypeKind::NotTranslated)
|
||||
@@ -725,19 +725,17 @@ clang::QualType PdbAstBuilder::CreatePointerType(const PointerRecord &pointer) {
|
||||
MemberPointerInfo mpi = pointer.getMemberInfo();
|
||||
clang::QualType class_type = GetOrCreateType(mpi.ContainingType);
|
||||
|
||||
return m_clang.getASTContext()->getMemberPointerType(
|
||||
return m_clang.getASTContext().getMemberPointerType(
|
||||
pointee_type, class_type.getTypePtr());
|
||||
}
|
||||
|
||||
clang::QualType pointer_type;
|
||||
if (pointer.getMode() == PointerMode::LValueReference)
|
||||
pointer_type =
|
||||
m_clang.getASTContext()->getLValueReferenceType(pointee_type);
|
||||
pointer_type = m_clang.getASTContext().getLValueReferenceType(pointee_type);
|
||||
else if (pointer.getMode() == PointerMode::RValueReference)
|
||||
pointer_type =
|
||||
m_clang.getASTContext()->getRValueReferenceType(pointee_type);
|
||||
pointer_type = m_clang.getASTContext().getRValueReferenceType(pointee_type);
|
||||
else
|
||||
pointer_type = m_clang.getASTContext()->getPointerType(pointee_type);
|
||||
pointer_type = m_clang.getASTContext().getPointerType(pointee_type);
|
||||
|
||||
if ((pointer.getOptions() & PointerOptions::Const) != PointerOptions::None)
|
||||
pointer_type.addConst();
|
||||
|
||||
@@ -103,9 +103,7 @@ static CompilerType
|
||||
GetBuiltinTypeForPDBEncodingAndBitSize(ClangASTContext &clang_ast,
|
||||
const PDBSymbolTypeBuiltin &pdb_type,
|
||||
Encoding encoding, uint32_t width) {
|
||||
auto *ast = clang_ast.getASTContext();
|
||||
if (!ast)
|
||||
return CompilerType();
|
||||
clang::ASTContext &ast = clang_ast.getASTContext();
|
||||
|
||||
switch (pdb_type.getBuiltinType()) {
|
||||
default:
|
||||
@@ -119,32 +117,32 @@ GetBuiltinTypeForPDBEncodingAndBitSize(ClangASTContext &clang_ast,
|
||||
case PDB_BuiltinType::Bool:
|
||||
return clang_ast.GetBasicType(eBasicTypeBool);
|
||||
case PDB_BuiltinType::Long:
|
||||
if (width == ast->getTypeSize(ast->LongTy))
|
||||
return CompilerType(ClangASTContext::GetASTContext(ast),
|
||||
ast->LongTy.getAsOpaquePtr());
|
||||
if (width == ast->getTypeSize(ast->LongLongTy))
|
||||
return CompilerType(ClangASTContext::GetASTContext(ast),
|
||||
ast->LongLongTy.getAsOpaquePtr());
|
||||
if (width == ast.getTypeSize(ast.LongTy))
|
||||
return CompilerType(ClangASTContext::GetASTContext(&ast),
|
||||
ast.LongTy.getAsOpaquePtr());
|
||||
if (width == ast.getTypeSize(ast.LongLongTy))
|
||||
return CompilerType(ClangASTContext::GetASTContext(&ast),
|
||||
ast.LongLongTy.getAsOpaquePtr());
|
||||
break;
|
||||
case PDB_BuiltinType::ULong:
|
||||
if (width == ast->getTypeSize(ast->UnsignedLongTy))
|
||||
return CompilerType(ClangASTContext::GetASTContext(ast),
|
||||
ast->UnsignedLongTy.getAsOpaquePtr());
|
||||
if (width == ast->getTypeSize(ast->UnsignedLongLongTy))
|
||||
return CompilerType(ClangASTContext::GetASTContext(ast),
|
||||
ast->UnsignedLongLongTy.getAsOpaquePtr());
|
||||
if (width == ast.getTypeSize(ast.UnsignedLongTy))
|
||||
return CompilerType(ClangASTContext::GetASTContext(&ast),
|
||||
ast.UnsignedLongTy.getAsOpaquePtr());
|
||||
if (width == ast.getTypeSize(ast.UnsignedLongLongTy))
|
||||
return CompilerType(ClangASTContext::GetASTContext(&ast),
|
||||
ast.UnsignedLongLongTy.getAsOpaquePtr());
|
||||
break;
|
||||
case PDB_BuiltinType::WCharT:
|
||||
if (width == ast->getTypeSize(ast->WCharTy))
|
||||
return CompilerType(ClangASTContext::GetASTContext(ast),
|
||||
ast->WCharTy.getAsOpaquePtr());
|
||||
if (width == ast.getTypeSize(ast.WCharTy))
|
||||
return CompilerType(ClangASTContext::GetASTContext(&ast),
|
||||
ast.WCharTy.getAsOpaquePtr());
|
||||
break;
|
||||
case PDB_BuiltinType::Char16:
|
||||
return CompilerType(ClangASTContext::GetASTContext(ast),
|
||||
ast->Char16Ty.getAsOpaquePtr());
|
||||
return CompilerType(ClangASTContext::GetASTContext(&ast),
|
||||
ast.Char16Ty.getAsOpaquePtr());
|
||||
case PDB_BuiltinType::Char32:
|
||||
return CompilerType(ClangASTContext::GetASTContext(ast),
|
||||
ast->Char32Ty.getAsOpaquePtr());
|
||||
return CompilerType(ClangASTContext::GetASTContext(&ast),
|
||||
ast.Char32Ty.getAsOpaquePtr());
|
||||
case PDB_BuiltinType::Float:
|
||||
// Note: types `long double` and `double` have same bit size in MSVC and
|
||||
// there is no information in the PDB to distinguish them. So when falling
|
||||
@@ -428,7 +426,7 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) {
|
||||
m_uid_to_decl[type.getSymIndexId()] = record_decl;
|
||||
|
||||
auto inheritance_attr = clang::MSInheritanceAttr::CreateImplicit(
|
||||
*m_ast.getASTContext(), GetMSInheritance(*udt));
|
||||
m_ast.getASTContext(), GetMSInheritance(*udt));
|
||||
record_decl->addAttr(inheritance_attr);
|
||||
|
||||
ClangASTContext::StartTagDeclarationDefinition(clang_type);
|
||||
@@ -900,7 +898,7 @@ PDBASTParser::GetDeclForSymbol(const llvm::pdb::PDBSymbol &symbol) {
|
||||
|
||||
// Check if the current context already contains the symbol with the name.
|
||||
clang::Decl *decl =
|
||||
GetDeclFromContextByName(*m_ast.getASTContext(), *decl_context, name);
|
||||
GetDeclFromContextByName(m_ast.getASTContext(), *decl_context, name);
|
||||
if (!decl) {
|
||||
auto type = symbol_file->ResolveTypeUID(data->getTypeId());
|
||||
if (!type)
|
||||
@@ -1160,7 +1158,7 @@ bool PDBASTParser::AddEnumValue(CompilerType enum_type,
|
||||
}
|
||||
CompilerType underlying_type =
|
||||
m_ast.GetEnumerationIntegerType(enum_type.GetOpaqueQualType());
|
||||
uint32_t byte_size = m_ast.getASTContext()->getTypeSize(
|
||||
uint32_t byte_size = m_ast.getASTContext().getTypeSize(
|
||||
ClangUtil::GetQualType(underlying_type));
|
||||
auto enum_constant_decl = m_ast.AddEnumerationValueToEnumerationType(
|
||||
enum_type, decl, name.c_str(), raw_value, byte_size * 8);
|
||||
|
||||
@@ -413,8 +413,7 @@ void SystemRuntimeMacOSX::ReadLibdispatchTSDIndexes() {
|
||||
|
||||
ClangASTContext *ast_ctx =
|
||||
ClangASTContext::GetScratch(m_process->GetTarget());
|
||||
if (ast_ctx->getASTContext() &&
|
||||
m_dispatch_tsd_indexes_addr != LLDB_INVALID_ADDRESS) {
|
||||
if (m_dispatch_tsd_indexes_addr != LLDB_INVALID_ADDRESS) {
|
||||
CompilerType uint16 =
|
||||
ast_ctx->GetBuiltinTypeForEncodingAndBitSize(eEncodingUint, 16);
|
||||
CompilerType dispatch_tsd_indexes_s = ast_ctx->CreateRecordType(
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -27,26 +27,22 @@ using namespace clang;
|
||||
|
||||
CompilerType ClangASTImporter::CopyType(ClangASTContext &dst_ast,
|
||||
const CompilerType &src_type) {
|
||||
clang::ASTContext *dst_clang_ast = dst_ast.getASTContext();
|
||||
if (!dst_clang_ast)
|
||||
return CompilerType();
|
||||
clang::ASTContext &dst_clang_ast = dst_ast.getASTContext();
|
||||
|
||||
ClangASTContext *src_ast =
|
||||
llvm::dyn_cast_or_null<ClangASTContext>(src_type.GetTypeSystem());
|
||||
if (!src_ast)
|
||||
return CompilerType();
|
||||
|
||||
clang::ASTContext *src_clang_ast = src_ast->getASTContext();
|
||||
if (!src_clang_ast)
|
||||
return CompilerType();
|
||||
clang::ASTContext &src_clang_ast = src_ast->getASTContext();
|
||||
|
||||
clang::QualType src_qual_type = ClangUtil::GetQualType(src_type);
|
||||
|
||||
ImporterDelegateSP delegate_sp(GetDelegate(dst_clang_ast, src_clang_ast));
|
||||
ImporterDelegateSP delegate_sp(GetDelegate(&dst_clang_ast, &src_clang_ast));
|
||||
if (!delegate_sp)
|
||||
return CompilerType();
|
||||
|
||||
ASTImporterDelegate::CxxModuleScope std_scope(*delegate_sp, dst_clang_ast);
|
||||
ASTImporterDelegate::CxxModuleScope std_scope(*delegate_sp, &dst_clang_ast);
|
||||
|
||||
llvm::Expected<QualType> ret_or_error = delegate_sp->Import(src_qual_type);
|
||||
if (!ret_or_error) {
|
||||
@@ -307,15 +303,15 @@ CompilerType ClangASTImporter::DeportType(ClangASTContext &dst,
|
||||
" [ClangASTImporter] DeportType called on ({0}Type*){1:x} "
|
||||
"from (ASTContext*){2:x} to (ASTContext*){3:x}",
|
||||
src_type.GetTypeName(), src_type.GetOpaqueQualType(),
|
||||
src_ctxt->getASTContext(), dst.getASTContext());
|
||||
&src_ctxt->getASTContext(), &dst.getASTContext());
|
||||
|
||||
DeclContextOverride decl_context_override;
|
||||
|
||||
if (auto *t = ClangUtil::GetQualType(src_type)->getAs<TagType>())
|
||||
decl_context_override.OverrideAllDeclsFromContainingFunction(t->getDecl());
|
||||
|
||||
CompleteTagDeclsScope complete_scope(*this, dst.getASTContext(),
|
||||
src_ctxt->getASTContext());
|
||||
CompleteTagDeclsScope complete_scope(*this, &dst.getASTContext(),
|
||||
&src_ctxt->getASTContext());
|
||||
return CopyType(dst, src_type);
|
||||
}
|
||||
|
||||
|
||||
@@ -603,11 +603,9 @@ Error opts::symbols::dumpAST(lldb_private::Module &Module) {
|
||||
if (!clang_ast_ctx)
|
||||
return make_string_error("Retrieved TypeSystem was not a ClangASTContext");
|
||||
|
||||
auto ast_ctx = clang_ast_ctx->getASTContext();
|
||||
if (!ast_ctx)
|
||||
return make_string_error("Can't retrieve AST context.");
|
||||
clang::ASTContext &ast_ctx = clang_ast_ctx->getASTContext();
|
||||
|
||||
clang::TranslationUnitDecl *tu = ast_ctx->getTranslationUnitDecl();
|
||||
clang::TranslationUnitDecl *tu = ast_ctx.getTranslationUnitDecl();
|
||||
if (!tu)
|
||||
return make_string_error("Can't retrieve translation unit declaration.");
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ struct FakeClangExpressionDeclMap : public ClangExpressionDeclMap {
|
||||
// persistent declaration and must be inside the scratch AST context.
|
||||
assert(d);
|
||||
assert(d->getName().startswith("$"));
|
||||
assert(&d->getASTContext() == m_scratch_context->getASTContext());
|
||||
assert(&d->getASTContext() == &m_scratch_context->getASTContext());
|
||||
m_persistent_decls[d->getName()] = d;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,67 +52,66 @@ protected:
|
||||
};
|
||||
|
||||
TEST_F(TestClangASTContext, TestGetBasicTypeFromEnum) {
|
||||
clang::ASTContext *context = m_ast->getASTContext();
|
||||
clang::ASTContext &context = m_ast->getASTContext();
|
||||
|
||||
EXPECT_TRUE(
|
||||
context->hasSameType(GetBasicQualType(eBasicTypeBool), context->BoolTy));
|
||||
context.hasSameType(GetBasicQualType(eBasicTypeBool), context.BoolTy));
|
||||
EXPECT_TRUE(
|
||||
context->hasSameType(GetBasicQualType(eBasicTypeChar), context->CharTy));
|
||||
EXPECT_TRUE(context->hasSameType(GetBasicQualType(eBasicTypeChar16),
|
||||
context->Char16Ty));
|
||||
EXPECT_TRUE(context->hasSameType(GetBasicQualType(eBasicTypeChar32),
|
||||
context->Char32Ty));
|
||||
EXPECT_TRUE(context->hasSameType(GetBasicQualType(eBasicTypeDouble),
|
||||
context->DoubleTy));
|
||||
EXPECT_TRUE(context->hasSameType(GetBasicQualType(eBasicTypeDoubleComplex),
|
||||
context->DoubleComplexTy));
|
||||
EXPECT_TRUE(context->hasSameType(GetBasicQualType(eBasicTypeFloat),
|
||||
context->FloatTy));
|
||||
EXPECT_TRUE(context->hasSameType(GetBasicQualType(eBasicTypeFloatComplex),
|
||||
context->FloatComplexTy));
|
||||
context.hasSameType(GetBasicQualType(eBasicTypeChar), context.CharTy));
|
||||
EXPECT_TRUE(context.hasSameType(GetBasicQualType(eBasicTypeChar16),
|
||||
context.Char16Ty));
|
||||
EXPECT_TRUE(context.hasSameType(GetBasicQualType(eBasicTypeChar32),
|
||||
context.Char32Ty));
|
||||
EXPECT_TRUE(context.hasSameType(GetBasicQualType(eBasicTypeDouble),
|
||||
context.DoubleTy));
|
||||
EXPECT_TRUE(context.hasSameType(GetBasicQualType(eBasicTypeDoubleComplex),
|
||||
context.DoubleComplexTy));
|
||||
EXPECT_TRUE(
|
||||
context->hasSameType(GetBasicQualType(eBasicTypeHalf), context->HalfTy));
|
||||
context.hasSameType(GetBasicQualType(eBasicTypeFloat), context.FloatTy));
|
||||
EXPECT_TRUE(context.hasSameType(GetBasicQualType(eBasicTypeFloatComplex),
|
||||
context.FloatComplexTy));
|
||||
EXPECT_TRUE(
|
||||
context->hasSameType(GetBasicQualType(eBasicTypeInt), context->IntTy));
|
||||
EXPECT_TRUE(context->hasSameType(GetBasicQualType(eBasicTypeInt128),
|
||||
context->Int128Ty));
|
||||
context.hasSameType(GetBasicQualType(eBasicTypeHalf), context.HalfTy));
|
||||
EXPECT_TRUE(
|
||||
context->hasSameType(GetBasicQualType(eBasicTypeLong), context->LongTy));
|
||||
EXPECT_TRUE(context->hasSameType(GetBasicQualType(eBasicTypeLongDouble),
|
||||
context->LongDoubleTy));
|
||||
context.hasSameType(GetBasicQualType(eBasicTypeInt), context.IntTy));
|
||||
EXPECT_TRUE(context.hasSameType(GetBasicQualType(eBasicTypeInt128),
|
||||
context.Int128Ty));
|
||||
EXPECT_TRUE(
|
||||
context->hasSameType(GetBasicQualType(eBasicTypeLongDoubleComplex),
|
||||
context->LongDoubleComplexTy));
|
||||
EXPECT_TRUE(context->hasSameType(GetBasicQualType(eBasicTypeLongLong),
|
||||
context->LongLongTy));
|
||||
EXPECT_TRUE(context->hasSameType(GetBasicQualType(eBasicTypeNullPtr),
|
||||
context->NullPtrTy));
|
||||
EXPECT_TRUE(context->hasSameType(GetBasicQualType(eBasicTypeObjCClass),
|
||||
context->getObjCClassType()));
|
||||
EXPECT_TRUE(context->hasSameType(GetBasicQualType(eBasicTypeObjCID),
|
||||
context->getObjCIdType()));
|
||||
EXPECT_TRUE(context->hasSameType(GetBasicQualType(eBasicTypeObjCSel),
|
||||
context->getObjCSelType()));
|
||||
EXPECT_TRUE(context->hasSameType(GetBasicQualType(eBasicTypeShort),
|
||||
context->ShortTy));
|
||||
EXPECT_TRUE(context->hasSameType(GetBasicQualType(eBasicTypeSignedChar),
|
||||
context->SignedCharTy));
|
||||
EXPECT_TRUE(context->hasSameType(GetBasicQualType(eBasicTypeUnsignedChar),
|
||||
context->UnsignedCharTy));
|
||||
EXPECT_TRUE(context->hasSameType(GetBasicQualType(eBasicTypeUnsignedInt),
|
||||
context->UnsignedIntTy));
|
||||
EXPECT_TRUE(context->hasSameType(GetBasicQualType(eBasicTypeUnsignedInt128),
|
||||
context->UnsignedInt128Ty));
|
||||
EXPECT_TRUE(context->hasSameType(GetBasicQualType(eBasicTypeUnsignedLong),
|
||||
context->UnsignedLongTy));
|
||||
EXPECT_TRUE(context->hasSameType(GetBasicQualType(eBasicTypeUnsignedLongLong),
|
||||
context->UnsignedLongLongTy));
|
||||
EXPECT_TRUE(context->hasSameType(GetBasicQualType(eBasicTypeUnsignedShort),
|
||||
context->UnsignedShortTy));
|
||||
context.hasSameType(GetBasicQualType(eBasicTypeLong), context.LongTy));
|
||||
EXPECT_TRUE(context.hasSameType(GetBasicQualType(eBasicTypeLongDouble),
|
||||
context.LongDoubleTy));
|
||||
EXPECT_TRUE(context.hasSameType(GetBasicQualType(eBasicTypeLongDoubleComplex),
|
||||
context.LongDoubleComplexTy));
|
||||
EXPECT_TRUE(context.hasSameType(GetBasicQualType(eBasicTypeLongLong),
|
||||
context.LongLongTy));
|
||||
EXPECT_TRUE(context.hasSameType(GetBasicQualType(eBasicTypeNullPtr),
|
||||
context.NullPtrTy));
|
||||
EXPECT_TRUE(context.hasSameType(GetBasicQualType(eBasicTypeObjCClass),
|
||||
context.getObjCClassType()));
|
||||
EXPECT_TRUE(context.hasSameType(GetBasicQualType(eBasicTypeObjCID),
|
||||
context.getObjCIdType()));
|
||||
EXPECT_TRUE(context.hasSameType(GetBasicQualType(eBasicTypeObjCSel),
|
||||
context.getObjCSelType()));
|
||||
EXPECT_TRUE(
|
||||
context->hasSameType(GetBasicQualType(eBasicTypeVoid), context->VoidTy));
|
||||
EXPECT_TRUE(context->hasSameType(GetBasicQualType(eBasicTypeWChar),
|
||||
context->WCharTy));
|
||||
context.hasSameType(GetBasicQualType(eBasicTypeShort), context.ShortTy));
|
||||
EXPECT_TRUE(context.hasSameType(GetBasicQualType(eBasicTypeSignedChar),
|
||||
context.SignedCharTy));
|
||||
EXPECT_TRUE(context.hasSameType(GetBasicQualType(eBasicTypeUnsignedChar),
|
||||
context.UnsignedCharTy));
|
||||
EXPECT_TRUE(context.hasSameType(GetBasicQualType(eBasicTypeUnsignedInt),
|
||||
context.UnsignedIntTy));
|
||||
EXPECT_TRUE(context.hasSameType(GetBasicQualType(eBasicTypeUnsignedInt128),
|
||||
context.UnsignedInt128Ty));
|
||||
EXPECT_TRUE(context.hasSameType(GetBasicQualType(eBasicTypeUnsignedLong),
|
||||
context.UnsignedLongTy));
|
||||
EXPECT_TRUE(context.hasSameType(GetBasicQualType(eBasicTypeUnsignedLongLong),
|
||||
context.UnsignedLongLongTy));
|
||||
EXPECT_TRUE(context.hasSameType(GetBasicQualType(eBasicTypeUnsignedShort),
|
||||
context.UnsignedShortTy));
|
||||
EXPECT_TRUE(
|
||||
context.hasSameType(GetBasicQualType(eBasicTypeVoid), context.VoidTy));
|
||||
EXPECT_TRUE(
|
||||
context.hasSameType(GetBasicQualType(eBasicTypeWChar), context.WCharTy));
|
||||
}
|
||||
|
||||
TEST_F(TestClangASTContext, TestGetBasicTypeFromName) {
|
||||
@@ -168,7 +167,7 @@ TEST_F(TestClangASTContext, TestGetBasicTypeFromName) {
|
||||
|
||||
void VerifyEncodingAndBitSize(ClangASTContext &clang_context,
|
||||
lldb::Encoding encoding, unsigned int bit_size) {
|
||||
clang::ASTContext *context = clang_context.getASTContext();
|
||||
clang::ASTContext &context = clang_context.getASTContext();
|
||||
|
||||
CompilerType type =
|
||||
clang_context.GetBuiltinTypeForEncodingAndBitSize(encoding, bit_size);
|
||||
@@ -179,7 +178,7 @@ void VerifyEncodingAndBitSize(ClangASTContext &clang_context,
|
||||
if (qtype.isNull())
|
||||
return;
|
||||
|
||||
uint64_t actual_size = context->getTypeSize(qtype);
|
||||
uint64_t actual_size = context.getTypeSize(qtype);
|
||||
EXPECT_EQ(bit_size, actual_size);
|
||||
|
||||
const clang::Type *type_ptr = qtype.getTypePtr();
|
||||
@@ -229,9 +228,9 @@ TEST_F(TestClangASTContext, TestBuiltinTypeForEncodingAndBitSize) {
|
||||
}
|
||||
|
||||
TEST_F(TestClangASTContext, TestIsClangType) {
|
||||
clang::ASTContext *context = m_ast->getASTContext();
|
||||
clang::ASTContext &context = m_ast->getASTContext();
|
||||
lldb::opaque_compiler_type_t bool_ctype =
|
||||
ClangASTContext::GetOpaqueCompilerType(context, lldb::eBasicTypeBool);
|
||||
ClangASTContext::GetOpaqueCompilerType(&context, lldb::eBasicTypeBool);
|
||||
CompilerType bool_type(m_ast.get(), bool_ctype);
|
||||
CompilerType record_type = m_ast->CreateRecordType(
|
||||
nullptr, lldb::eAccessPublic, "FooRecord", clang::TTK_Struct,
|
||||
@@ -392,11 +391,11 @@ TEST_F(TestClangASTContext, TestRecordHasFields) {
|
||||
TEST_F(TestClangASTContext, TemplateArguments) {
|
||||
ClangASTContext::TemplateParameterInfos infos;
|
||||
infos.names.push_back("T");
|
||||
infos.args.push_back(TemplateArgument(m_ast->getASTContext()->IntTy));
|
||||
infos.args.push_back(TemplateArgument(m_ast->getASTContext().IntTy));
|
||||
infos.names.push_back("I");
|
||||
llvm::APSInt arg(llvm::APInt(8, 47));
|
||||
infos.args.push_back(TemplateArgument(*m_ast->getASTContext(), arg,
|
||||
m_ast->getASTContext()->IntTy));
|
||||
infos.args.push_back(TemplateArgument(m_ast->getASTContext(), arg,
|
||||
m_ast->getASTContext().IntTy));
|
||||
|
||||
// template<typename T, int I> struct foo;
|
||||
ClassTemplateDecl *decl = m_ast->CreateClassTemplateDecl(
|
||||
@@ -421,11 +420,12 @@ TEST_F(TestClangASTContext, TemplateArguments) {
|
||||
CompilerType auto_type(
|
||||
m_ast.get(),
|
||||
m_ast->getASTContext()
|
||||
->getAutoType(ClangUtil::GetCanonicalQualType(typedef_type),
|
||||
clang::AutoTypeKeyword::Auto, false)
|
||||
.getAutoType(ClangUtil::GetCanonicalQualType(typedef_type),
|
||||
clang::AutoTypeKeyword::Auto, false)
|
||||
.getAsOpaquePtr());
|
||||
|
||||
CompilerType int_type(m_ast.get(), m_ast->getASTContext()->IntTy.getAsOpaquePtr());
|
||||
CompilerType int_type(m_ast.get(),
|
||||
m_ast->getASTContext().IntTy.getAsOpaquePtr());
|
||||
for (CompilerType t : {type, typedef_type, auto_type}) {
|
||||
SCOPED_TRACE(t.GetTypeName().AsCString());
|
||||
|
||||
@@ -454,27 +454,27 @@ static QualType makeConstInt(clang::ASTContext &ctxt) {
|
||||
}
|
||||
|
||||
TEST_F(TestClangASTContext, TestGetTypeClassDeclType) {
|
||||
clang::ASTContext &ctxt = *m_ast->getASTContext();
|
||||
clang::ASTContext &ctxt = m_ast->getASTContext();
|
||||
auto *nullptr_expr = new (ctxt) CXXNullPtrLiteralExpr(ctxt.NullPtrTy, SourceLocation());
|
||||
QualType t = ctxt.getDecltypeType(nullptr_expr, makeConstInt(ctxt));
|
||||
EXPECT_EQ(lldb::eTypeClassBuiltin, m_ast->GetTypeClass(t.getAsOpaquePtr()));
|
||||
}
|
||||
|
||||
TEST_F(TestClangASTContext, TestGetTypeClassTypeOf) {
|
||||
clang::ASTContext &ctxt = *m_ast->getASTContext();
|
||||
clang::ASTContext &ctxt = m_ast->getASTContext();
|
||||
QualType t = ctxt.getTypeOfType(makeConstInt(ctxt));
|
||||
EXPECT_EQ(lldb::eTypeClassBuiltin, m_ast->GetTypeClass(t.getAsOpaquePtr()));
|
||||
}
|
||||
|
||||
TEST_F(TestClangASTContext, TestGetTypeClassTypeOfExpr) {
|
||||
clang::ASTContext &ctxt = *m_ast->getASTContext();
|
||||
clang::ASTContext &ctxt = m_ast->getASTContext();
|
||||
auto *nullptr_expr = new (ctxt) CXXNullPtrLiteralExpr(ctxt.NullPtrTy, SourceLocation());
|
||||
QualType t = ctxt.getTypeOfExprType(nullptr_expr);
|
||||
EXPECT_EQ(lldb::eTypeClassBuiltin, m_ast->GetTypeClass(t.getAsOpaquePtr()));
|
||||
}
|
||||
|
||||
TEST_F(TestClangASTContext, TestGetTypeClassNested) {
|
||||
clang::ASTContext &ctxt = *m_ast->getASTContext();
|
||||
clang::ASTContext &ctxt = m_ast->getASTContext();
|
||||
QualType t_base = ctxt.getTypeOfType(makeConstInt(ctxt));
|
||||
QualType t = ctxt.getTypeOfType(t_base);
|
||||
EXPECT_EQ(lldb::eTypeClassBuiltin, m_ast->GetTypeClass(t.getAsOpaquePtr()));
|
||||
|
||||
@@ -53,7 +53,7 @@ TEST_F(TestClangASTImporter, CopyDeclTagDecl) {
|
||||
|
||||
ClangASTImporter importer;
|
||||
clang::Decl *imported =
|
||||
importer.CopyDecl(target_ast->getASTContext(), source.record_decl);
|
||||
importer.CopyDecl(&target_ast->getASTContext(), source.record_decl);
|
||||
ASSERT_NE(nullptr, imported);
|
||||
|
||||
// Check that we got the correct decl by just comparing their qualified name.
|
||||
@@ -66,7 +66,7 @@ TEST_F(TestClangASTImporter, CopyDeclTagDecl) {
|
||||
// Check that origin was set for the imported declaration.
|
||||
ClangASTImporter::DeclOrigin origin = importer.GetDeclOrigin(imported);
|
||||
EXPECT_TRUE(origin.Valid());
|
||||
EXPECT_EQ(origin.ctx, source.ast->getASTContext());
|
||||
EXPECT_EQ(origin.ctx, &source.ast->getASTContext());
|
||||
EXPECT_EQ(origin.decl, source.record_decl);
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ TEST_F(TestClangASTImporter, CopyTypeTagDecl) {
|
||||
ClangASTImporter::DeclOrigin origin =
|
||||
importer.GetDeclOrigin(imported_tag_decl);
|
||||
EXPECT_TRUE(origin.Valid());
|
||||
EXPECT_EQ(origin.ctx, source.ast->getASTContext());
|
||||
EXPECT_EQ(origin.ctx, &source.ast->getASTContext());
|
||||
EXPECT_EQ(origin.decl, source.record_decl);
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ TEST_F(TestClangASTImporter, DeportDeclTagDecl) {
|
||||
|
||||
ClangASTImporter importer;
|
||||
clang::Decl *imported =
|
||||
importer.DeportDecl(target_ast->getASTContext(), source.record_decl);
|
||||
importer.DeportDecl(&target_ast->getASTContext(), source.record_decl);
|
||||
ASSERT_NE(nullptr, imported);
|
||||
|
||||
// Check that we got the correct decl by just comparing their qualified name.
|
||||
@@ -150,7 +150,7 @@ TEST_F(TestClangASTImporter, MetadataPropagation) {
|
||||
|
||||
ClangASTImporter importer;
|
||||
clang::Decl *imported =
|
||||
importer.CopyDecl(target_ast->getASTContext(), source.record_decl);
|
||||
importer.CopyDecl(&target_ast->getASTContext(), source.record_decl);
|
||||
ASSERT_NE(nullptr, imported);
|
||||
|
||||
// Check that we got the same Metadata.
|
||||
@@ -172,12 +172,12 @@ TEST_F(TestClangASTImporter, MetadataPropagationIndirectImport) {
|
||||
|
||||
ClangASTImporter importer;
|
||||
clang::Decl *temporary_imported =
|
||||
importer.CopyDecl(temporary_ast->getASTContext(), source.record_decl);
|
||||
importer.CopyDecl(&temporary_ast->getASTContext(), source.record_decl);
|
||||
ASSERT_NE(nullptr, temporary_imported);
|
||||
|
||||
std::unique_ptr<ClangASTContext> target_ast = clang_utils::createAST();
|
||||
clang::Decl *imported =
|
||||
importer.CopyDecl(target_ast->getASTContext(), temporary_imported);
|
||||
importer.CopyDecl(&target_ast->getASTContext(), temporary_imported);
|
||||
ASSERT_NE(nullptr, imported);
|
||||
|
||||
// Check that we got the same Metadata.
|
||||
@@ -196,7 +196,7 @@ TEST_F(TestClangASTImporter, MetadataPropagationAfterCopying) {
|
||||
|
||||
ClangASTImporter importer;
|
||||
clang::Decl *imported =
|
||||
importer.CopyDecl(target_ast->getASTContext(), source.record_decl);
|
||||
importer.CopyDecl(&target_ast->getASTContext(), source.record_decl);
|
||||
ASSERT_NE(nullptr, imported);
|
||||
|
||||
// The TagDecl has been imported. Now set the metadata of the source and
|
||||
|
||||
@@ -17,8 +17,8 @@ namespace lldb_private {
|
||||
namespace clang_utils {
|
||||
inline clang::DeclarationName getDeclarationName(ClangASTContext &ast,
|
||||
llvm::StringRef name) {
|
||||
clang::IdentifierInfo &II = ast.getASTContext()->Idents.get(name);
|
||||
return ast.getASTContext()->DeclarationNames.getIdentifier(&II);
|
||||
clang::IdentifierInfo &II = ast.getASTContext().Idents.get(name);
|
||||
return ast.getASTContext().DeclarationNames.getIdentifier(&II);
|
||||
}
|
||||
|
||||
inline std::unique_ptr<ClangASTContext> createAST() {
|
||||
@@ -26,7 +26,7 @@ inline std::unique_ptr<ClangASTContext> createAST() {
|
||||
}
|
||||
|
||||
inline CompilerType createRecord(ClangASTContext &ast, llvm::StringRef name) {
|
||||
return ast.CreateRecordType(ast.getASTContext()->getTranslationUnitDecl(),
|
||||
return ast.CreateRecordType(ast.getASTContext().getTranslationUnitDecl(),
|
||||
lldb::AccessType::eAccessPublic, name, 0,
|
||||
lldb::LanguageType::eLanguageTypeC);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user