This revision was automatically updated to reflect the committed changes. Closed by commit rGffcc076a2b23: [[Clang CallGraph]] CallGraph should still record calls to decls. (authored by erichkeane). Herald added a project: clang. Herald added a subscriber: cfe-commits.
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D76435/new/ https://reviews.llvm.org/D76435 Files: clang/include/clang/Analysis/CallGraph.h clang/lib/Analysis/CallGraph.cpp clang/test/Analysis/debug-CallGraph.cpp Index: clang/test/Analysis/debug-CallGraph.cpp =================================================================== --- clang/test/Analysis/debug-CallGraph.cpp +++ clang/test/Analysis/debug-CallGraph.cpp @@ -97,9 +97,10 @@ } // CHECK:--- Call graph Dump --- -// CHECK-NEXT: {{Function: < root > calls: get5 add test_add mmm foo aaa < > bbb ddd ccc eee fff do_nothing test_single_call SomeNS::templ SomeNS::templ SomeNS::templUser Lambdas::Callee Lambdas::f1 Lambdas::f1\(\)::\(anonymous class\)::operator\(\) Lambdas::f1\(\)::\(anonymous class\)::operator\(\) CallDecl::SomeDef CallDecl::Caller CallDecl::SomeOtherDecl $}} -// CHECK-NEXT: {{Function: CallDecl::Caller calls: CallDecl::SomeOtherDecl $}} +// CHECK-NEXT: {{Function: < root > calls: get5 add test_add mmm foo aaa < > bbb ddd ccc eee fff do_nothing test_single_call SomeNS::templ SomeNS::templ SomeNS::templUser Lambdas::Callee Lambdas::f1 Lambdas::f1\(\)::\(anonymous class\)::operator\(\) Lambdas::f1\(\)::\(anonymous class\)::operator\(\) CallDecl::SomeDef CallDecl::Caller CallDecl::SomeDecl CallDecl::SomeOtherDecl $}} +// CHECK-NEXT: {{Function: CallDecl::Caller calls: CallDecl::SomeDecl CallDecl::SomeOtherDecl $}} // CHECK-NEXT: {{Function: CallDecl::SomeOtherDecl calls: CallDecl::SomeDef $}} +// CHECK-NEXT: {{Function: CallDecl::SomeDecl calls: $}} // CHECK-NEXT: {{Function: CallDecl::SomeDef calls: $}} // CHECK-NEXT: {{Function: Lambdas::f1 calls: Lambdas::f1\(\)::\(anonymous class\)::operator\(\) Lambdas::f1\(\)::\(anonymous class\)::operator\(\) $}} // CHECK-NEXT: {{Function: Lambdas::f1\(\)::\(anonymous class\)::operator\(\) calls: Lambdas::Callee $}} Index: clang/lib/Analysis/CallGraph.cpp =================================================================== --- clang/lib/Analysis/CallGraph.cpp +++ clang/lib/Analysis/CallGraph.cpp @@ -67,7 +67,7 @@ } void addCalledDecl(Decl *D, Expr *CallExpr) { - if (G->includeInGraph(D)) { + if (G->includeCalleeInGraph(D)) { CallGraphNode *CalleeNode = G->getOrInsertNode(D); CallerNode->addCallee({CalleeNode, CallExpr}); } @@ -157,6 +157,10 @@ if (!D->hasBody()) return false; + return includeCalleeInGraph(D); +} + +bool CallGraph::includeCalleeInGraph(const Decl *D) { if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { // We skip function template definitions, as their semantics is // only determined when they are instantiated. Index: clang/include/clang/Analysis/CallGraph.h =================================================================== --- clang/include/clang/Analysis/CallGraph.h +++ clang/include/clang/Analysis/CallGraph.h @@ -66,6 +66,11 @@ /// Determine if a declaration should be included in the graph. static bool includeInGraph(const Decl *D); + /// Determine if a declaration should be included in the graph for the + /// purposes of being a callee. This is similar to includeInGraph except + /// it permits declarations, not just definitions. + static bool includeCalleeInGraph(const Decl *D); + /// Lookup the node for the given declaration. CallGraphNode *getNode(const Decl *) const;
Index: clang/test/Analysis/debug-CallGraph.cpp =================================================================== --- clang/test/Analysis/debug-CallGraph.cpp +++ clang/test/Analysis/debug-CallGraph.cpp @@ -97,9 +97,10 @@ } // CHECK:--- Call graph Dump --- -// CHECK-NEXT: {{Function: < root > calls: get5 add test_add mmm foo aaa < > bbb ddd ccc eee fff do_nothing test_single_call SomeNS::templ SomeNS::templ SomeNS::templUser Lambdas::Callee Lambdas::f1 Lambdas::f1\(\)::\(anonymous class\)::operator\(\) Lambdas::f1\(\)::\(anonymous class\)::operator\(\) CallDecl::SomeDef CallDecl::Caller CallDecl::SomeOtherDecl $}} -// CHECK-NEXT: {{Function: CallDecl::Caller calls: CallDecl::SomeOtherDecl $}} +// CHECK-NEXT: {{Function: < root > calls: get5 add test_add mmm foo aaa < > bbb ddd ccc eee fff do_nothing test_single_call SomeNS::templ SomeNS::templ SomeNS::templUser Lambdas::Callee Lambdas::f1 Lambdas::f1\(\)::\(anonymous class\)::operator\(\) Lambdas::f1\(\)::\(anonymous class\)::operator\(\) CallDecl::SomeDef CallDecl::Caller CallDecl::SomeDecl CallDecl::SomeOtherDecl $}} +// CHECK-NEXT: {{Function: CallDecl::Caller calls: CallDecl::SomeDecl CallDecl::SomeOtherDecl $}} // CHECK-NEXT: {{Function: CallDecl::SomeOtherDecl calls: CallDecl::SomeDef $}} +// CHECK-NEXT: {{Function: CallDecl::SomeDecl calls: $}} // CHECK-NEXT: {{Function: CallDecl::SomeDef calls: $}} // CHECK-NEXT: {{Function: Lambdas::f1 calls: Lambdas::f1\(\)::\(anonymous class\)::operator\(\) Lambdas::f1\(\)::\(anonymous class\)::operator\(\) $}} // CHECK-NEXT: {{Function: Lambdas::f1\(\)::\(anonymous class\)::operator\(\) calls: Lambdas::Callee $}} Index: clang/lib/Analysis/CallGraph.cpp =================================================================== --- clang/lib/Analysis/CallGraph.cpp +++ clang/lib/Analysis/CallGraph.cpp @@ -67,7 +67,7 @@ } void addCalledDecl(Decl *D, Expr *CallExpr) { - if (G->includeInGraph(D)) { + if (G->includeCalleeInGraph(D)) { CallGraphNode *CalleeNode = G->getOrInsertNode(D); CallerNode->addCallee({CalleeNode, CallExpr}); } @@ -157,6 +157,10 @@ if (!D->hasBody()) return false; + return includeCalleeInGraph(D); +} + +bool CallGraph::includeCalleeInGraph(const Decl *D) { if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { // We skip function template definitions, as their semantics is // only determined when they are instantiated. Index: clang/include/clang/Analysis/CallGraph.h =================================================================== --- clang/include/clang/Analysis/CallGraph.h +++ clang/include/clang/Analysis/CallGraph.h @@ -66,6 +66,11 @@ /// Determine if a declaration should be included in the graph. static bool includeInGraph(const Decl *D); + /// Determine if a declaration should be included in the graph for the + /// purposes of being a callee. This is similar to includeInGraph except + /// it permits declarations, not just definitions. + static bool includeCalleeInGraph(const Decl *D); + /// Lookup the node for the given declaration. CallGraphNode *getNode(const Decl *) const;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits