Skip to content

Commit

Permalink
fix(cxx_indexer): function definitions should influence declarations (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
zrlk committed Feb 2, 2021
1 parent ce3200a commit c741a38
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
18 changes: 11 additions & 7 deletions kythe/cxx/indexer/cxx/IndexerASTHooks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3289,13 +3289,17 @@ bool IndexerASTVisitor::VisitFunctionDecl(clang::FunctionDecl* Decl) {
: GraphObserver::Specificity::Completes,
OuterNode);

if (Decl->param_size() == NextDecl->param_size()) {
for (size_t param = 0; param < Decl->param_size(); ++param) {
auto lhs = NextDecl->getParamDecl(param);
auto rhs = Decl->getParamDecl(param);
if (DataflowEdges && lhs != nullptr && rhs != nullptr) {
Observer.recordInfluences(BuildNodeIdForDecl(lhs),
BuildNodeIdForDecl(rhs));
if (DataflowEdges) {
Observer.recordInfluences(OuterNode, TargetDecl);

if (Decl->param_size() == NextDecl->param_size()) {
for (size_t param = 0; param < Decl->param_size(); ++param) {
auto lhs = NextDecl->getParamDecl(param);
auto rhs = Decl->getParamDecl(param);
if (lhs != nullptr && rhs != nullptr) {
Observer.recordInfluences(BuildNodeIdForDecl(lhs),
BuildNodeIdForDecl(rhs));
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions kythe/cxx/indexer/cxx/testdata/df/df_fncall_influence.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ int f(int a, int b);
//- @f completes/uniquely FDecl
//- VarA influences VarC
//- VarB influences VarD
//- FDefn influences FDecl
int f(int c, int d) {
//- VarC influences FDefn
//- VarD influences FDefn
Expand Down
2 changes: 1 addition & 1 deletion kythe/docs/schema/influences-relation.txt
Original file line number Diff line number Diff line change
Expand Up @@ -155,5 +155,5 @@ int f(int x, int y) {

//- FwdParamX influences DefnParamX
//- FwdParamY influences DefnParamY
//- // DefnFnF influences FwdFnF TODO(#4812)
//- DefnFnF influences FwdFnF
--------------------------------------------------------------------------------

0 comments on commit c741a38

Please sign in to comment.