summaryrefslogtreecommitdiff
path: root/clang/lib/Analysis/CallGraph.cpp
AgeCommit message (Collapse)Author
2025-07-01[Analysis] Use range-based for loops (NFC) (#146466)Kazu Hirata
2025-05-31[Analysis] Remove unused includes (NFC) (#142255)Kazu Hirata
These are identified by misc-include-cleaner. I've filtered out those that break builds. Also, I'm staying away from llvm-config.h, config.h, and Compiler.h, which likely cause platform- or compiler-specific build failures.
2024-11-15[Clang] [NFC] Refactor AST visitors in Sema and the static analyser to use ↵Sirraide
DynamicRecursiveASTVisitor (#115144) This pr refactors all recursive AST visitors in `Sema`, `Analyze`, and `StaticAnalysis` to inherit from DRAV instead. This is over half of the visitors that inherit from RAV directly. See also #115132, #110040, #93462 LLVM Compile-Time Tracker link for this branch: https://llvm-compile-time-tracker.com/compare.php?from=5adb5c05a2e9f31385fbba8b0436cbc07d91a44d&to=b58e589a86c06ba28d4d90613864d10be29aa5ba&stat=instructions%3Au
2023-12-13[clang] Use StringRef::{starts,ends}_with (NFC) (#75149)Kazu Hirata
This patch replaces uses of StringRef::{starts,ends}with with StringRef::{starts,ends}_with for consistency with std::{string,string_view}::{starts,ends}_with in C++20. I'm planning to deprecate and eventually remove StringRef::{starts,ends}with.
2020-03-20[[Clang CallGraph]] CallGraph should still record calls to decls.Erich Keane
Discovered by a downstream user, we found that the CallGraph ignores callees unless they are defined. This seems foolish, and prevents combining the report with other reports to create unified reports. Additionally, declarations contain information that is likely useful to consumers of the CallGraph. This patch implements this by splitting the includeInGraph function into two versions, the current one plus one that is for callees only. The only difference currently is that includeInGraph checks for a body, then calls includeCalleeInGraph. Differential Revision: https://reviews.llvm.org/D76435
2020-02-13[clang][Analysis] CallGraph: store the actual call `Expr*` in the ↵Roman Lebedev
CallGraphNode::CallRecord Summary: Storing not just the callee, but the actual call may be interesting for some use-cases. In particular, D72362 would like that to better pretty-print the cycles in call graph. Reviewers: NoQ, erichkeane Reviewed By: NoQ Subscribers: martong, Charusso, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D74081
2019-09-30Teach CallGraph to look into Generic Lambdas.Erich Keane
CallGraph visited LambdaExpr by getting the Call Operator from CXXRecordDecl (LambdaExpr::getCallOperator calls CXXRecordDecl::getLambdaCallOperator), which replaced generic lambda call operators with the non-instantiated FunctionDecl. The result was that the CallGraph would only pick up non-dependent calls. This patch does a few things: 1- Extend CXXRecordDecl to have a getDependentLambdaCallOperator, which will get the FunctionTemplateDecl, rather than immediately getting the TemplateDecl. 2- Define getLambdaCallOperator and getDependentLambdaCallOperator in terms of a common function. 3- Extend LambdaExpr with a getDependentCallOperator, which just calls the above function. 4- Changes CallGraph to handle Generic LambdaExprs. llvm-svn: 373247
2019-08-20[CallGraph] Take into accound calls that aren't within any function bodies.Artem Dergachev
This patch improves Clang call graph analysis by adding in expressions that are not found in regular function bodies, such as default arguments or member initializers. Patch by Joshua Cranmer! Differential Revision: https://reviews.llvm.org/D65453 llvm-svn: 369321
2019-08-14[Clang] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere
Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. Differential revision: https://reviews.llvm.org/D66259 llvm-svn: 368942
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
2018-12-12Change CallGraph print to show the fully qualified nameErich Keane
CallGraph previously would just show the normal name of a function, which gets really confusing when using it on large C++ projects. This patch switches the printName call to a printQualifiedName, so that the namespaces are included. Change-Id: Ie086d863f6b2251be92109ea1b0946825b28b49a llvm-svn: 348950
2018-07-30Remove trailing spaceFangrui Song
sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} llvm-svn: 338291
2017-12-07[Analysis] Fix some Clang-tidy modernize and Include What You Use warnings; ↵Eugene Zelenko
other minor fixes (NFC). llvm-svn: 320091
2017-01-27[analyzer] Consider function call arguments while building CallGraph.Artem Dergachev
Function call can appear in the arguments of another function call, eg.: foo(bar()); This patch adds support for such cases. Patch by Ivan Sidorenko! Differential revision: https://reviews.llvm.org/D28905 llvm-svn: 293280
2016-12-12[StaticAnalysis] Remove unnecessary parameter in CallGraphNode::addCallee.Haojian Wu
Summary: Remove the CallGraph in addCallee as it is not used in addCallee. It decouples addCallee from CallGraph, so that we can use CallGraphNode within our customized CallGraph. Reviewers: bkramer Subscribers: cfe-commits, ioeric Differential Revision: https://reviews.llvm.org/D27674 llvm-svn: 289431
2016-10-10[Analysis] Use unique_ptr for CallGraph::FunctionMap.Justin Lebar
Reviewers: timshen Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25427 llvm-svn: 283775
2016-01-29Annotate dump() methods with LLVM_DUMP_METHOD, addressing Richard Smith ↵Yaron Keren
r259192 post commit comment. llvm-svn: 259232
2015-07-02Switch users of the 'for (StmtRange range = stmt->children(); range; ↵Benjamin Kramer
++range)‘ pattern to range for loops. The pattern was born out of the lack of range-based for loops in C++98 and is somewhat obscure. No functionality change intended. llvm-svn: 241300
2015-06-22Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko
llvm-svn: 240353
2015-06-22Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko
The patch is generated using this command: $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ work/llvm/tools/clang To reduce churn, not touching namespaces spanning less than 10 lines. llvm-svn: 240270
2014-12-17[CallGraph] Make sure the edges are not missed due to re-declarationsAnna Zaks
A patch by Daniel DeFreez! We were previously dropping edges on re-declarations. Store the canonical declarations in the graph to ensure that different references to the same function end up reflected with the same call graph node. (Note, this might lead to performance fluctuation because call graph is used to determine the function analysis order.) llvm-svn: 224398
2014-05-20[C++11] Use 'nullptr'. Analysis edition.Craig Topper
llvm-svn: 209191
2014-04-22[Modules] Fix potential ODR violations by sinking the DEBUG_TYPEChandler Carruth
definition below all of the header #include lines, clang edition. If you want more details about this, you can see some of the commits to Debug.h in LLVM recently. This is just the clang section of a cleanup I've done for all uses of DEBUG_TYPE in LLVM. llvm-svn: 206849
2014-03-07[C++11] Replacing DeclBase iterators decls_begin() and decls_end() with ↵Aaron Ballman
iterator_range decls(). The same is true for the noload versions of these APIs. Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203278
2014-02-19Use llvm::DeleteContainerSeconds when possibleReid Kleckner
llvm-svn: 201739
2012-12-21[analyzer] Fix typos.Anna Zaks
llvm-svn: 170907
2012-12-21[analyzer] Re-apply r170826 and make the dumping of the GallGraphAnna Zaks
deterministic. Commit message for r170826: [analyzer] Traverse the Call Graph in topological order. Modify the call graph by removing the parentless nodes. Instead all nodes are children of root to ensure they are all reachable. Remove the tracking of nodes that are "top level" or global. This information is not used and can be obtained from the Decls stored inside CallGraphNodes. Instead of existing ordering hacks, analyze the functions in topological order over the Call Graph. Together with the addition of devirtualizable ObjC message sends and blocks to the call graph, this gives around 6% performance improvement on several large ObjC benchmarks. llvm-svn: 170906
2012-12-21Revert r170826. The output ofRafael Espindola
./bin/clang -cc1 -internal-isystem /home/espindola/llvm/build/lib/clang/3.3/include/ -analyze -analyzer-checker=debug.DumpCallGraph /home/espindola/llvm/clang/test/Analysis/debug-CallGraph.c -fblocks changes in each run. llvm-svn: 170829
2012-12-21[analyzer] Traverse the Call Graph in topological order.Anna Zaks
Modify the call graph by removing the parentless nodes. Instead all nodes are children of root to ensure they are all reachable. Remove the tracking of nodes that are "top level" or global. This information is not used and can be obtained from the Decls stored inside CallGraphNodes. Instead of existing ordering hacks, analyze the functions in topological order over the Call Graph. Together with the addition of devirtualizable ObjC message sends and blocks to the call graph, this gives around 6% performance improvement on several large ObjC benchmarks. llvm-svn: 170826
2012-12-21[analyzer] Add blocks and ObjC messages to the call graph.Anna Zaks
This paves the road for constructing a better function dependency graph. If we analyze a function before the functions it calls and inlines, there is more opportunity for optimization. Note, we add call edges to the called methods that correspond to function definitions (declarations with bodies). llvm-svn: 170825
2012-12-04Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth
uncovered. This required manually correcting all of the incorrect main-module headers I could find, and running the new llvm/utils/sort_includes.py script over the files. I also manually added quite a few missing headers that were uncovered by shuffling the order or moving headers up to be main-module-headers. llvm-svn: 169237
2012-06-06Remove unused private member variables found by clang's new ↵Benjamin Kramer
-Wunused-private-field. llvm-svn: 158086
2012-04-12[analyzer] PCH deserialization optimization.Anna Zaks
We should not deserialize unused declarations from the PCH file. Achieve this by storing the top level declarations during parsing (HandleTopLevelDecl ASTConsumer callback) and analyzing/building a call graph only for those. Tested the patch on a sample ObjC file that uses PCH. With the patch, the analyzes is 17.5% faster and clang consumes 40% less memory. Got about 10% overall build/analyzes time decrease on a large Objective C project. A bit of CallGraph refactoring/cleanup as well.. llvm-svn: 154625
2012-04-05Do not crash in the callgraph construction when encountering deleted ↵Ted Kremenek
function definitions. Fixes <rdar://problem/11178609>. llvm-svn: 154081
2012-03-14Fix dereference of end iterator. Spotted by ASan.Matt Beaumont-Gay
llvm-svn: 152738
2012-03-13[analyzer] Refactor CallGraph to use Recursive AST visitor whenAnna Zaks
collecting function Decls. llvm-svn: 152651
2012-03-09CallGraph: Add getNode() method, constify.Anna Zaks
llvm-svn: 152439
2012-03-08Call Graph: Only the root node is allowed to have an invalid Decl*.Anna Zaks
llvm-svn: 152350
2012-03-08Remove stray semi-colon.Daniel Dunbar
llvm-svn: 152331
2012-03-08Add a basic CallGraph to Analysis.Anna Zaks
The final graph contains a single root node, which is a parent of all externally available functions(and 'main'). As well as a list of Parentless/Unreachable functions, which are either truly unreachable or are unreachable due to our analyses imprecision. The analyzer checkers debug.DumpCallGraph or debug.ViewGraph can be used to look at the produced graph. Currently, the graph is not very precise, for example, it entirely skips edges resulted from ObjC method calls. llvm-svn: 152272
2009-12-03Fix layering violation by moving Analysis/CallGraph to IndexDaniel Dunbar
llvm-svn: 90424
2009-11-30Adapt to the DOTGraphTraits changes in LLVM.Tobias Grosser
llvm-svn: 90137
2009-11-14Change *BugReport constructors to take StringRefs.Benjamin Kramer
- Eliminates many calls to std::string.c_str() - Fixes an invalid read in ReturnStackAddressChecker due to an unsafe call to StringRef.data() which doesn't guarantee null-termination. llvm-svn: 88779
2009-10-28make CallGraph more flexible by letting it accept ASTContext instead of ASTUnit.Zhongxing Xu
Patch by Simone Pellegrini. llvm-svn: 85386
2009-09-29Modify ASTLocation and apart from being a Decl or Stmt, allow it to also be:Argyrios Kyrtzidis
-A NamedDecl reference -A TypeLoc llvm-svn: 83095
2009-09-29Add more const-goodness to ASTLocation.Argyrios Kyrtzidis
llvm-svn: 83087
2009-09-09Remove tabs, and whitespace cleanups.Mike Stump
llvm-svn: 81346
2009-07-24Add getDecl() to CallGraph and CallGraphNode.Zhongxing Xu
llvm-svn: 76940
2009-07-23Add two nodes to the call graph:Zhongxing Xu
- Root is the main function or 0. - ExternalCallingNode has edges to all external functions. llvm-svn: 76876
2009-07-23Add template specializations to view the call graph in dot format.Zhongxing Xu
- change the DenseMap used in callgraph to std::map, since DenseMap cannot be used with mapped_iterator and friends. llvm-svn: 76874