[lldb][NFC] Remove TypeSystemClang::GetASTContext calls in IRForTarget
authorRaphael Isemann <teemperor@gmail.com>
Thu, 30 Jan 2020 10:53:41 +0000 (11:53 +0100)
committerRaphael Isemann <teemperor@gmail.com>
Thu, 30 Jan 2020 11:07:19 +0000 (12:07 +0100)
Similar to previous commits, this just replaces the lookup in the
global map with the reference to the TypeSystemClang instance we already
have in this context.

lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp

index 52fb0d1..2b711db 100644 (file)
@@ -356,6 +356,10 @@ public:
   ///     True if lookup succeeded; false otherwise.
   ClangASTImporter::DeclOrigin GetDeclOrigin(const clang::Decl *decl);
 
+  /// Returns the TypeSystem that uses this ClangASTSource instance as it's
+  /// ExternalASTSource.
+  TypeSystemClang *GetTypeSystem() const { return m_clang_ast_context; }
+
 protected:
   bool FindObjCMethodDeclsWithOrigin(
       unsigned int current_id, NameSearchContext &context,
index 0a0314d..bcf13e5 100644 (file)
@@ -283,17 +283,13 @@ bool IRForTarget::CreateResultVariable(llvm::Function &llvm_function) {
       clang::QualType element_qual_type = pointer_pointertype->getPointeeType();
 
       m_result_type = lldb_private::TypeFromParser(
-          element_qual_type.getAsOpaquePtr(),
-          lldb_private::TypeSystemClang::GetASTContext(
-              &result_decl->getASTContext()));
+          m_decl_map->GetTypeSystem()->GetType(element_qual_type));
     } else if (pointer_objcobjpointertype) {
       clang::QualType element_qual_type =
           clang::QualType(pointer_objcobjpointertype->getObjectType(), 0);
 
       m_result_type = lldb_private::TypeFromParser(
-          element_qual_type.getAsOpaquePtr(),
-          lldb_private::TypeSystemClang::GetASTContext(
-              &result_decl->getASTContext()));
+          m_decl_map->GetTypeSystem()->GetType(element_qual_type));
     } else {
       LLDB_LOG(log, "Expected result to have pointer type, but it did not");
 
@@ -305,9 +301,7 @@ bool IRForTarget::CreateResultVariable(llvm::Function &llvm_function) {
     }
   } else {
     m_result_type = lldb_private::TypeFromParser(
-        result_var->getType().getAsOpaquePtr(),
-        lldb_private::TypeSystemClang::GetASTContext(
-            &result_decl->getASTContext()));
+        m_decl_map->GetTypeSystem()->GetType(result_var->getType()));
   }
 
   lldb::TargetSP target_sp(m_execution_unit.GetTarget());
@@ -1094,8 +1088,7 @@ bool IRForTarget::RewritePersistentAlloc(llvm::Instruction *persistent_alloc) {
   clang::VarDecl *decl = reinterpret_cast<clang::VarDecl *>(ptr);
 
   lldb_private::TypeFromParser result_decl_type(
-      decl->getType().getAsOpaquePtr(),
-      lldb_private::TypeSystemClang::GetASTContext(&decl->getASTContext()));
+      m_decl_map->GetTypeSystem()->GetType(decl->getType()));
 
   StringRef decl_name(decl->getName());
   lldb_private::ConstString persistent_variable_name(decl_name.data(),
@@ -1225,10 +1218,8 @@ bool IRForTarget::MaybeHandleVariable(Value *llvm_value_ptr) {
     if (value_decl == nullptr)
       return false;
 
-    lldb_private::CompilerType compiler_type(
-        lldb_private::TypeSystemClang::GetASTContext(
-            &value_decl->getASTContext()),
-        value_decl->getType().getAsOpaquePtr());
+    lldb_private::CompilerType compiler_type =
+        m_decl_map->GetTypeSystem()->GetType(value_decl->getType());
 
     const Type *value_type = nullptr;