[analyzer] Rename clang::CallGraph into clang::idx::CallGraph + rename
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
diff --git a/examples/wpa/clang-wpa.cpp b/examples/wpa/clang-wpa.cpp
index b1119e1..8e29090 100644
--- a/examples/wpa/clang-wpa.cpp
+++ b/examples/wpa/clang-wpa.cpp
@@ -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 @@
   }
 
   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());
diff --git a/include/clang/Index/CallGraph.h b/include/clang/Index/GlobalCallGraph.h
similarity index 84%
rename from include/clang/Index/CallGraph.h
rename to include/clang/Index/GlobalCallGraph.h
index 38baf0f..7ba1cce 100644
--- a/include/clang/Index/CallGraph.h
+++ b/include/clang/Index/GlobalCallGraph.h
@@ -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"
@@ -23,15 +23,18 @@
 #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 @@
   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 @@
 
 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 @@
   CallGraphNode *ExternalCallingNode;
 
 public:
-  CallGraph(idx::Program &P);
+  CallGraph(Program &P);
   ~CallGraph();
 
   typedef FunctionMapTy::iterator iterator;
@@ -88,7 +91,7 @@
 
   void addTU(ASTContext &AST);
 
-  idx::Program &getProgram() { return Prog; }
+  Program &getProgram() { return Prog; }
 
   CallGraphNode *getOrInsertFunction(idx::Entity F);
 
@@ -100,13 +103,13 @@
   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;
diff --git a/lib/Index/CallGraph.cpp b/lib/Index/GlobalCallGraph.cpp
similarity index 94%
rename from lib/Index/CallGraph.cpp
rename to lib/Index/GlobalCallGraph.cpp
index 741e781..a21b52a 100644
--- a/lib/Index/CallGraph.cpp
+++ b/lib/Index/GlobalCallGraph.cpp
@@ -1,4 +1,4 @@
-//== CallGraph.cpp - Call graph building ------------------------*- C++ -*--==//
+//== GlobalCallGraph.cpp - Call graph building ------------------*- C++ -*--==//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -11,15 +11,17 @@
 //
 //===----------------------------------------------------------------------===//
 
-#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> {