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
diff --git a/lib/Analysis/CallGraph.cpp b/lib/Analysis/CallGraph.cpp
index cf8f620..2530fc0 100644
--- a/lib/Analysis/CallGraph.cpp
+++ b/lib/Analysis/CallGraph.cpp
@@ -25,12 +25,12 @@
   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 @@
 
 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 @@
     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 @@
   }
 }
 
-CallGraphNode *CallGraph::getOrInsertFunction(Entity *F) {
+CallGraphNode *CallGraph::getOrInsertFunction(Entity F) {
   CallGraphNode *&Node = FunctionMap[F];
   if (Node)
     return Node;
@@ -98,7 +98,7 @@
   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) {