[PATCH] D61565: Ignore generated @import statements in the expression evaluator
Raphael Isemann via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 23 23:57:57 PDT 2019
This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL372690: Ignore generated @import statements in the expression evaluator (authored by teemperor, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Changed prior to commit:
https://reviews.llvm.org/D61565?vs=220987&id=221475#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D61565/new/
https://reviews.llvm.org/D61565
Files:
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp
lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.h
Index: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp
===================================================================
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp
@@ -29,9 +29,12 @@
using namespace lldb_private;
+#define PREFIX_NAME "<lldb wrapper prefix>"
+
+const llvm::StringRef ClangExpressionSourceCode::g_prefix_file_name = PREFIX_NAME;
+
const char *ClangExpressionSourceCode::g_expression_prefix =
- R"(
-#line 1 "<lldb wrapper prefix>"
+"#line 1 \"" PREFIX_NAME R"("
#ifndef offsetof
#define offsetof(t, d) __builtin_offsetof(t, d)
#endif
Index: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.h
===================================================================
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.h
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.h
@@ -23,6 +23,9 @@
class ClangExpressionSourceCode : public ExpressionSourceCode {
public:
+ /// The file name we use for the wrapper code that we inject before
+ /// the user expression.
+ static const llvm::StringRef g_prefix_file_name;
static const char *g_expression_prefix;
static ClangExpressionSourceCode *CreateWrapped(llvm::StringRef filename,
Index: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
===================================================================
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -105,16 +105,26 @@
class ClangExpressionParser::LLDBPreprocessorCallbacks : public PPCallbacks {
ClangModulesDeclVendor &m_decl_vendor;
ClangPersistentVariables &m_persistent_vars;
+ clang::SourceManager &m_source_mgr;
StreamString m_error_stream;
bool m_has_errors = false;
public:
LLDBPreprocessorCallbacks(ClangModulesDeclVendor &decl_vendor,
- ClangPersistentVariables &persistent_vars)
- : m_decl_vendor(decl_vendor), m_persistent_vars(persistent_vars) {}
+ ClangPersistentVariables &persistent_vars,
+ clang::SourceManager &source_mgr)
+ : m_decl_vendor(decl_vendor), m_persistent_vars(persistent_vars),
+ m_source_mgr(source_mgr) {}
void moduleImport(SourceLocation import_location, clang::ModuleIdPath path,
const clang::Module * /*null*/) override {
+ // Ignore modules that are imported in the wrapper code as these are not
+ // loaded by the user.
+ llvm::StringRef filename =
+ m_source_mgr.getPresumedLoc(import_location).getFilename();
+ if (filename == ClangExpressionSourceCode::g_prefix_file_name)
+ return;
+
SourceModule module;
for (const std::pair<IdentifierInfo *, SourceLocation> &component : path)
@@ -572,8 +582,8 @@
llvm::cast<ClangPersistentVariables>(
target_sp->GetPersistentExpressionStateForLanguage(
lldb::eLanguageTypeC));
- std::unique_ptr<PPCallbacks> pp_callbacks(
- new LLDBPreprocessorCallbacks(*decl_vendor, *clang_persistent_vars));
+ std::unique_ptr<PPCallbacks> pp_callbacks(new LLDBPreprocessorCallbacks(
+ *decl_vendor, *clang_persistent_vars, m_compiler->getSourceManager()));
m_pp_callbacks =
static_cast<LLDBPreprocessorCallbacks *>(pp_callbacks.get());
m_compiler->getPreprocessor().addPPCallbacks(std::move(pp_callbacks));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61565.221475.patch
Type: text/x-patch
Size: 3639 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190924/fc36a613/attachment.bin>
More information about the llvm-commits
mailing list