Commit Graph

28 Commits

Author SHA1 Message Date
Benjamin Kramer d1d76b2da7 Remove unused private member variables found by clang's new -Wunused-private-field.
llvm-svn: 158086
2012-06-06 17:32:50 +00:00
Anna Zaks 8e0785286a [analyzer] PCH deserialization optimization.
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-12 22:36:48 +00:00
Ted Kremenek 504957f413 Do not crash in the callgraph construction when encountering deleted function definitions. Fixes <rdar://problem/11178609>.
llvm-svn: 154081
2012-04-05 04:03:23 +00:00
Matt Beaumont-Gay dcc425ec19 Fix dereference of end iterator. Spotted by ASan.
llvm-svn: 152738
2012-03-14 20:21:25 +00:00
Anna Zaks 32da47b9a1 [analyzer] Refactor CallGraph to use Recursive AST visitor when
collecting function Decls.

llvm-svn: 152651
2012-03-13 19:32:08 +00:00
Anna Zaks c255577062 CallGraph: Add getNode() method, constify.
llvm-svn: 152439
2012-03-09 21:13:53 +00:00
Anna Zaks 9a008bb7f8 Call Graph: Only the root node is allowed to have an invalid Decl*.
llvm-svn: 152350
2012-03-08 23:16:26 +00:00
Daniel Dunbar eb72532098 Remove stray semi-colon.
llvm-svn: 152331
2012-03-08 20:28:59 +00:00
Anna Zaks c000e7ed3d Add a basic CallGraph to Analysis.
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
2012-03-08 00:42:23 +00:00
Daniel Dunbar 19a30ca8c0 Fix layering violation by moving Analysis/CallGraph to Index
llvm-svn: 90424
2009-12-03 07:20:04 +00:00
Tobias Grosser 9fc223a6b1 Adapt to the DOTGraphTraits changes in LLVM.
llvm-svn: 90137
2009-11-30 14:16:05 +00:00
Benjamin Kramer f4c511b026 Change *BugReport constructors to take StringRefs.
- 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-11-14 12:08:24 +00:00
Zhongxing Xu cb131542f1 make CallGraph more flexible by letting it accept ASTContext instead of ASTUnit.
Patch by Simone Pellegrini.

llvm-svn: 85386
2009-10-28 12:23:03 +00:00
Argyrios Kyrtzidis 4cbe85904c Modify ASTLocation and apart from being a Decl or Stmt, allow it to also be:
-A NamedDecl reference
-A TypeLoc

llvm-svn: 83095
2009-09-29 19:44:27 +00:00
Argyrios Kyrtzidis 81aba1fe53 Add more const-goodness to ASTLocation.
llvm-svn: 83087
2009-09-29 19:39:53 +00:00
Mike Stump 11289f4280 Remove tabs, and whitespace cleanups.
llvm-svn: 81346
2009-09-09 15:08:12 +00:00
Zhongxing Xu 30ac7607be Add getDecl() to CallGraph and CallGraphNode.
llvm-svn: 76940
2009-07-24 03:41:11 +00:00
Zhongxing Xu ee5d708e55 Add two nodes to the call graph:
- Root is the main function or 0.
 - ExternalCallingNode has edges to all external functions.

llvm-svn: 76876
2009-07-23 13:39:38 +00:00
Zhongxing Xu a598e5c9d5 Add template specializations to view the call graph in dot format.
- change the DenseMap used in callgraph to std::map, since DenseMap cannot
   be used with mapped_iterator and friends.

llvm-svn: 76874
2009-07-23 09:04:23 +00:00
Argyrios Kyrtzidis 8274ad5281 Remove the ASTContext parameter from Entity::getPrintableName().
llvm-svn: 76546
2009-07-21 07:52:21 +00:00
Argyrios Kyrtzidis 05ac8276cf Change the semantics for Entity.
Entity can now refer to declarations that are not visible outside the translation unit.
It is a wrapper of a pointer union, it's either a Decl* for declarations that don't
"cross" translation units, or an EntityImpl* which is associated with the specific "visible" Decl.

Included is a test case for handling fields across translation units.

llvm-svn: 76515
2009-07-21 00:07:06 +00:00
Zhongxing Xu 4b9f2d082a Replace stmt visitors with the fall back method.
llvm-svn: 76294
2009-07-18 08:49:07 +00:00
Zhongxing Xu 9d05213899 Rename Entity::getName() to Entity::getPrintableName() to make its purpose
more obvious.

llvm-svn: 76167
2009-07-17 07:49:44 +00:00
Zhongxing Xu 3436f58e40 As suggested by Argyrios, revert r76159 and make "FindImmediateParent"
a public static method of ASTLocation.

llvm-svn: 76166
2009-07-17 07:36:20 +00:00
Zhongxing Xu 3c8fa978ad Refactor code into a new CallExpr::getDirectCallee() method. Simplify some
code with the new method.

llvm-svn: 76164
2009-07-17 07:29:51 +00:00
Zhongxing Xu 2391d265ed CallGraph: add a bunch of stmt visitors.
llvm-svn: 76161
2009-07-17 07:05:19 +00:00
Zhongxing Xu 6c1b35a0ef CallGraph:
- add IfStmt visitor.
 - print information only when a function has callee. Otherwise its ASTContext
   map is NULL.

llvm-svn: 76156
2009-07-17 05:49:16 +00:00
Zhongxing Xu bc6eb71f31 Commit the initial implementation of call graph building.
llvm-svn: 75873
2009-07-16 00:54:12 +00:00