indexer: index TemplateTypeParmDecl and ParmVarDecl in declarations for clang >= 9

This commit is contained in:
Fangrui Song 2019-02-22 10:59:05 +08:00
parent 7f82dcf3d1
commit a3f6885c5e

View File

@ -820,8 +820,12 @@ public:
do_def_decl(type); do_def_decl(type);
if (Spell != Loc) if (Spell != Loc)
AddMacroUse(db, SM, usr, Kind::Type, Spell); AddMacroUse(db, SM, usr, Kind::Type, Spell);
if (type->def.detailed_name[0] == '\0' && info->short_name.size()) if (type->def.detailed_name[0] == '\0' && info->short_name.size()) {
SetName(D, info->short_name, info->qualified, type->def); if (D->getKind() == Decl::TemplateTypeParm)
type->def.detailed_name = Intern(info->short_name);
else
SetName(D, info->short_name, info->qualified, type->def);
}
if (is_def || is_decl) { if (is_def || is_decl) {
const Decl *DC = cast<Decl>(SemDC); const Decl *DC = cast<Decl>(SemDC);
if (GetKind(DC, ls_kind) == Kind::Type) if (GetKind(DC, ls_kind) == Kind::Type)
@ -853,6 +857,7 @@ public:
if (!isa<EnumConstantDecl>(D)) if (!isa<EnumConstantDecl>(D))
db->ToType(usr1).instances.push_back(usr); db->ToType(usr1).instances.push_back(usr);
} else if (const Decl *D1 = GetAdjustedDecl(GetTypeDecl(T))) { } else if (const Decl *D1 = GetAdjustedDecl(GetTypeDecl(T))) {
#if LLVM_VERSION_MAJOR < 9
if (isa<TemplateTypeParmDecl>(D1)) { if (isa<TemplateTypeParmDecl>(D1)) {
// e.g. TemplateTypeParmDecl is not handled by // e.g. TemplateTypeParmDecl is not handled by
// handleDeclOccurence. // handleDeclOccurence.
@ -875,6 +880,7 @@ public:
break; break;
} }
} }
#endif
IndexParam::DeclInfo *info1; IndexParam::DeclInfo *info1;
Usr usr1 = GetUsr(D1, &info1); Usr usr1 = GetUsr(D1, &info1);
@ -1250,6 +1256,10 @@ Index(SemaManager *manager, WorkingFiles *wfiles, VFS *vfs,
index::IndexingOptions::SystemSymbolFilterKind::All; index::IndexingOptions::SystemSymbolFilterKind::All;
IndexOpts.IndexFunctionLocals = true; IndexOpts.IndexFunctionLocals = true;
IndexOpts.IndexImplicitInstantiation = true; IndexOpts.IndexImplicitInstantiation = true;
#if LLVM_VERSION_MAJOR >= 9
IndexOpts.IndexParametersInDeclarations = true;
IndexOpts.IndexTemplateParameters = true;
#endif
std::unique_ptr<FrontendAction> Action = createIndexingAction( std::unique_ptr<FrontendAction> Action = createIndexingAction(
DataConsumer, IndexOpts, std::make_unique<IndexFrontendAction>(param)); DataConsumer, IndexOpts, std::make_unique<IndexFrontendAction>(param));