[Lldb-commits] [PATCH] D64989: [lldb] Fix crash when looking up type coming from the ClangModuleDeclVendor

Raphael Isemann via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Sun Jul 21 03:33:19 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL366653: [lldb] Fix crash when looking up type coming from the ClangModuleDeclVendor (authored by teemperor, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64989?vs=210817&id=210986#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64989/new/

https://reviews.llvm.org/D64989

Files:
  lldb/trunk/packages/Python/lldbsuite/test/lang/objc/modules/TestObjCModules.py
  lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp


Index: lldb/trunk/packages/Python/lldbsuite/test/lang/objc/modules/TestObjCModules.py
===================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lang/objc/modules/TestObjCModules.py
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/objc/modules/TestObjCModules.py
@@ -60,6 +60,10 @@
                 "int",
                 "4"])
 
+        # Type lookup should still work and print something reasonable
+        # for types from the module.
+        self.expect("type lookup NSObject", substrs=["instanceMethod"])
+
         self.expect("expr string.length", VARIABLES_DISPLAYED_CORRECTLY,
                     substrs=["NSUInteger", "5"])
 
Index: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
===================================================================
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
@@ -27,6 +27,7 @@
 #include "lldb/Core/ModuleList.h"
 #include "lldb/Host/Host.h"
 #include "lldb/Host/HostInfo.h"
+#include "lldb/Symbol/ClangASTContext.h"
 #include "lldb/Symbol/CompileUnit.h"
 #include "lldb/Symbol/SourceModule.h"
 #include "lldb/Target/Target.h"
@@ -110,6 +111,9 @@
   ImportedModuleMap m_imported_modules;
   ImportedModuleSet m_user_imported_modules;
   const clang::ExternalASTMerger::OriginMap m_origin_map;
+  // We assume that every ASTContext has an ClangASTContext, so we also store
+  // a custom ClangASTContext for our internal ASTContext.
+  std::unique_ptr<ClangASTContext> m_ast_context;
 };
 } // anonymous namespace
 
@@ -155,7 +159,13 @@
     : m_diagnostics_engine(std::move(diagnostics_engine)),
       m_compiler_invocation(std::move(compiler_invocation)),
       m_compiler_instance(std::move(compiler_instance)),
-      m_parser(std::move(parser)), m_origin_map() {}
+      m_parser(std::move(parser)), m_origin_map() {
+
+  // Initialize our ClangASTContext.
+  auto target_opts = m_compiler_invocation->getTargetOpts();
+  m_ast_context.reset(new ClangASTContext(target_opts.Triple.c_str()));
+  m_ast_context->setASTContext(&m_compiler_instance->getASTContext());
+}
 
 void ClangModulesDeclVendorImpl::ReportModuleExportsHelper(
     std::set<ClangModulesDeclVendor::ModuleID> &exports,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64989.210986.patch
Type: text/x-patch
Size: 2344 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190721/6f56bb5d/attachment.bin>


More information about the lldb-commits mailing list