@@ -105,16 +105,26 @@ using namespace lldb_private;
105
105
class ClangExpressionParser ::LLDBPreprocessorCallbacks : public PPCallbacks {
106
106
ClangModulesDeclVendor &m_decl_vendor;
107
107
ClangPersistentVariables &m_persistent_vars;
108
+ clang::SourceManager &m_source_mgr;
108
109
StreamString m_error_stream;
109
110
bool m_has_errors = false ;
110
111
111
112
public:
112
113
LLDBPreprocessorCallbacks (ClangModulesDeclVendor &decl_vendor,
113
- ClangPersistentVariables &persistent_vars)
114
- : m_decl_vendor(decl_vendor), m_persistent_vars(persistent_vars) {}
114
+ ClangPersistentVariables &persistent_vars,
115
+ clang::SourceManager &source_mgr)
116
+ : m_decl_vendor(decl_vendor), m_persistent_vars(persistent_vars),
117
+ m_source_mgr (source_mgr) {}
115
118
116
119
void moduleImport (SourceLocation import_location, clang::ModuleIdPath path,
117
120
const clang::Module * /* null*/ ) override {
121
+ // Ignore modules that are imported in the wrapper code as these are not
122
+ // loaded by the user.
123
+ llvm::StringRef filename =
124
+ m_source_mgr.getPresumedLoc (import_location).getFilename ();
125
+ if (filename == ClangExpressionSourceCode::g_prefix_file_name)
126
+ return ;
127
+
118
128
SourceModule module;
119
129
120
130
for (const std::pair<IdentifierInfo *, SourceLocation> &component : path)
@@ -557,8 +567,8 @@ ClangExpressionParser::ClangExpressionParser(
557
567
llvm::cast<ClangPersistentVariables>(
558
568
target_sp->GetPersistentExpressionStateForLanguage (
559
569
lldb::eLanguageTypeC));
560
- std::unique_ptr<PPCallbacks> pp_callbacks (
561
- new LLDBPreprocessorCallbacks ( *decl_vendor, *clang_persistent_vars));
570
+ std::unique_ptr<PPCallbacks> pp_callbacks (new LLDBPreprocessorCallbacks (
571
+ *decl_vendor, *clang_persistent_vars, m_compiler-> getSourceManager () ));
562
572
m_pp_callbacks =
563
573
static_cast <LLDBPreprocessorCallbacks *>(pp_callbacks.get ());
564
574
m_compiler->getPreprocessor ().addPPCallbacks (std::move (pp_callbacks));
0 commit comments