forked from OSchip/llvm-project
[lldb] Remove some calls to GetASTContext
GetASTContext is really expensive to call as it makes use of the global mapping from ASTContext to ClangASTContext. This replaces all calls where we already have the ClangASTContext around and don't need to call GetASTContext again.
This commit is contained in:
parent
073cdb2390
commit
b036f557ce
|
@ -816,9 +816,8 @@ void ClangExpressionDeclMap::LookUpLldbClass(NameSearchContext &context,
|
|||
|
||||
QualType class_qual_type(class_decl->getTypeForDecl(), 0);
|
||||
|
||||
TypeFromUser class_user_type(
|
||||
class_qual_type.getAsOpaquePtr(),
|
||||
ClangASTContext::GetASTContext(&class_decl->getASTContext()));
|
||||
TypeFromUser class_user_type(class_qual_type.getAsOpaquePtr(),
|
||||
function_decl_ctx.GetTypeSystem());
|
||||
|
||||
LLDB_LOG(log, " CEDM::FEVD[{0}] Adding type for $__lldb_class: {1}",
|
||||
current_id, class_qual_type.getAsString());
|
||||
|
@ -831,9 +830,8 @@ void ClangExpressionDeclMap::LookUpLldbClass(NameSearchContext &context,
|
|||
QualType class_pointer_type =
|
||||
method_decl->getASTContext().getPointerType(class_qual_type);
|
||||
|
||||
TypeFromUser self_user_type(
|
||||
class_pointer_type.getAsOpaquePtr(),
|
||||
ClangASTContext::GetASTContext(&method_decl->getASTContext()));
|
||||
TypeFromUser self_user_type(class_pointer_type.getAsOpaquePtr(),
|
||||
function_decl_ctx.GetTypeSystem());
|
||||
|
||||
m_struct_vars->m_object_pointer_type = self_user_type;
|
||||
}
|
||||
|
@ -926,9 +924,8 @@ void ClangExpressionDeclMap::LookUpLldbObjCClass(NameSearchContext &context,
|
|||
return; // This is unlikely, but we have seen crashes where this
|
||||
// occurred
|
||||
|
||||
TypeFromUser class_user_type(
|
||||
QualType(interface_type, 0).getAsOpaquePtr(),
|
||||
ClangASTContext::GetASTContext(&method_decl->getASTContext()));
|
||||
TypeFromUser class_user_type(QualType(interface_type, 0).getAsOpaquePtr(),
|
||||
function_decl_ctx.GetTypeSystem());
|
||||
|
||||
LLDB_LOG(log, " FEVD[{0}] Adding type for $__lldb_objc_class: {1}",
|
||||
current_id, ClangUtil::ToString(interface_type));
|
||||
|
@ -942,18 +939,16 @@ void ClangExpressionDeclMap::LookUpLldbObjCClass(NameSearchContext &context,
|
|||
method_decl->getASTContext().getObjCObjectPointerType(
|
||||
QualType(interface_type, 0));
|
||||
|
||||
TypeFromUser self_user_type(
|
||||
class_pointer_type.getAsOpaquePtr(),
|
||||
ClangASTContext::GetASTContext(&method_decl->getASTContext()));
|
||||
TypeFromUser self_user_type(class_pointer_type.getAsOpaquePtr(),
|
||||
function_decl_ctx.GetTypeSystem());
|
||||
|
||||
m_struct_vars->m_object_pointer_type = self_user_type;
|
||||
} else {
|
||||
// self is a Class pointer
|
||||
QualType class_type = method_decl->getASTContext().getObjCClassType();
|
||||
|
||||
TypeFromUser self_user_type(
|
||||
class_type.getAsOpaquePtr(),
|
||||
ClangASTContext::GetASTContext(&method_decl->getASTContext()));
|
||||
TypeFromUser self_user_type(class_type.getAsOpaquePtr(),
|
||||
function_decl_ctx.GetTypeSystem());
|
||||
|
||||
m_struct_vars->m_object_pointer_type = self_user_type;
|
||||
}
|
||||
|
|
|
@ -118,31 +118,24 @@ GetBuiltinTypeForPDBEncodingAndBitSize(ClangASTContext &clang_ast,
|
|||
return clang_ast.GetBasicType(eBasicTypeBool);
|
||||
case PDB_BuiltinType::Long:
|
||||
if (width == ast.getTypeSize(ast.LongTy))
|
||||
return CompilerType(ClangASTContext::GetASTContext(&ast),
|
||||
ast.LongTy.getAsOpaquePtr());
|
||||
return CompilerType(&clang_ast, ast.LongTy.getAsOpaquePtr());
|
||||
if (width == ast.getTypeSize(ast.LongLongTy))
|
||||
return CompilerType(ClangASTContext::GetASTContext(&ast),
|
||||
ast.LongLongTy.getAsOpaquePtr());
|
||||
return CompilerType(&clang_ast, ast.LongLongTy.getAsOpaquePtr());
|
||||
break;
|
||||
case PDB_BuiltinType::ULong:
|
||||
if (width == ast.getTypeSize(ast.UnsignedLongTy))
|
||||
return CompilerType(ClangASTContext::GetASTContext(&ast),
|
||||
ast.UnsignedLongTy.getAsOpaquePtr());
|
||||
return CompilerType(&clang_ast, ast.UnsignedLongTy.getAsOpaquePtr());
|
||||
if (width == ast.getTypeSize(ast.UnsignedLongLongTy))
|
||||
return CompilerType(ClangASTContext::GetASTContext(&ast),
|
||||
ast.UnsignedLongLongTy.getAsOpaquePtr());
|
||||
return CompilerType(&clang_ast, ast.UnsignedLongLongTy.getAsOpaquePtr());
|
||||
break;
|
||||
case PDB_BuiltinType::WCharT:
|
||||
if (width == ast.getTypeSize(ast.WCharTy))
|
||||
return CompilerType(ClangASTContext::GetASTContext(&ast),
|
||||
ast.WCharTy.getAsOpaquePtr());
|
||||
return CompilerType(&clang_ast, ast.WCharTy.getAsOpaquePtr());
|
||||
break;
|
||||
case PDB_BuiltinType::Char16:
|
||||
return CompilerType(ClangASTContext::GetASTContext(&ast),
|
||||
ast.Char16Ty.getAsOpaquePtr());
|
||||
return CompilerType(&clang_ast, ast.Char16Ty.getAsOpaquePtr());
|
||||
case PDB_BuiltinType::Char32:
|
||||
return CompilerType(ClangASTContext::GetASTContext(&ast),
|
||||
ast.Char32Ty.getAsOpaquePtr());
|
||||
return CompilerType(&clang_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
|
||||
|
|
|
@ -902,7 +902,7 @@ CompilerType ClangASTContext::GetBasicType(lldb::BasicType basic_type) {
|
|||
GetOpaqueCompilerType(&ast, basic_type);
|
||||
|
||||
if (clang_type)
|
||||
return CompilerType(GetASTContext(&ast), clang_type);
|
||||
return CompilerType(this, clang_type);
|
||||
return CompilerType();
|
||||
}
|
||||
|
||||
|
@ -2736,9 +2736,7 @@ bool ClangASTContext::IsVectorType(lldb::opaque_compiler_type_t type,
|
|||
|
||||
bool ClangASTContext::IsRuntimeGeneratedType(
|
||||
lldb::opaque_compiler_type_t type) {
|
||||
clang::DeclContext *decl_ctx =
|
||||
ClangASTContext::GetASTContext(&getASTContext())
|
||||
->GetDeclContextForType(GetQualType(type));
|
||||
clang::DeclContext *decl_ctx = GetDeclContextForType(GetQualType(type));
|
||||
if (!decl_ctx)
|
||||
return false;
|
||||
|
||||
|
@ -7757,9 +7755,8 @@ clang::ObjCMethodDecl *ClangASTContext::AddMethodToObjCObjectType(
|
|||
clang::SourceLocation(), // endLoc,
|
||||
method_selector, method_function_prototype->getReturnType(),
|
||||
nullptr, // TypeSourceInfo *ResultTInfo,
|
||||
ClangASTContext::GetASTContext(&ast)->GetDeclContextForType(
|
||||
ClangUtil::GetQualType(type)),
|
||||
isInstance, isVariadic, isPropertyAccessor, isSynthesizedAccessorStub,
|
||||
lldb_ast->GetDeclContextForType(ClangUtil::GetQualType(type)), isInstance,
|
||||
isVariadic, isPropertyAccessor, isSynthesizedAccessorStub,
|
||||
isImplicitlyDeclared, isDefined, impControl, HasRelatedResultType);
|
||||
|
||||
if (objc_method_decl == nullptr)
|
||||
|
|
Loading…
Reference in New Issue