Remove FileVarDecl and BlockVarDecl. They are replaced by VarDecl::isBlockVarDecl() and VarDecl::isFileVarDecl().

This is a fairly mechanical/large change. As a result, I avoided making any changes/simplifications that weren't directly related. I did break two Analysis tests. I also have a couple FIXME's in UninitializedValues.cpp. Ted, can you take a look? If the bug isn't obvious, I am happy to dig in and fix it (since I broke it).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49748 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index ac1a593..cee7dda 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -24,8 +24,7 @@
 
 // temporary statistics gathering
 static unsigned nFuncs = 0;
-static unsigned nBlockVars = 0;
-static unsigned nFileVars = 0;
+static unsigned nVars = 0;
 static unsigned nParmVars = 0;
 static unsigned nSUC = 0;
 static unsigned nEnumConst = 0;
@@ -59,8 +58,7 @@
   default: assert(0 && "Unknown decl kind!");
   case Typedef:             return "Typedef";
   case Function:            return "Function";
-  case BlockVar:            return "BlockVar";
-  case FileVar:             return "FileVar";
+  case Var:                 return "Var";
   case ParmVar:             return "ParmVar";
   case EnumConstant:        return "EnumConstant";
   case ObjCInterface:       return "ObjCInterface";
@@ -84,17 +82,14 @@
 void Decl::PrintStats() {
   fprintf(stderr, "*** Decl Stats:\n");
   fprintf(stderr, "  %d decls total.\n", 
-          int(nFuncs+nBlockVars+nFileVars+nParmVars+nFieldDecls+nSUC+
+          int(nFuncs+nVars+nParmVars+nFieldDecls+nSUC+
               nEnumDecls+nEnumConst+nTypedef+nInterfaceDecls+nClassDecls+
               nMethodDecls+nProtocolDecls+nCategoryDecls+nIvarDecls));
   fprintf(stderr, "    %d function decls, %d each (%d bytes)\n", 
           nFuncs, (int)sizeof(FunctionDecl), int(nFuncs*sizeof(FunctionDecl)));
-  fprintf(stderr, "    %d block variable decls, %d each (%d bytes)\n", 
-          nBlockVars, (int)sizeof(BlockVarDecl), 
-          int(nBlockVars*sizeof(BlockVarDecl)));
-  fprintf(stderr, "    %d file variable decls, %d each (%d bytes)\n", 
-          nFileVars, (int)sizeof(FileVarDecl), 
-          int(nFileVars*sizeof(FileVarDecl)));
+  fprintf(stderr, "    %d variable decls, %d each (%d bytes)\n", 
+          nVars, (int)sizeof(VarDecl), 
+          int(nVars*sizeof(VarDecl)));
   fprintf(stderr, "    %d parameter variable decls, %d each (%d bytes)\n", 
           nParmVars, (int)sizeof(ParmVarDecl),
           int(nParmVars*sizeof(ParmVarDecl)));
@@ -152,8 +147,8 @@
           int(nObjCPropertyDecl*sizeof(ObjCPropertyDecl)));
   
   fprintf(stderr, "Total bytes = %d\n", 
-          int(nFuncs*sizeof(FunctionDecl)+nBlockVars*sizeof(BlockVarDecl)+
-              nFileVars*sizeof(FileVarDecl)+nParmVars*sizeof(ParmVarDecl)+
+          int(nFuncs*sizeof(FunctionDecl)+
+              nVars*sizeof(VarDecl)+nParmVars*sizeof(ParmVarDecl)+
               nFieldDecls*sizeof(FieldDecl)+nSUC*sizeof(RecordDecl)+
               nEnumDecls*sizeof(EnumDecl)+nEnumConst*sizeof(EnumConstantDecl)+
               nTypedef*sizeof(TypedefDecl)+
@@ -177,8 +172,7 @@
   switch (k) {
   case Typedef:             nTypedef++; break;
   case Function:            nFuncs++; break;
-  case BlockVar:            nBlockVars++; break;
-  case FileVar:             nFileVars++; break;
+  case Var:                 nVars++; break;
   case ParmVar:             nParmVars++; break;
   case EnumConstant:        nEnumConst++; break;
   case Field:               nFieldDecls++; break;
@@ -204,23 +198,15 @@
 // Decl Allocation/Deallocation Method Implementations
 //===----------------------------------------------------------------------===//
 
-BlockVarDecl *BlockVarDecl::Create(ASTContext &C, DeclContext *CD,
-                                   SourceLocation L,
-                                   IdentifierInfo *Id, QualType T,
-                                   StorageClass S, ScopedDecl *PrevDecl) {
-  void *Mem = C.getAllocator().Allocate<BlockVarDecl>();
-  return new (Mem) BlockVarDecl(CD, L, Id, T, S, PrevDecl);
+VarDecl *VarDecl::Create(ASTContext &C, DeclContext *CD,
+                         SourceLocation L,
+                         IdentifierInfo *Id, QualType T,
+                         StorageClass S, ScopedDecl *PrevDecl) {
+  void *Mem = C.getAllocator().Allocate<VarDecl>();
+  return new (Mem) VarDecl(Var, CD, L, Id, T, S, PrevDecl);
 }
 
 
-FileVarDecl *FileVarDecl::Create(ASTContext &C, DeclContext *CD,
-                                 SourceLocation L, IdentifierInfo *Id,
-                                 QualType T, StorageClass S,
-                                 ScopedDecl *PrevDecl) {
-  void *Mem = C.getAllocator().Allocate<FileVarDecl>();
-  return new (Mem) FileVarDecl(CD, L, Id, T, S, PrevDecl);
-}
-
 ParmVarDecl *ParmVarDecl::Create(ASTContext &C, DeclContext *CD,
                                  SourceLocation L, IdentifierInfo *Id,
                                  QualType T, StorageClass S,
@@ -347,8 +333,7 @@
   CASE(Enum);
   CASE(EnumConstant);
   CASE(Function);
-  CASE(BlockVar);
-  CASE(FileVar);
+  CASE(Var);
   CASE(ParmVar);
   CASE(ObjCInterface);
   CASE(ObjCCompatibleAlias);
diff --git a/lib/AST/DeclSerialization.cpp b/lib/AST/DeclSerialization.cpp
index 6b0d7f8..96df1b7 100644
--- a/lib/AST/DeclSerialization.cpp
+++ b/lib/AST/DeclSerialization.cpp
@@ -41,8 +41,8 @@
       assert (false && "Not implemented.");
       break;
 
-    case BlockVar:
-      return BlockVarDecl::CreateImpl(D, C);
+    case Var:
+      return VarDecl::CreateImpl(D, C);
       
     case Enum:
       return EnumDecl::CreateImpl(D, C);
@@ -53,9 +53,6 @@
     case Field:
       return FieldDecl::CreateImpl(D, C);
       
-    case FileVar:
-      return FileVarDecl::CreateImpl(D, C);
-      
     case ParmVar:
       return ParmVarDecl::CreateImpl(D, C);
       
@@ -195,13 +192,13 @@
 }
 
 //===----------------------------------------------------------------------===//
-//      BlockVarDecl Serialization.
+//      VarDecl Serialization.
 //===----------------------------------------------------------------------===//
 
-BlockVarDecl* BlockVarDecl::CreateImpl(Deserializer& D, ASTContext& C) {  
-  void *Mem = C.getAllocator().Allocate<BlockVarDecl>();
-  BlockVarDecl* decl =
-    new (Mem) BlockVarDecl(0, SourceLocation(), NULL, QualType(), None, NULL);
+VarDecl* VarDecl::CreateImpl(Deserializer& D, ASTContext& C) {  
+  void *Mem = C.getAllocator().Allocate<VarDecl>();
+  VarDecl* decl =
+    new (Mem) VarDecl(Var, 0, SourceLocation(), NULL, QualType(), None, NULL);
  
   decl->VarDecl::ReadImpl(D, C);
   
@@ -209,21 +206,7 @@
 }
 
 //===----------------------------------------------------------------------===//
-//      FileVarDecl Serialization.
-//===----------------------------------------------------------------------===//
-
-FileVarDecl* FileVarDecl::CreateImpl(Deserializer& D, ASTContext& C) {
-  void *Mem = C.getAllocator().Allocate<FileVarDecl>();
-  FileVarDecl* decl =
-    new (Mem) FileVarDecl(0, SourceLocation(), NULL, QualType(), None, NULL);
-  
-  decl->VarDecl::ReadImpl(D, C);
-
-  return decl;
-}
-
-//===----------------------------------------------------------------------===//
-//      ParmDecl Serialization.
+//      ParmVarDecl Serialization.
 //===----------------------------------------------------------------------===//
 
 void ParmVarDecl::EmitImpl(llvm::Serializer& S) const {
diff --git a/lib/AST/StmtDumper.cpp b/lib/AST/StmtDumper.cpp
index dd7e2b3..2d4adf8 100644
--- a/lib/AST/StmtDumper.cpp
+++ b/lib/AST/StmtDumper.cpp
@@ -280,8 +280,7 @@
   fprintf(F, " ");
   switch (Node->getDecl()->getKind()) {
     case Decl::Function: fprintf(F,"FunctionDecl"); break;
-    case Decl::BlockVar: fprintf(F,"BlockVar"); break;
-    case Decl::FileVar: fprintf(F,"FileVar"); break;
+    case Decl::Var: fprintf(F,"Var"); break;
     case Decl::ParmVar: fprintf(F,"ParmVar"); break;
     case Decl::EnumConstant: fprintf(F,"EnumConstant"); break;
     case Decl::Typedef: fprintf(F,"Typedef"); break;