Author: Raphael Isemann
Date: 2019-12-29T16:33:40+01:00
New Revision: 0460a6bdf2f2b6c98eb6c72621baaf445aca34d5

URL: 
https://github.com/llvm/llvm-project/commit/0460a6bdf2f2b6c98eb6c72621baaf445aca34d5
DIFF: 
https://github.com/llvm/llvm-project/commit/0460a6bdf2f2b6c98eb6c72621baaf445aca34d5.diff

LOG: [lldb][NFC] Remove most GetASTContext calls in AST metadata code

Added: 
    

Modified: 
    lldb/include/lldb/Symbol/ClangASTContext.h
    lldb/source/Symbol/ClangASTContext.cpp
    lldb/source/Symbol/ClangASTImporter.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Symbol/ClangASTContext.h 
b/lldb/include/lldb/Symbol/ClangASTContext.h
index e25eae8180df..cb9b89cf3e10 100644
--- a/lldb/include/lldb/Symbol/ClangASTContext.h
+++ b/lldb/include/lldb/Symbol/ClangASTContext.h
@@ -132,20 +132,10 @@ class ClangASTContext : public TypeSystem {
   void SetMetadataAsUserID(const clang::Type *type, lldb::user_id_t user_id);
 
   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);
-  }
-
-  static ClangASTMetadata *GetMetadata(clang::ASTContext *ast,
-                                       const clang::Decl *object);
 
-  ClangASTMetadata *GetMetadata(const clang::Type *object) {
-    return GetMetadata(&getASTContext(), object);
-  }
-
-  static ClangASTMetadata *GetMetadata(clang::ASTContext *ast,
-                                       const clang::Type *object);
+  void SetMetadata(const clang::Type *object, ClangASTMetadata &meta_data);
+  ClangASTMetadata *GetMetadata(const clang::Decl *object);
+  ClangASTMetadata *GetMetadata(const clang::Type *object);
 
   // Basic Types
   CompilerType GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding,

diff  --git a/lldb/source/Symbol/ClangASTContext.cpp 
b/lldb/source/Symbol/ClangASTContext.cpp
index 089d0177c8fc..5c78e9ff0c98 100644
--- a/lldb/source/Symbol/ClangASTContext.cpp
+++ b/lldb/source/Symbol/ClangASTContext.cpp
@@ -2335,20 +2335,16 @@ void ClangASTContext::SetMetadata(const clang::Type 
*object,
   m_type_metadata[object] = metadata;
 }
 
-ClangASTMetadata *ClangASTContext::GetMetadata(clang::ASTContext *ast,
-                                               const clang::Decl *object) {
-  ClangASTContext *self = GetASTContext(ast);
-  auto It = self->m_decl_metadata.find(object);
-  if (It != self->m_decl_metadata.end())
+ClangASTMetadata *ClangASTContext::GetMetadata(const clang::Decl *object) {
+  auto It = m_decl_metadata.find(object);
+  if (It != m_decl_metadata.end())
     return &It->second;
   return nullptr;
 }
 
-ClangASTMetadata *ClangASTContext::GetMetadata(clang::ASTContext *ast,
-                                               const clang::Type *object) {
-  ClangASTContext *self = GetASTContext(ast);
-  auto It = self->m_type_metadata.find(object);
-  if (It != self->m_type_metadata.end())
+ClangASTMetadata *ClangASTContext::GetMetadata(const clang::Type *object) {
+  auto It = m_type_metadata.find(object);
+  if (It != m_type_metadata.end())
     return &It->second;
   return nullptr;
 }
@@ -2746,8 +2742,7 @@ bool ClangASTContext::IsRuntimeGeneratedType(
   clang::ObjCInterfaceDecl *result_iface_decl =
       llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl_ctx);
 
-  ClangASTMetadata *ast_metadata =
-      ClangASTContext::GetMetadata(&getASTContext(), result_iface_decl);
+  ClangASTMetadata *ast_metadata = GetMetadata(result_iface_decl);
   if (!ast_metadata)
     return false;
   return (ast_metadata->GetISAPtr() != 0);
@@ -3398,8 +3393,7 @@ bool 
ClangASTContext::IsPossibleDynamicType(lldb::opaque_compiler_type_t type,
             if (is_complete)
               success = cxx_record_decl->isDynamicClass();
             else {
-              ClangASTMetadata *metadata = ClangASTContext::GetMetadata(
-                  &getASTContext(), cxx_record_decl);
+              ClangASTMetadata *metadata = GetMetadata(cxx_record_decl);
               if (metadata)
                 success = metadata->GetIsDynamicCXXType();
               else {
@@ -8729,8 +8723,7 @@ void 
ClangASTContext::DumpTypeDescription(lldb::opaque_compiler_type_t type) {
 
   CompilerType ct(this, type);
   const clang::Type *clang_type = ClangUtil::GetQualType(ct).getTypePtr();
-  ClangASTMetadata *metadata =
-      ClangASTContext::GetMetadata(&getASTContext(), clang_type);
+  ClangASTMetadata *metadata = GetMetadata(clang_type);
   if (metadata) {
     metadata->Dump(&s);
   }
@@ -9268,8 +9261,7 @@ bool ClangASTContext::DeclContextIsClassMethod(
       return true;
     } else if (clang::FunctionDecl *function_decl =
                    llvm::dyn_cast<clang::FunctionDecl>(decl_ctx)) {
-      ClangASTMetadata *metadata =
-          GetMetadata(&decl_ctx->getParentASTContext(), function_decl);
+      ClangASTMetadata *metadata = GetMetadata(function_decl);
       if (metadata && metadata->HasObjectPtr()) {
         if (is_instance_method_ptr)
           *is_instance_method_ptr = true;
@@ -9347,10 +9339,8 @@ ClangASTContext::DeclContextGetAsNamespaceDecl(const 
CompilerDeclContext &dc) {
 ClangASTMetadata *
 ClangASTContext::DeclContextGetMetaData(const CompilerDeclContext &dc,
                                         const Decl *object) {
-  clang::ASTContext *ast = DeclContextGetClangASTContext(dc);
-  if (ast)
-    return ClangASTContext::GetMetadata(ast, object);
-  return nullptr;
+  ClangASTContext *ast = llvm::cast<ClangASTContext>(dc.GetTypeSystem());
+  return ast->GetMetadata(object);
 }
 
 clang::ASTContext *

diff  --git a/lldb/source/Symbol/ClangASTImporter.cpp 
b/lldb/source/Symbol/ClangASTImporter.cpp
index 2f1b350d96e5..b2debe1a2e1a 100644
--- a/lldb/source/Symbol/ClangASTImporter.cpp
+++ b/lldb/source/Symbol/ClangASTImporter.cpp
@@ -737,9 +737,12 @@ bool ClangASTImporter::RequireCompleteType(clang::QualType 
type) {
 ClangASTMetadata *ClangASTImporter::GetDeclMetadata(const clang::Decl *decl) {
   DeclOrigin decl_origin = GetDeclOrigin(decl);
 
-  if (decl_origin.Valid())
-    return ClangASTContext::GetMetadata(decl_origin.ctx, decl_origin.decl);
-  return ClangASTContext::GetMetadata(&decl->getASTContext(), decl);
+  if (decl_origin.Valid()) {
+    ClangASTContext *ast = ClangASTContext::GetASTContext(decl_origin.ctx);
+    return ast->GetMetadata(decl_origin.decl);
+  }
+  ClangASTContext *ast = 
ClangASTContext::GetASTContext(&decl->getASTContext());
+  return ast->GetMetadata(decl);
 }
 
 ClangASTImporter::DeclOrigin


        
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to