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);
|
QualType class_qual_type(class_decl->getTypeForDecl(), 0);
|
||||||
|
|
||||||
TypeFromUser class_user_type(
|
TypeFromUser class_user_type(class_qual_type.getAsOpaquePtr(),
|
||||||
class_qual_type.getAsOpaquePtr(),
|
function_decl_ctx.GetTypeSystem());
|
||||||
ClangASTContext::GetASTContext(&class_decl->getASTContext()));
|
|
||||||
|
|
||||||
LLDB_LOG(log, " CEDM::FEVD[{0}] Adding type for $__lldb_class: {1}",
|
LLDB_LOG(log, " CEDM::FEVD[{0}] Adding type for $__lldb_class: {1}",
|
||||||
current_id, class_qual_type.getAsString());
|
current_id, class_qual_type.getAsString());
|
||||||
|
@ -831,9 +830,8 @@ void ClangExpressionDeclMap::LookUpLldbClass(NameSearchContext &context,
|
||||||
QualType class_pointer_type =
|
QualType class_pointer_type =
|
||||||
method_decl->getASTContext().getPointerType(class_qual_type);
|
method_decl->getASTContext().getPointerType(class_qual_type);
|
||||||
|
|
||||||
TypeFromUser self_user_type(
|
TypeFromUser self_user_type(class_pointer_type.getAsOpaquePtr(),
|
||||||
class_pointer_type.getAsOpaquePtr(),
|
function_decl_ctx.GetTypeSystem());
|
||||||
ClangASTContext::GetASTContext(&method_decl->getASTContext()));
|
|
||||||
|
|
||||||
m_struct_vars->m_object_pointer_type = self_user_type;
|
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
|
return; // This is unlikely, but we have seen crashes where this
|
||||||
// occurred
|
// occurred
|
||||||
|
|
||||||
TypeFromUser class_user_type(
|
TypeFromUser class_user_type(QualType(interface_type, 0).getAsOpaquePtr(),
|
||||||
QualType(interface_type, 0).getAsOpaquePtr(),
|
function_decl_ctx.GetTypeSystem());
|
||||||
ClangASTContext::GetASTContext(&method_decl->getASTContext()));
|
|
||||||
|
|
||||||
LLDB_LOG(log, " FEVD[{0}] Adding type for $__lldb_objc_class: {1}",
|
LLDB_LOG(log, " FEVD[{0}] Adding type for $__lldb_objc_class: {1}",
|
||||||
current_id, ClangUtil::ToString(interface_type));
|
current_id, ClangUtil::ToString(interface_type));
|
||||||
|
@ -942,18 +939,16 @@ void ClangExpressionDeclMap::LookUpLldbObjCClass(NameSearchContext &context,
|
||||||
method_decl->getASTContext().getObjCObjectPointerType(
|
method_decl->getASTContext().getObjCObjectPointerType(
|
||||||
QualType(interface_type, 0));
|
QualType(interface_type, 0));
|
||||||
|
|
||||||
TypeFromUser self_user_type(
|
TypeFromUser self_user_type(class_pointer_type.getAsOpaquePtr(),
|
||||||
class_pointer_type.getAsOpaquePtr(),
|
function_decl_ctx.GetTypeSystem());
|
||||||
ClangASTContext::GetASTContext(&method_decl->getASTContext()));
|
|
||||||
|
|
||||||
m_struct_vars->m_object_pointer_type = self_user_type;
|
m_struct_vars->m_object_pointer_type = self_user_type;
|
||||||
} else {
|
} else {
|
||||||
// self is a Class pointer
|
// self is a Class pointer
|
||||||
QualType class_type = method_decl->getASTContext().getObjCClassType();
|
QualType class_type = method_decl->getASTContext().getObjCClassType();
|
||||||
|
|
||||||
TypeFromUser self_user_type(
|
TypeFromUser self_user_type(class_type.getAsOpaquePtr(),
|
||||||
class_type.getAsOpaquePtr(),
|
function_decl_ctx.GetTypeSystem());
|
||||||
ClangASTContext::GetASTContext(&method_decl->getASTContext()));
|
|
||||||
|
|
||||||
m_struct_vars->m_object_pointer_type = self_user_type;
|
m_struct_vars->m_object_pointer_type = self_user_type;
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,31 +118,24 @@ GetBuiltinTypeForPDBEncodingAndBitSize(ClangASTContext &clang_ast,
|
||||||
return clang_ast.GetBasicType(eBasicTypeBool);
|
return clang_ast.GetBasicType(eBasicTypeBool);
|
||||||
case PDB_BuiltinType::Long:
|
case PDB_BuiltinType::Long:
|
||||||
if (width == ast.getTypeSize(ast.LongTy))
|
if (width == ast.getTypeSize(ast.LongTy))
|
||||||
return CompilerType(ClangASTContext::GetASTContext(&ast),
|
return CompilerType(&clang_ast, ast.LongTy.getAsOpaquePtr());
|
||||||
ast.LongTy.getAsOpaquePtr());
|
|
||||||
if (width == ast.getTypeSize(ast.LongLongTy))
|
if (width == ast.getTypeSize(ast.LongLongTy))
|
||||||
return CompilerType(ClangASTContext::GetASTContext(&ast),
|
return CompilerType(&clang_ast, ast.LongLongTy.getAsOpaquePtr());
|
||||||
ast.LongLongTy.getAsOpaquePtr());
|
|
||||||
break;
|
break;
|
||||||
case PDB_BuiltinType::ULong:
|
case PDB_BuiltinType::ULong:
|
||||||
if (width == ast.getTypeSize(ast.UnsignedLongTy))
|
if (width == ast.getTypeSize(ast.UnsignedLongTy))
|
||||||
return CompilerType(ClangASTContext::GetASTContext(&ast),
|
return CompilerType(&clang_ast, ast.UnsignedLongTy.getAsOpaquePtr());
|
||||||
ast.UnsignedLongTy.getAsOpaquePtr());
|
|
||||||
if (width == ast.getTypeSize(ast.UnsignedLongLongTy))
|
if (width == ast.getTypeSize(ast.UnsignedLongLongTy))
|
||||||
return CompilerType(ClangASTContext::GetASTContext(&ast),
|
return CompilerType(&clang_ast, ast.UnsignedLongLongTy.getAsOpaquePtr());
|
||||||
ast.UnsignedLongLongTy.getAsOpaquePtr());
|
|
||||||
break;
|
break;
|
||||||
case PDB_BuiltinType::WCharT:
|
case PDB_BuiltinType::WCharT:
|
||||||
if (width == ast.getTypeSize(ast.WCharTy))
|
if (width == ast.getTypeSize(ast.WCharTy))
|
||||||
return CompilerType(ClangASTContext::GetASTContext(&ast),
|
return CompilerType(&clang_ast, ast.WCharTy.getAsOpaquePtr());
|
||||||
ast.WCharTy.getAsOpaquePtr());
|
|
||||||
break;
|
break;
|
||||||
case PDB_BuiltinType::Char16:
|
case PDB_BuiltinType::Char16:
|
||||||
return CompilerType(ClangASTContext::GetASTContext(&ast),
|
return CompilerType(&clang_ast, ast.Char16Ty.getAsOpaquePtr());
|
||||||
ast.Char16Ty.getAsOpaquePtr());
|
|
||||||
case PDB_BuiltinType::Char32:
|
case PDB_BuiltinType::Char32:
|
||||||
return CompilerType(ClangASTContext::GetASTContext(&ast),
|
return CompilerType(&clang_ast, ast.Char32Ty.getAsOpaquePtr());
|
||||||
ast.Char32Ty.getAsOpaquePtr());
|
|
||||||
case PDB_BuiltinType::Float:
|
case PDB_BuiltinType::Float:
|
||||||
// Note: types `long double` and `double` have same bit size in MSVC and
|
// 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
|
// 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);
|
GetOpaqueCompilerType(&ast, basic_type);
|
||||||
|
|
||||||
if (clang_type)
|
if (clang_type)
|
||||||
return CompilerType(GetASTContext(&ast), clang_type);
|
return CompilerType(this, clang_type);
|
||||||
return CompilerType();
|
return CompilerType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2736,9 +2736,7 @@ bool ClangASTContext::IsVectorType(lldb::opaque_compiler_type_t type,
|
||||||
|
|
||||||
bool ClangASTContext::IsRuntimeGeneratedType(
|
bool ClangASTContext::IsRuntimeGeneratedType(
|
||||||
lldb::opaque_compiler_type_t type) {
|
lldb::opaque_compiler_type_t type) {
|
||||||
clang::DeclContext *decl_ctx =
|
clang::DeclContext *decl_ctx = GetDeclContextForType(GetQualType(type));
|
||||||
ClangASTContext::GetASTContext(&getASTContext())
|
|
||||||
->GetDeclContextForType(GetQualType(type));
|
|
||||||
if (!decl_ctx)
|
if (!decl_ctx)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -7757,9 +7755,8 @@ clang::ObjCMethodDecl *ClangASTContext::AddMethodToObjCObjectType(
|
||||||
clang::SourceLocation(), // endLoc,
|
clang::SourceLocation(), // endLoc,
|
||||||
method_selector, method_function_prototype->getReturnType(),
|
method_selector, method_function_prototype->getReturnType(),
|
||||||
nullptr, // TypeSourceInfo *ResultTInfo,
|
nullptr, // TypeSourceInfo *ResultTInfo,
|
||||||
ClangASTContext::GetASTContext(&ast)->GetDeclContextForType(
|
lldb_ast->GetDeclContextForType(ClangUtil::GetQualType(type)), isInstance,
|
||||||
ClangUtil::GetQualType(type)),
|
isVariadic, isPropertyAccessor, isSynthesizedAccessorStub,
|
||||||
isInstance, isVariadic, isPropertyAccessor, isSynthesizedAccessorStub,
|
|
||||||
isImplicitlyDeclared, isDefined, impControl, HasRelatedResultType);
|
isImplicitlyDeclared, isDefined, impControl, HasRelatedResultType);
|
||||||
|
|
||||||
if (objc_method_decl == nullptr)
|
if (objc_method_decl == nullptr)
|
||||||
|
|
Loading…
Reference in New Issue