@@ -48,13 +48,12 @@ SlabTuple indexSymbols(ASTContext &AST, Preprocessor &PP,
48
48
const MainFileMacros *MacroRefsToIndex,
49
49
const include_cleaner::PragmaIncludes &PI,
50
50
bool IsIndexMainAST, llvm::StringRef Version,
51
- bool CollectMainFileRefs) {
51
+ bool CollectMainFileRefs, SymbolOrigin Origin ) {
52
52
SymbolCollector::Options CollectorOpts;
53
53
CollectorOpts.CollectIncludePath = true ;
54
54
CollectorOpts.PragmaIncludes = Π
55
55
CollectorOpts.CountReferences = false ;
56
- CollectorOpts.Origin =
57
- IsIndexMainAST ? SymbolOrigin::Open : SymbolOrigin::Preamble;
56
+ CollectorOpts.Origin = Origin;
58
57
CollectorOpts.CollectMainFileRefs = CollectMainFileRefs;
59
58
// We want stdlib implementation details in the index only if we've opened the
60
59
// file in question. This does means xrefs won't work, though.
@@ -221,22 +220,24 @@ FileShardedIndex::getShard(llvm::StringRef Uri) const {
221
220
}
222
221
223
222
SlabTuple indexMainDecls (ParsedAST &AST) {
224
- return indexSymbols (
225
- AST.getASTContext (), AST.getPreprocessor (), AST.getLocalTopLevelDecls (),
226
- &AST.getMacros (), AST.getPragmaIncludes (),
227
- /* IsIndexMainAST=*/ true , AST.version (), /* CollectMainFileRefs=*/ true );
223
+ return indexSymbols (AST.getASTContext (), AST.getPreprocessor (),
224
+ AST.getLocalTopLevelDecls (), &AST.getMacros (),
225
+ AST.getPragmaIncludes (),
226
+ /* IsIndexMainAST=*/ true , AST.version (),
227
+ /* CollectMainFileRefs=*/ true , SymbolOrigin::Open);
228
228
}
229
229
230
230
SlabTuple indexHeaderSymbols (llvm::StringRef Version, ASTContext &AST,
231
231
Preprocessor &PP,
232
- const include_cleaner::PragmaIncludes &PI) {
232
+ const include_cleaner::PragmaIncludes &PI,
233
+ SymbolOrigin Origin) {
233
234
std::vector<Decl *> DeclsToIndex (
234
235
AST.getTranslationUnitDecl ()->decls ().begin (),
235
236
AST.getTranslationUnitDecl ()->decls ().end ());
236
237
return indexSymbols (AST, PP, DeclsToIndex,
237
238
/* MainFileMacros=*/ nullptr , PI,
238
239
/* IsIndexMainAST=*/ false , Version,
239
- /* CollectMainFileRefs=*/ false );
240
+ /* CollectMainFileRefs=*/ false , Origin );
240
241
}
241
242
242
243
FileSymbols::FileSymbols (IndexContents IdxContents, bool SupportContainedRefs)
@@ -462,7 +463,7 @@ void FileIndex::updatePreamble(PathRef Path, llvm::StringRef Version,
462
463
const include_cleaner::PragmaIncludes &PI) {
463
464
IndexFileIn IF;
464
465
std::tie (IF.Symbols , std::ignore, IF.Relations ) =
465
- indexHeaderSymbols (Version, AST, PP, PI);
466
+ indexHeaderSymbols (Version, AST, PP, PI, SymbolOrigin::Preamble );
466
467
updatePreamble (std::move (IF));
467
468
}
468
469
0 commit comments