diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2020-07-26 19:36:28 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2020-07-26 19:36:28 +0000 |
commit | cfca06d7963fa0909f90483b42a6d7d194d01e08 (patch) | |
tree | 209fb2a2d68f8f277793fc8df46c753d31bc853b /clang/lib/Index/IndexDecl.cpp | |
parent | 706b4fc47bbc608932d3b491ae19a3b9cde9497b (diff) |
Notes
Diffstat (limited to 'clang/lib/Index/IndexDecl.cpp')
-rw-r--r-- | clang/lib/Index/IndexDecl.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/clang/lib/Index/IndexDecl.cpp b/clang/lib/Index/IndexDecl.cpp index c59b1372e399a..2ba323e635753 100644 --- a/clang/lib/Index/IndexDecl.cpp +++ b/clang/lib/Index/IndexDecl.cpp @@ -80,7 +80,7 @@ public: !MD->isSynthesizedAccessorStub(); } - + void handleDeclarator(const DeclaratorDecl *D, const NamedDecl *Parent = nullptr, bool isIBType = false) { @@ -90,6 +90,12 @@ public: Parent->getLexicalDeclContext(), /*isBase=*/false, isIBType); IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent); + auto IndexDefaultParmeterArgument = [&](const ParmVarDecl *Parm, + const NamedDecl *Parent) { + if (Parm->hasDefaultArg() && !Parm->hasUninstantiatedDefaultArg() && + !Parm->hasUnparsedDefaultArg()) + IndexCtx.indexBody(Parm->getDefaultArg(), Parent); + }; if (IndexCtx.shouldIndexFunctionLocalSymbols()) { if (const ParmVarDecl *Parm = dyn_cast<ParmVarDecl>(D)) { auto *DC = Parm->getDeclContext(); @@ -106,7 +112,8 @@ public: } else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { if (IndexCtx.shouldIndexParametersInDeclarations() || FD->isThisDeclarationADefinition()) { - for (auto PI : FD->parameters()) { + for (const auto *PI : FD->parameters()) { + IndexDefaultParmeterArgument(PI, D); IndexCtx.handleDecl(PI); } } @@ -116,9 +123,7 @@ public: if (const auto *FD = dyn_cast<FunctionDecl>(D)) { if (FD->isThisDeclarationADefinition()) { for (const auto *PV : FD->parameters()) { - if (PV->hasDefaultArg() && !PV->hasUninstantiatedDefaultArg() && - !PV->hasUnparsedDefaultArg()) - IndexCtx.indexBody(PV->getDefaultArg(), D); + IndexDefaultParmeterArgument(PV, D); } } } @@ -760,6 +765,9 @@ bool IndexingContext::indexTopLevelDecl(const Decl *D) { if (isa<ObjCMethodDecl>(D)) return true; // Wait for the objc container. + if (IndexOpts.ShouldTraverseDecl && !IndexOpts.ShouldTraverseDecl(D)) + return true; // skip + return indexDecl(D); } |