@@ -48,13 +48,12 @@ SlabTuple indexSymbols(ASTContext &AST, Preprocessor &PP,
4848 const MainFileMacros *MacroRefsToIndex,
4949 const include_cleaner::PragmaIncludes &PI,
5050 bool IsIndexMainAST, llvm::StringRef Version,
51- bool CollectMainFileRefs) {
51+ bool CollectMainFileRefs, SymbolOrigin Origin ) {
5252 SymbolCollector::Options CollectorOpts;
5353 CollectorOpts.CollectIncludePath = true ;
5454 CollectorOpts.PragmaIncludes = Π
5555 CollectorOpts.CountReferences = false ;
56- CollectorOpts.Origin =
57- IsIndexMainAST ? SymbolOrigin::Open : SymbolOrigin::Preamble;
56+ CollectorOpts.Origin = Origin;
5857 CollectorOpts.CollectMainFileRefs = CollectMainFileRefs;
5958 // We want stdlib implementation details in the index only if we've opened the
6059 // file in question. This does means xrefs won't work, though.
@@ -221,22 +220,24 @@ FileShardedIndex::getShard(llvm::StringRef Uri) const {
221220}
222221
223222SlabTuple 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);
228228}
229229
230230SlabTuple indexHeaderSymbols (llvm::StringRef Version, ASTContext &AST,
231231 Preprocessor &PP,
232- const include_cleaner::PragmaIncludes &PI) {
232+ const include_cleaner::PragmaIncludes &PI,
233+ SymbolOrigin Origin) {
233234 std::vector<Decl *> DeclsToIndex (
234235 AST.getTranslationUnitDecl ()->decls ().begin (),
235236 AST.getTranslationUnitDecl ()->decls ().end ());
236237 return indexSymbols (AST, PP, DeclsToIndex,
237238 /* MainFileMacros=*/ nullptr , PI,
238239 /* IsIndexMainAST=*/ false , Version,
239- /* CollectMainFileRefs=*/ false );
240+ /* CollectMainFileRefs=*/ false , Origin );
240241}
241242
242243FileSymbols::FileSymbols (IndexContents IdxContents, bool SupportContainedRefs)
@@ -462,7 +463,7 @@ void FileIndex::updatePreamble(PathRef Path, llvm::StringRef Version,
462463 const include_cleaner::PragmaIncludes &PI) {
463464 IndexFileIn IF;
464465 std::tie (IF.Symbols , std::ignore, IF.Relations ) =
465- indexHeaderSymbols (Version, AST, PP, PI);
466+ indexHeaderSymbols (Version, AST, PP, PI, SymbolOrigin::Preamble );
466467 updatePreamble (std::move (IF));
467468}
468469
0 commit comments