]> granicus.if.org Git - clang/commitdiff
[analyzer] Rename clang::CallGraph into clang::idx::CallGraph + rename
authorAnna Zaks <ganna@apple.com>
Fri, 2 Mar 2012 22:54:36 +0000 (22:54 +0000)
committerAnna Zaks <ganna@apple.com>
Fri, 2 Mar 2012 22:54:36 +0000 (22:54 +0000)
the corresponding files to avoid confusion.

This is a preparation to adding an AST-based call graph to Analysis. The
existing call graph works with indexer entries. We might be able to
refactor it to use the AST based graph in the future.

(Minimal testing here as the only example that uses the API has been
completely broken, does not compile.)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151950 91177308-0d34-0410-b5e6-96231b3b80d8

examples/wpa/clang-wpa.cpp
include/clang/Index/GlobalCallGraph.h [moved from include/clang/Index/CallGraph.h with 84% similarity]
lib/Index/GlobalCallGraph.cpp [moved from lib/Index/CallGraph.cpp with 94% similarity]

index b1119e14b7959db43adf8e5a5dc5768fe93c7023..8e29090fe78b9074fe8e2ae6e62c18fbe0f6ffd8 100644 (file)
@@ -22,7 +22,7 @@
 #include "clang/StaticAnalyzer/Checkers/LocalCheckers.h"
 #include "clang/Frontend/ASTUnit.h"
 #include "clang/Frontend/CompilerInstance.h"
-#include "clang/Index/CallGraph.h"
+#include "clang/Index/GlobalCallGraph.h"
 #include "clang/Index/Indexer.h"
 #include "clang/Index/TranslationUnit.h"
 #include "clang/Index/DeclReferenceMap.h"
@@ -104,8 +104,8 @@ int main(int argc, char **argv) {
   }
 
   if (ViewCallGraph) {
-    OwningPtr<CallGraph> CG;
-    CG.reset(new CallGraph(Prog));
+    OwningPtr<clang::idx::CallGraph> CG;
+    CG.reset(new clang::idx::CallGraph(Prog));
 
     for (unsigned i = 0, e = ASTUnits.size(); i != e; ++i)
       CG->addTU(ASTUnits[i]->getASTContext());
similarity index 84%
rename from include/clang/Index/CallGraph.h
rename to include/clang/Index/GlobalCallGraph.h
index 38baf0f7537f4bda1135221f15e271b116cfcb7b..7ba1cceac1844d39543f00d4356d2e5957f2a3b9 100644 (file)
@@ -1,4 +1,4 @@
-//== CallGraph.cpp - Call graph building ------------------------*- C++ -*--==//
+//== GlobalCallGraph.h - Call graph building --------------------*- C++ -*--==//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -11,8 +11,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_CLANG_ANALYSIS_CALLGRAPH
-#define LLVM_CLANG_ANALYSIS_CALLGRAPH
+#ifndef LLVM_CLANG_INDEX_CALLGRAPH
+#define LLVM_CLANG_INDEX_CALLGRAPH
 
 #include "clang/Index/ASTLocation.h"
 #include "clang/Index/Entity.h"
 #include <vector>
 #include <map>
 
+using namespace clang;
+
 namespace clang {
+namespace idx {
 
 class CallGraphNode {
-  idx::Entity F;
-  typedef std::pair<idx::ASTLocation, CallGraphNode*> CallRecord;
+  Entity F;
+  typedef std::pair<ASTLocation, CallGraphNode*> CallRecord;
   std::vector<CallRecord> CalledFunctions;
 
 public:
-  CallGraphNode(idx::Entity f) : F(f) {}
+  CallGraphNode(Entity f) : F(f) {}
 
   typedef std::vector<CallRecord>::iterator iterator;
   typedef std::vector<CallRecord>::const_iterator const_iterator;
@@ -41,7 +44,7 @@ public:
   const_iterator begin() const { return CalledFunctions.begin(); }
   const_iterator end()   const { return CalledFunctions.end();   }
 
-  void addCallee(idx::ASTLocation L, CallGraphNode *Node) {
+  void addCallee(ASTLocation L, CallGraphNode *Node) {
     CalledFunctions.push_back(std::make_pair(L, Node));
   }
 
@@ -54,9 +57,9 @@ public:
 
 class CallGraph {
   /// Program manages all Entities.
-  idx::Program &Prog;
+  Program &Prog;
 
-  typedef std::map<idx::Entity, CallGraphNode *> FunctionMapTy;
+  typedef std::map<Entity, CallGraphNode *> FunctionMapTy;
 
   /// FunctionMap owns all CallGraphNodes.
   FunctionMapTy FunctionMap;
@@ -71,7 +74,7 @@ class CallGraph {
   CallGraphNode *ExternalCallingNode;
 
 public:
-  CallGraph(idx::Program &P);
+  CallGraph(Program &P);
   ~CallGraph();
 
   typedef FunctionMapTy::iterator iterator;
@@ -88,7 +91,7 @@ public:
 
   void addTU(ASTContext &AST);
 
-  idx::Program &getProgram() { return Prog; }
+  Program &getProgram() { return Prog; }
 
   CallGraphNode *getOrInsertFunction(idx::Entity F);
 
@@ -100,13 +103,13 @@ public:
   void ViewCallGraph() const;
 };
 
-} // end clang namespace
+}} // end clang idx namespace
 
 namespace llvm {
 
-template <> struct GraphTraits<clang::CallGraph> {
-  typedef clang::CallGraph GraphType;
-  typedef clang::CallGraphNode NodeType;
+template <> struct GraphTraits<clang::idx::CallGraph> {
+  typedef clang::idx::CallGraph GraphType;
+  typedef clang::idx::CallGraphNode NodeType;
 
   typedef std::pair<clang::idx::ASTLocation, NodeType*> CGNPairTy;
   typedef std::pointer_to_unary_function<CGNPairTy, NodeType*> CGNDerefFun;
similarity index 94%
rename from lib/Index/CallGraph.cpp
rename to lib/Index/GlobalCallGraph.cpp
index 741e78107f84639c697238ab863eaddf60e985e0..a21b52ae60272afc1723ba37d81a4c0e8bfa9417 100644 (file)
@@ -1,4 +1,4 @@
-//== CallGraph.cpp - Call graph building ------------------------*- C++ -*--==//
+//== GlobalCallGraph.cpp - Call graph building ------------------*- C++ -*--==//
 //
 //                     The LLVM Compiler Infrastructure
 //
 //
 //===----------------------------------------------------------------------===//
 
-#include "clang/Index/CallGraph.h"
+#include "clang/Index/GlobalCallGraph.h"
 
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/StmtVisitor.h"
 
 #include "llvm/Support/GraphWriter.h"
 
-using namespace clang;
-using namespace idx;
+using namespace clang::idx;
+using clang::FunctionDecl;
+using clang::DeclContext;
+using clang::ASTContext;
 
 namespace {
 class CGBuilder : public StmtVisitor<CGBuilder> {