diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2009-07-21 00:07:06 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2009-07-21 00:07:06 +0000 |
commit | f7cf15ca3c9bee7c0348f549e7a8f0af32b5fa54 (patch) | |
tree | 05e1fd135984a32777ddfbd291bfdc913046d50a /lib/Analysis/CallGraph.cpp | |
parent | 07ef804f918d8aade8739a02e78c6209fd3062a9 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76515 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/CallGraph.cpp')
-rw-r--r-- | lib/Analysis/CallGraph.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/Analysis/CallGraph.cpp b/lib/Analysis/CallGraph.cpp index cf8f6205ab..2530fc0ad7 100644 --- a/lib/Analysis/CallGraph.cpp +++ b/lib/Analysis/CallGraph.cpp @@ -25,12 +25,12 @@ class CGBuilder : public StmtVisitor<CGBuilder> { CallGraph &G; FunctionDecl *FD; - Entity *CallerEnt; + Entity CallerEnt; CallGraphNode *CallerNode; public: - CGBuilder(CallGraph &g, FunctionDecl *fd, Entity *E, CallGraphNode *N) + CGBuilder(CallGraph &g, FunctionDecl *fd, Entity E, CallGraphNode *N) : G(g), FD(fd), CallerEnt(E), CallerNode(N) {} void VisitStmt(Stmt *S) { VisitChildren(S); } @@ -47,7 +47,7 @@ public: void CGBuilder::VisitCallExpr(CallExpr *CE) { if (FunctionDecl *CalleeDecl = CE->getDirectCallee()) { - Entity *Ent = Entity::get(CalleeDecl, G.getProgram()); + Entity Ent = Entity::get(CalleeDecl, G.getProgram()); CallGraphNode *CalleeNode = G.getOrInsertFunction(Ent); Decl *Parent = ASTLocation::FindImmediateParent(FD, CE); @@ -75,7 +75,7 @@ void CallGraph::addTU(ASTUnit &AST) { if (FunctionDecl *FD = dyn_cast<FunctionDecl>(*I)) { if (FD->isThisDeclarationADefinition()) { // Set caller's ASTContext. - Entity *Ent = Entity::get(FD, Prog); + Entity Ent = Entity::get(FD, Prog); CallGraphNode *Node = getOrInsertFunction(Ent); CallerCtx[Node] = &Ctx; @@ -86,7 +86,7 @@ void CallGraph::addTU(ASTUnit &AST) { } } -CallGraphNode *CallGraph::getOrInsertFunction(Entity *F) { +CallGraphNode *CallGraph::getOrInsertFunction(Entity F) { CallGraphNode *&Node = FunctionMap[F]; if (Node) return Node; @@ -98,7 +98,7 @@ void CallGraph::print(llvm::raw_ostream &os) { for (iterator I = begin(), E = end(); I != E; ++I) { if (I->second->hasCallee()) { ASTContext &Ctx = *CallerCtx[I->second]; - os << "function: " << I->first->getPrintableName(Ctx).c_str() + os << "function: " << I->first.getPrintableName(Ctx).c_str() << " calls:\n"; for (CallGraphNode::iterator CI = I->second->begin(), CE = I->second->end(); CI != CE; ++CI) { |