2121#include " clang/Basic/SourceManager.h"
2222#include " clang/Lex/HeaderSearch.h"
2323#include " clang/Lex/Lexer.h"
24+ #include " clang/Lex/Preprocessor.h"
2425#include " clang/Tooling/Inclusions/StandardLibrary.h"
2526#include " llvm/Support/ScopedPrinter.h"
2627#include " llvm/Support/raw_ostream.h"
@@ -135,7 +136,7 @@ class Reporter {
135136 llvm::raw_ostream &OS;
136137 const ASTContext &Ctx;
137138 const SourceManager &SM;
138- const HeaderSearch &HS ;
139+ const Preprocessor &PP ;
139140 const include_cleaner::Includes &Includes;
140141 const PragmaIncludes *PI;
141142 FileID MainFile;
@@ -170,9 +171,9 @@ class Reporter {
170171
171172 void fillTarget (Ref &R) {
172173 // Duplicates logic from walkUsed(), which doesn't expose SymbolLocations.
173- for (auto &Loc : locateSymbol (R.Sym ))
174+ for (auto &Loc : locateSymbol (R.Sym , Ctx. getLangOpts () ))
174175 R.Locations .push_back (Loc);
175- R.Headers = headersForSymbol (R.Sym , SM , PI);
176+ R.Headers = headersForSymbol (R.Sym , PP , PI);
176177
177178 for (const auto &H : R.Headers ) {
178179 R.Includes .append (Includes.match (H));
@@ -189,14 +190,15 @@ class Reporter {
189190 R.Includes .end ());
190191
191192 if (!R.Headers .empty ())
192- R.Insert = spellHeader ({R.Headers .front (), HS, MainFE});
193+ R.Insert =
194+ spellHeader ({R.Headers .front (), PP.getHeaderSearchInfo (), MainFE});
193195 }
194196
195197public:
196- Reporter (llvm::raw_ostream &OS, ASTContext &Ctx, const HeaderSearch &HS ,
198+ Reporter (llvm::raw_ostream &OS, ASTContext &Ctx, const Preprocessor &PP ,
197199 const include_cleaner::Includes &Includes, const PragmaIncludes *PI,
198200 FileID MainFile)
199- : OS(OS), Ctx(Ctx), SM(Ctx.getSourceManager()), HS(HS ),
201+ : OS(OS), Ctx(Ctx), SM(Ctx.getSourceManager()), PP(PP ),
200202 Includes (Includes), PI(PI), MainFile(MainFile),
201203 MainFE(SM.getFileEntryForID(MainFile)) {}
202204
@@ -498,9 +500,9 @@ class Reporter {
498500void writeHTMLReport (FileID File, const include_cleaner::Includes &Includes,
499501 llvm::ArrayRef<Decl *> Roots,
500502 llvm::ArrayRef<SymbolReference> MacroRefs, ASTContext &Ctx,
501- const HeaderSearch &HS , PragmaIncludes *PI,
503+ const Preprocessor &PP , PragmaIncludes *PI,
502504 llvm::raw_ostream &OS) {
503- Reporter R (OS, Ctx, HS , Includes, PI, File);
505+ Reporter R (OS, Ctx, PP , Includes, PI, File);
504506 const auto & SM = Ctx.getSourceManager ();
505507 for (Decl *Root : Roots)
506508 walkAST (*Root, [&](SourceLocation Loc, const NamedDecl &D, RefType T) {
0 commit comments