|
15 | 15 | #include "Compiler.h"
|
16 | 16 | #include "Config.h"
|
17 | 17 | #include "SymbolCollector.h"
|
| 18 | +#include "clang-include-cleaner/Record.h" |
| 19 | +#include "index/FileIndex.h" |
18 | 20 | #include "index/IndexAction.h"
|
19 | 21 | #include "support/Logger.h"
|
20 | 22 | #include "support/ThreadsafeFS.h"
|
21 | 23 | #include "support/Trace.h"
|
22 | 24 | #include "clang/Basic/LangOptions.h"
|
23 | 25 | #include "clang/Frontend/CompilerInvocation.h"
|
| 26 | +#include "clang/Frontend/FrontendActions.h" |
24 | 27 | #include "clang/Lex/PreprocessorOptions.h"
|
25 | 28 | #include "clang/Tooling/Inclusions/StandardLibrary.h"
|
26 | 29 | #include "llvm/ADT/IntrusiveRefCntPtr.h"
|
@@ -234,22 +237,26 @@ SymbolSlab indexStandardLibrary(llvm::StringRef HeaderSources,
|
234 | 237 | // We end up "blessing" such headers, and can only do that by indexing
|
235 | 238 | // everything first.
|
236 | 239 |
|
237 |
| - // Refs, relations, include graph in the stdlib mostly aren't useful. |
238 |
| - auto Action = createStaticIndexingAction( |
239 |
| - IndexOpts, [&](SymbolSlab S) { Symbols = std::move(S); }, nullptr, |
240 |
| - nullptr, nullptr); |
| 240 | + SyntaxOnlyAction Action; |
241 | 241 |
|
242 |
| - if (!Action->BeginSourceFile(*Clang, Input)) { |
| 242 | + if (!Action.BeginSourceFile(*Clang, Input)) { |
243 | 243 | elog("Standard Library Index: BeginSourceFile() failed");
|
244 | 244 | return Symbols;
|
245 | 245 | }
|
246 | 246 |
|
247 |
| - if (llvm::Error Err = Action->Execute()) { |
| 247 | + if (llvm::Error Err = Action.Execute()) { |
248 | 248 | elog("Standard Library Index: Execute failed: {0}", std::move(Err));
|
249 | 249 | return Symbols;
|
250 | 250 | }
|
251 | 251 |
|
252 |
| - Action->EndSourceFile(); |
| 252 | + // We don't care about include graph for stdlib headers, so provide a no-op |
| 253 | + // PI. |
| 254 | + include_cleaner::PragmaIncludes PI; |
| 255 | + auto Slabs = indexHeaderSymbols("", Clang->getASTContext(), |
| 256 | + Clang->getPreprocessor(), PI); |
| 257 | + Symbols = std::move(std::get<0>(Slabs)); |
| 258 | + |
| 259 | + Action.EndSourceFile(); |
253 | 260 |
|
254 | 261 | unsigned SymbolsBeforeFilter = Symbols.size();
|
255 | 262 | Symbols = filter(std::move(Symbols), Loc);
|
|
0 commit comments