teemperor created this revision.
teemperor added reviewers: vsk, aprantl.
Herald added a subscriber: lldb-commits.

Now that we moved the BuiltinContext and SelectorTable to the
CompilerInstance, we can also get rid of manually creating our
own ASTContext, but just use the one from the CompilerInstance
(which will be created with the same settings).


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D51253

Files:
  source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp


Index: source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
===================================================================
--- source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -517,28 +517,24 @@
   builtin_context.initializeBuiltins(PP.getIdentifierTable(),
                                      m_compiler->getLangOpts());
 
-  std::unique_ptr<clang::ASTContext> ast_context(
-      new ASTContext(m_compiler->getLangOpts(), m_compiler->getSourceManager(),
-                     m_compiler->getPreprocessor().getIdentifierTable(),
-                     PP.getSelectorTable(), builtin_context));
 
-  ast_context->InitBuiltinTypes(m_compiler->getTarget());
+  m_compiler->createASTContext();
+  clang::ASTContext& ast_context = m_compiler->getASTContext();
 
   ClangExpressionHelper *type_system_helper =
       dyn_cast<ClangExpressionHelper>(m_expr.GetTypeSystemHelper());
   ClangExpressionDeclMap *decl_map = type_system_helper->DeclMap();
 
   if (decl_map) {
     llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> ast_source(
         decl_map->CreateProxy());
-    decl_map->InstallASTContext(*ast_context, m_compiler->getFileManager());
-    ast_context->setExternalSource(ast_source);
+    decl_map->InstallASTContext(ast_context, m_compiler->getFileManager());
+    ast_context.setExternalSource(ast_source);
   }
 
   m_ast_context.reset(
       new ClangASTContext(m_compiler->getTargetOpts().Triple.c_str()));
-  m_ast_context->setASTContext(ast_context.get());
-  m_compiler->setASTContext(ast_context.release());
+  m_ast_context->setASTContext(&ast_context);
 
   std::string module_name("$__lldb_module");
 


Index: source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
===================================================================
--- source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -517,28 +517,24 @@
   builtin_context.initializeBuiltins(PP.getIdentifierTable(),
                                      m_compiler->getLangOpts());
 
-  std::unique_ptr<clang::ASTContext> ast_context(
-      new ASTContext(m_compiler->getLangOpts(), m_compiler->getSourceManager(),
-                     m_compiler->getPreprocessor().getIdentifierTable(),
-                     PP.getSelectorTable(), builtin_context));
 
-  ast_context->InitBuiltinTypes(m_compiler->getTarget());
+  m_compiler->createASTContext();
+  clang::ASTContext& ast_context = m_compiler->getASTContext();
 
   ClangExpressionHelper *type_system_helper =
       dyn_cast<ClangExpressionHelper>(m_expr.GetTypeSystemHelper());
   ClangExpressionDeclMap *decl_map = type_system_helper->DeclMap();
 
   if (decl_map) {
     llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> ast_source(
         decl_map->CreateProxy());
-    decl_map->InstallASTContext(*ast_context, m_compiler->getFileManager());
-    ast_context->setExternalSource(ast_source);
+    decl_map->InstallASTContext(ast_context, m_compiler->getFileManager());
+    ast_context.setExternalSource(ast_source);
   }
 
   m_ast_context.reset(
       new ClangASTContext(m_compiler->getTargetOpts().Triple.c_str()));
-  m_ast_context->setASTContext(ast_context.get());
-  m_compiler->setASTContext(ast_context.release());
+  m_ast_context->setASTContext(&ast_context);
 
   std::string module_name("$__lldb_module");
 
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to