[cfe-commits] r49748 - in /cfe/trunk: Driver/ include/clang/AST/ include/clang/Analysis/Analyses/ include/clang/Analysis/Visitors/ lib/AST/ lib/Analysis/ lib/CodeGen/ lib/Sema/

Steve Naroff snaroff at apple.com
Tue Apr 15 15:42:07 PDT 2008


Author: snaroff
Date: Tue Apr 15 17:42:06 2008
New Revision: 49748

URL: http://llvm.org/viewvc/llvm-project?rev=49748&view=rev
Log:
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).

Modified:
    cfe/trunk/Driver/RewriteObjC.cpp
    cfe/trunk/include/clang/AST/Decl.h
    cfe/trunk/include/clang/AST/DeclBase.h
    cfe/trunk/include/clang/Analysis/Analyses/UninitializedValues.h
    cfe/trunk/include/clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h
    cfe/trunk/lib/AST/Decl.cpp
    cfe/trunk/lib/AST/DeclSerialization.cpp
    cfe/trunk/lib/AST/StmtDumper.cpp
    cfe/trunk/lib/Analysis/GRExprEngine.cpp
    cfe/trunk/lib/Analysis/UninitializedValues.cpp
    cfe/trunk/lib/CodeGen/CGDecl.cpp
    cfe/trunk/lib/CodeGen/CGExpr.cpp
    cfe/trunk/lib/CodeGen/CGExprConstant.cpp
    cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
    cfe/trunk/lib/CodeGen/CodeGenFunction.h
    cfe/trunk/lib/CodeGen/CodeGenModule.cpp
    cfe/trunk/lib/CodeGen/CodeGenModule.h
    cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
    cfe/trunk/lib/Sema/SemaStmt.cpp

Modified: cfe/trunk/Driver/RewriteObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteObjC.cpp?rev=49748&r1=49747&r2=49748&view=diff

==============================================================================
--- cfe/trunk/Driver/RewriteObjC.cpp (original)
+++ cfe/trunk/Driver/RewriteObjC.cpp Tue Apr 15 17:42:06 2008
@@ -70,7 +70,7 @@
     FunctionDecl *SuperContructorFunctionDecl;
       
     // ObjC string constant support.
-    FileVarDecl *ConstantStringClassReference;
+    VarDecl *ConstantStringClassReference;
     RecordDecl *NSStringRecord;
     
     // ObjC foreach break/continue generation support.
@@ -367,7 +367,7 @@
   // Look for built-in declarations that we need to refer during the rewrite.
   if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
     RewriteFunctionDecl(FD);
-  } else if (FileVarDecl *FVD = dyn_cast<FileVarDecl>(D)) {
+  } else if (VarDecl *FVD = dyn_cast<VarDecl>(D)) {
     // declared in <Foundation/NSString.h>
     if (strcmp(FVD->getName(), "_NSConstantStringClassReference") == 0) {
       ConstantStringClassReference = FVD;
@@ -1776,9 +1776,9 @@
   // The minus 2 removes the begin/end double quotes.
   Preamble += utostr(prettyBuf.str().size()-2) + "};\n";
   
-  FileVarDecl *NewVD = FileVarDecl::Create(*Context, NULL, SourceLocation(), 
-                                       &Context->Idents.get(S.c_str()), strType, 
-                                       VarDecl::Static, NULL);
+  VarDecl *NewVD = VarDecl::Create(*Context, NULL, SourceLocation(), 
+                                    &Context->Idents.get(S.c_str()), strType, 
+                                    VarDecl::Static, NULL);
   DeclRefExpr *DRE = new DeclRefExpr(NewVD, strType, SourceLocation());
   Expr *Unop = new UnaryOperator(DRE, UnaryOperator::AddrOf,
                                  Context->getPointerType(DRE->getType()), 

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=49748&r1=49747&r2=49748&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Tue Apr 15 17:42:06 2008
@@ -146,6 +146,10 @@
           StorageClass SC, ScopedDecl *PrevDecl)
     : ValueDecl(DK, CD, L, Id, T, PrevDecl), Init(0) { SClass = SC; }
 public:
+  static VarDecl *Create(ASTContext &C, DeclContext *CD,
+                         SourceLocation L, IdentifierInfo *Id,
+                         QualType T, StorageClass S, ScopedDecl *PrevDecl);
+  
   StorageClass getStorageClass() const { return (StorageClass)SClass; }
 
   const Expr *getInit() const { return Init; }
@@ -156,7 +160,7 @@
   ///  is a non-static local variable.
   bool hasLocalStorage() const {
     if (getStorageClass() == None)
-      return getKind() != FileVar;
+      return !isFileVarDecl();
     
     // Return true for:  Auto, Register.
     // Return false for: Extern, Static, PrivateExtern.
@@ -168,6 +172,29 @@
   ///  have local storage.  This includs all global variables as well
   ///  as static variables declared within a function.
   bool hasGlobalStorage() const { return !hasLocalStorage(); }
+
+  /// isBlockVarDecl - Returns true for local variable declarations.  Note that
+  /// this includes static variables inside of functions.
+  ///
+  ///   void foo() { int x; static int y; extern int z; }
+  ///
+  bool isBlockVarDecl() const {
+    if (getKind() != Decl::Var)
+      return false;
+    if (DeclContext *DC = getDeclContext())
+      return DC->isFunctionOrMethod();
+    return false;
+  }
+  
+  /// isFileVarDecl - Returns true for file scoped variable declaration.
+  bool isFileVarDecl() const {
+    if (getKind() != Decl::Var)
+      return false;
+    // FIXME: change when TranlationUnitDecl is added as a declaration context.
+    if (!getDeclContext())
+      return true;
+    return false;
+  }
   
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Decl *D) {
@@ -187,56 +214,9 @@
   
   /// ReadImpl - Deserialize this VarDecl. Called by subclasses.
   virtual void ReadImpl(llvm::Deserializer& D, ASTContext& C);
-};
-
-/// BlockVarDecl - Represent a local variable declaration.  Note that this
-/// includes static variables inside of functions.
-///
-///   void foo() { int x; static int y; extern int z; }
-///
-class BlockVarDecl : public VarDecl {
-  BlockVarDecl(DeclContext *CD, SourceLocation L,
-               IdentifierInfo *Id, QualType T, StorageClass S,
-               ScopedDecl *PrevDecl)
-    : VarDecl(BlockVar, CD, L, Id, T, S, PrevDecl) {}
-public:
-  static BlockVarDecl *Create(ASTContext &C, DeclContext *CD, SourceLocation L,
-                              IdentifierInfo *Id, QualType T, StorageClass S,
-                              ScopedDecl *PrevDecl);
-  // Implement isa/cast/dyncast/etc.
-  static bool classof(const Decl *D) { return D->getKind() == BlockVar; }
-  static bool classof(const BlockVarDecl *D) { return true; }  
-
-protected:
-  /// CreateImpl - Deserialize a BlockVarDecl.  Called by Decl::Create.
-  static BlockVarDecl* CreateImpl(llvm::Deserializer& D, ASTContext& C);
-
-  friend Decl* Decl::Create(llvm::Deserializer& D, ASTContext& C);
-};
-
-/// FileVarDecl - Represent a file scoped variable declaration. This
-/// will allow us to reason about external variable declarations and tentative 
-/// definitions (C99 6.9.2p2) using our type system (without storing a
-/// pointer to the decl's scope, which is transient).
-class FileVarDecl : public VarDecl {
-  FileVarDecl(DeclContext *CD, SourceLocation L,
-              IdentifierInfo *Id, QualType T, StorageClass S,
-              ScopedDecl *PrevDecl)
-    : VarDecl(FileVar, CD, L, Id, T, S, PrevDecl) {}
-public:
-  static FileVarDecl *Create(ASTContext &C, DeclContext *CD,
-                             SourceLocation L, IdentifierInfo *Id,
-                             QualType T, StorageClass S, ScopedDecl *PrevDecl);
   
-  // Implement isa/cast/dyncast/etc.
-  static bool classof(const Decl *D) { return D->getKind() == FileVar; }
-  static bool classof(const FileVarDecl *D) { return true; }
-
-protected:
-  /// CreateImpl - Deserialize a FileVarDecl.  Called by Decl::Create.
-  static FileVarDecl* CreateImpl(llvm::Deserializer& D, ASTContext& C);
-
-  friend Decl* Decl::Create(llvm::Deserializer& D, ASTContext& C);
+  /// CreateImpl - Deserialize a VarDecl.  Called by Decl::Create.
+  static VarDecl* CreateImpl(llvm::Deserializer& D, ASTContext& C);
 };
 
 /// ParmVarDecl - Represent a parameter to a function.

Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=49748&r1=49747&r2=49748&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Tue Apr 15 17:42:06 2008
@@ -55,9 +55,7 @@
     //       ValueDecl
                EnumConstant,
                Function,
-    //         VarDecl
-                 BlockVar,
-                 FileVar,
+               Var,
                  ParmVar,
          ObjCInterface,
          ObjCCompatibleAlias,
@@ -76,7 +74,7 @@
     TagFirst    = Enum         , TagLast    = Class,
     RecordFirst = Struct       , RecordLast = Class,
     ValueFirst  = EnumConstant , ValueLast  = ParmVar,
-    VarFirst    = BlockVar     , VarLast    = ParmVar
+    VarFirst    = Var          , VarLast    = ParmVar
   };
 
   /// IdentifierNamespace - According to C99 6.2.3, there are four namespaces,
@@ -151,8 +149,7 @@
     default: assert(0 && "Unknown decl kind!");
     case Typedef:
     case Function:
-    case BlockVar:
-    case FileVar:
+    case Var:
     case ParmVar:
     case EnumConstant:
     case ObjCInterface:

Modified: cfe/trunk/include/clang/Analysis/Analyses/UninitializedValues.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Analyses/UninitializedValues.h?rev=49748&r1=49747&r2=49748&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/Analyses/UninitializedValues.h (original)
+++ cfe/trunk/include/clang/Analysis/Analyses/UninitializedValues.h Tue Apr 15 17:42:06 2008
@@ -51,7 +51,7 @@
   struct ObserverTy {
     virtual ~ObserverTy();
     virtual void ObserveDeclRefExpr(ValTy& Val, AnalysisDataTy& AD, 
-                                    DeclRefExpr* DR, BlockVarDecl* VD) = 0;
+                                    DeclRefExpr* DR, VarDecl* VD) = 0;
   };  
 };
 

Modified: cfe/trunk/include/clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h?rev=49748&r1=49747&r2=49748&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h (original)
+++ cfe/trunk/include/clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h Tue Apr 15 17:42:06 2008
@@ -54,8 +54,7 @@
   void VisitScopedDecl(ScopedDecl* D) {
     switch (D->getKind()) {
         DISPATCH_CASE(Function,FunctionDecl)
-        DISPATCH_CASE(BlockVar,BlockVarDecl) // FIXME:Refine. VisitVarDecl?
-        DISPATCH_CASE(FileVar,FileVarDecl)   // FIXME: (same)
+        DISPATCH_CASE(Var,VarDecl)
         DISPATCH_CASE(ParmVar,ParmVarDecl)       // FIXME: (same)
         DISPATCH_CASE(EnumConstant,EnumConstantDecl)
         DISPATCH_CASE(Typedef,TypedefDecl)
@@ -70,8 +69,6 @@
   
   DEFAULT_DISPATCH(VarDecl)
   DEFAULT_DISPATCH(FunctionDecl)
-  DEFAULT_DISPATCH_VARDECL(BlockVarDecl)
-  DEFAULT_DISPATCH_VARDECL(FileVarDecl)
   DEFAULT_DISPATCH_VARDECL(ParmVarDecl)
   DEFAULT_DISPATCH(EnumConstantDecl)
   DEFAULT_DISPATCH(TypedefDecl)

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=49748&r1=49747&r2=49748&view=diff

==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Tue Apr 15 17:42:06 2008
@@ -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);

Modified: cfe/trunk/lib/AST/DeclSerialization.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclSerialization.cpp?rev=49748&r1=49747&r2=49748&view=diff

==============================================================================
--- cfe/trunk/lib/AST/DeclSerialization.cpp (original)
+++ cfe/trunk/lib/AST/DeclSerialization.cpp Tue Apr 15 17:42:06 2008
@@ -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 {

Modified: cfe/trunk/lib/AST/StmtDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtDumper.cpp?rev=49748&r1=49747&r2=49748&view=diff

==============================================================================
--- cfe/trunk/lib/AST/StmtDumper.cpp (original)
+++ cfe/trunk/lib/AST/StmtDumper.cpp Tue Apr 15 17:42:06 2008
@@ -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;

Modified: cfe/trunk/lib/Analysis/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRExprEngine.cpp?rev=49748&r1=49747&r2=49748&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Tue Apr 15 17:42:06 2008
@@ -738,7 +738,7 @@
         // In this context, Static => Local variable.
         
         assert (!VD->getStorageClass() == VarDecl::Static ||
-                !isa<FileVarDecl>(VD));
+                !VD->isFileVarDecl());
         
         // If there is no initializer, set the value of the
         // variable to "Undefined".

Modified: cfe/trunk/lib/Analysis/UninitializedValues.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/UninitializedValues.cpp?rev=49748&r1=49747&r2=49748&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/UninitializedValues.cpp (original)
+++ cfe/trunk/lib/Analysis/UninitializedValues.cpp Tue Apr 15 17:42:06 2008
@@ -36,7 +36,7 @@
 public:
   RegisterDecls(UninitializedValues::AnalysisDataTy& ad) :  AD(ad) {}
   
-  void VisitBlockVarDecl(BlockVarDecl* VD) { AD.Register(VD); }
+  void VisitBlockVarDecl(VarDecl* VD) { AD.Register(VD); }
   CFG& getCFG() { return AD.getCFG(); }
 };
   
@@ -80,14 +80,16 @@
     
   void VisitTerminator(Stmt* T) { }
   
-  BlockVarDecl* FindBlockVarDecl(Stmt* S);
+  VarDecl* FindBlockVarDecl(Stmt* S);
 };
   
 static const bool Initialized = true;
 static const bool Uninitialized = false;  
 
 bool TransferFuncs::VisitDeclRefExpr(DeclRefExpr* DR) {
-  if (BlockVarDecl* VD = dyn_cast<BlockVarDecl>(DR->getDecl())) {
+  // FIXME: Ted, can this be simplified?
+  VarDecl* VD = dyn_cast<VarDecl>(DR->getDecl());
+  if (VD && VD->isBlockVarDecl()) {
     if (AD.Observer) AD.Observer->ObserveDeclRefExpr(V,AD,DR,VD);
      
     // Pseudo-hack to prevent cascade of warnings.  If an accessed variable
@@ -101,13 +103,15 @@
   else return Initialized;
 }
 
-BlockVarDecl* TransferFuncs::FindBlockVarDecl(Stmt *S) {
+VarDecl* TransferFuncs::FindBlockVarDecl(Stmt *S) {
   for (;;)
     if (ParenExpr* P = dyn_cast<ParenExpr>(S)) {
       S = P->getSubExpr(); continue;
     }
     else if (DeclRefExpr* DR = dyn_cast<DeclRefExpr>(S)) {
-      if (BlockVarDecl* VD = dyn_cast<BlockVarDecl>(DR->getDecl()))
+      // FIXME: Ted, can this be simplified?
+      VarDecl* VD = dyn_cast<VarDecl>(DR->getDecl());
+      if (VD->isBlockVarDecl())
         return VD;
       else
         return NULL;
@@ -116,7 +120,9 @@
 }
 
 bool TransferFuncs::VisitBinaryOperator(BinaryOperator* B) {
-  if (BlockVarDecl* VD = FindBlockVarDecl(B->getLHS()))
+  // FIXME: Ted, can this be simplified?
+  VarDecl* VD = FindBlockVarDecl(B->getLHS());
+  if (VD && VD->isBlockVarDecl())
     if (B->isAssignmentOp()) {
       if (B->getOpcode() == BinaryOperator::Assign)
         return V(VD,AD) = Visit(B->getRHS());
@@ -128,8 +134,9 @@
 }
 
 bool TransferFuncs::VisitDeclStmt(DeclStmt* S) {
-  for (ScopedDecl* D = S->getDecl(); D != NULL; D = D->getNextDeclarator())
-    if (BlockVarDecl* VD = dyn_cast<BlockVarDecl>(D)) {
+  for (ScopedDecl* D = S->getDecl(); D != NULL; D = D->getNextDeclarator()) {
+    VarDecl *VD = dyn_cast<VarDecl>(D);
+    if (VD && VD->isBlockVarDecl()) {
       if (Stmt* I = VD->getInit()) 
         V(VD,AD) = AD.FullUninitTaint ? V(cast<Expr>(I),AD) : Initialized;
       else {
@@ -149,10 +156,10 @@
           V(VD,AD) = Uninitialized;
       }
     }
-      
+  }
   return Uninitialized; // Value is never consumed.
 }
-
+  
 bool TransferFuncs::VisitCallExpr(CallExpr* C) {
   VisitChildren(C);
   return Initialized;
@@ -161,9 +168,9 @@
 bool TransferFuncs::VisitUnaryOperator(UnaryOperator* U) {
   switch (U->getOpcode()) {
     case UnaryOperator::AddrOf:
-      if (BlockVarDecl* VD = FindBlockVarDecl(U->getSubExpr()))
+      VarDecl* VD = FindBlockVarDecl(U->getSubExpr());
+      if (VD && VD->isBlockVarDecl())
         return V(VD,AD) = Initialized;
-      
       break;
     
     case UnaryOperator::SizeOf:
@@ -240,7 +247,7 @@
     
   ASTContext &Ctx;
   Diagnostic &Diags;
-  llvm::SmallPtrSet<BlockVarDecl*,10> AlreadyWarned;
+  llvm::SmallPtrSet<VarDecl*,10> AlreadyWarned;
   
 public:
   UninitializedValuesChecker(ASTContext &ctx, Diagnostic &diags)
@@ -248,7 +255,7 @@
     
   virtual void ObserveDeclRefExpr(UninitializedValues::ValTy& V,
                                   UninitializedValues::AnalysisDataTy& AD,
-                                  DeclRefExpr* DR, BlockVarDecl* VD) {
+                                  DeclRefExpr* DR, VarDecl* VD) {
 
     assert ( AD.isTracked(VD) && "Unknown VarDecl.");
     

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=49748&r1=49747&r2=49748&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Tue Apr 15 17:42:06 2008
@@ -23,8 +23,6 @@
 void CodeGenFunction::EmitDecl(const Decl &D) {
   switch (D.getKind()) {
   default: assert(0 && "Unknown decl kind!");
-  case Decl::FileVar:
-    assert(0 && "Should not see file-scope variables inside a function!");
   case Decl::ParmVar:
     assert(0 && "Parmdecls should not be in declstmts!");
   case Decl::Typedef:   // typedef int X;
@@ -36,8 +34,11 @@
     // None of these decls require codegen support.
     return;
     
-  case Decl::BlockVar:
-    return EmitBlockVarDecl(cast<BlockVarDecl>(D));
+  case Decl::Var:
+    if (cast<VarDecl>(D).isBlockVarDecl())
+      return EmitBlockVarDecl(cast<VarDecl>(D));
+    assert(0 && "Should not see file-scope variables inside a function!");
+  
   case Decl::EnumConstant:
     return EmitEnumConstantDecl(cast<EnumConstantDecl>(D));
   }
@@ -49,7 +50,7 @@
 
 /// EmitBlockVarDecl - This method handles emission of any variable declaration
 /// inside a function, including static vars etc.
-void CodeGenFunction::EmitBlockVarDecl(const BlockVarDecl &D) {
+void CodeGenFunction::EmitBlockVarDecl(const VarDecl &D) {
   switch (D.getStorageClass()) {
   case VarDecl::Static:
     return EmitStaticBlockVarDecl(D);
@@ -65,7 +66,7 @@
   }
 }
 
-void CodeGenFunction::EmitStaticBlockVarDecl(const BlockVarDecl &D) {
+void CodeGenFunction::EmitStaticBlockVarDecl(const VarDecl &D) {
   QualType Ty = D.getType();
   assert(Ty->isConstantSizeType() && "VLAs can't be static");
   
@@ -99,7 +100,7 @@
 /// EmitLocalBlockVarDecl - Emit code and set up an entry in LocalDeclMap for a
 /// variable declaration with auto, register, or no storage class specifier.
 /// These turn into simple stack objects.
-void CodeGenFunction::EmitLocalBlockVarDecl(const BlockVarDecl &D) {
+void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) {
   QualType Ty = D.getType();
 
   llvm::Value *DeclPtr;

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=49748&r1=49747&r2=49748&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Tue Apr 15 17:42:06 2008
@@ -338,20 +338,20 @@
 
 
 LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) {
-  const ValueDecl *D = E->getDecl();
-  if (isa<BlockVarDecl>(D) || isa<ParmVarDecl>(D)) {
-    const VarDecl *VD = cast<VarDecl>(D);
+  const VarDecl *VD = dyn_cast<VarDecl>(E->getDecl());
+  
+  if (VD && (VD->isBlockVarDecl() || isa<ParmVarDecl>(VD))) {
     if (VD->getStorageClass() == VarDecl::Extern)
       return LValue::MakeAddr(CGM.GetAddrOfGlobalVar(VD, false));
     else {
-      llvm::Value *V = LocalDeclMap[D];
+      llvm::Value *V = LocalDeclMap[VD];
       assert(V && "BlockVarDecl not entered in LocalDeclMap?");
       return LValue::MakeAddr(V);
     }
-  } else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
+  } else if (VD && VD->isFileVarDecl()) {
+    return LValue::MakeAddr(CGM.GetAddrOfGlobalVar(VD, false));
+  } else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(E->getDecl())) {
     return LValue::MakeAddr(CGM.GetAddrOfFunctionDecl(FD, false));
-  } else if (const FileVarDecl *FVD = dyn_cast<FileVarDecl>(D)) {
-    return LValue::MakeAddr(CGM.GetAddrOfGlobalVar(FVD, false));
   }
   assert(0 && "Unimp declref");
   //an invalid LValue, but the assert will

Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=49748&r1=49747&r2=49748&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Tue Apr 15 17:42:06 2008
@@ -541,11 +541,13 @@
       ValueDecl *Decl = cast<DeclRefExpr>(E)->getDecl();
       if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(Decl))
         return CGM.GetAddrOfFunctionDecl(FD, false);
-      if (const FileVarDecl* VD = dyn_cast<FileVarDecl>(Decl))
-        return CGM.GetAddrOfGlobalVar(VD, false);
-      if (const BlockVarDecl* BVD = dyn_cast<BlockVarDecl>(Decl)) {
-        assert(CGF && "Can't access static local vars without CGF");
-        return CGF->GetAddrOfStaticLocalVar(BVD);
+      if (const VarDecl* VD = dyn_cast<VarDecl>(Decl)) {
+        if (VD->isFileVarDecl())
+          return CGM.GetAddrOfGlobalVar(VD, false);
+        else if (VD->isBlockVarDecl()) {
+          assert(CGF && "Can't access static local vars without CGF");
+          return CGF->GetAddrOfStaticLocalVar(VD);
+        }
       }
       break;
     }

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=49748&r1=49747&r2=49748&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Tue Apr 15 17:42:06 2008
@@ -42,7 +42,7 @@
 }
 
 llvm::Constant *
-CodeGenFunction::GetAddrOfStaticLocalVar(const BlockVarDecl *BVD) {
+CodeGenFunction::GetAddrOfStaticLocalVar(const VarDecl *BVD) {
   return cast<llvm::Constant>(LocalDeclMap[BVD]);
 }
 

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=49748&r1=49747&r2=49748&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Tue Apr 15 17:42:06 2008
@@ -70,7 +70,7 @@
   class ObjCIvarRefExpr;
   class MemberExpr;
 
-  class BlockVarDecl;
+  class VarDecl;
   class EnumConstantDecl;
   class ParmVarDecl;
   class FieldDecl;
@@ -344,16 +344,16 @@
   const CGRecordLayout *getCGRecordLayout(CodeGenTypes &CGT, QualType RTy);
 
   /// GetAddrOfStaticLocalVar - Return the address of a static local variable.
-  llvm::Constant *GetAddrOfStaticLocalVar(const BlockVarDecl *BVD);
+  llvm::Constant *GetAddrOfStaticLocalVar(const VarDecl *BVD);
   //===--------------------------------------------------------------------===//
   //                            Declaration Emission
   //===--------------------------------------------------------------------===//
   
   void EmitDecl(const Decl &D);
   void EmitEnumConstantDecl(const EnumConstantDecl &D);
-  void EmitBlockVarDecl(const BlockVarDecl &D);
-  void EmitLocalBlockVarDecl(const BlockVarDecl &D);
-  void EmitStaticBlockVarDecl(const BlockVarDecl &D);
+  void EmitBlockVarDecl(const VarDecl &D);
+  void EmitLocalBlockVarDecl(const VarDecl &D);
+  void EmitStaticBlockVarDecl(const VarDecl &D);
   void EmitParmDecl(const ParmVarDecl &D, llvm::Value *Arg);
   
   //===--------------------------------------------------------------------===//

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=49748&r1=49747&r2=49748&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Apr 15 17:42:06 2008
@@ -288,7 +288,7 @@
   return EmitConstantExpr(Expr);
 }
 
-void CodeGenModule::EmitGlobalVar(const FileVarDecl *D) {
+void CodeGenModule::EmitGlobalVar(const VarDecl *D) {
   // If this is just a forward declaration of the variable, don't emit it now,
   // allow it to be emitted lazily on its first use.
   if (D->getStorageClass() == VarDecl::Extern && D->getInit() == 0)
@@ -352,9 +352,10 @@
 
 /// EmitGlobalVarDeclarator - Emit all the global vars attached to the specified
 /// declarator chain.
-void CodeGenModule::EmitGlobalVarDeclarator(const FileVarDecl *D) {
-  for (; D; D = cast_or_null<FileVarDecl>(D->getNextDeclarator()))
-    EmitGlobalVar(D);
+void CodeGenModule::EmitGlobalVarDeclarator(const VarDecl *D) {
+  for (; D; D = cast_or_null<VarDecl>(D->getNextDeclarator()))
+    if (D->isFileVarDecl())
+      EmitGlobalVar(D);
 }
 
 void CodeGenModule::UpdateCompletedType(const TagDecl *TD) {

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=49748&r1=49747&r2=49748&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Tue Apr 15 17:42:06 2008
@@ -37,7 +37,6 @@
   class ValueDecl;
   class VarDecl;
   class TypeDecl;
-  class FileVarDecl;
   struct LangOptions;
   class Diagnostic;
     
@@ -103,8 +102,8 @@
 
   void EmitObjCMethod(const ObjCMethodDecl *OMD);
   void EmitFunction(const FunctionDecl *FD);
-  void EmitGlobalVar(const FileVarDecl *D);
-  void EmitGlobalVarDeclarator(const FileVarDecl *D);
+  void EmitGlobalVar(const VarDecl *D);
+  void EmitGlobalVarDeclarator(const VarDecl *D);
   void UpdateCompletedType(const TagDecl *D);
   llvm::Constant *EmitGlobalInit(const Expr *E);
   llvm::Constant *EmitConstantExpr(const Expr *E, CodeGenFunction *CGF = 0);

Modified: cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ModuleBuilder.cpp?rev=49748&r1=49747&r2=49748&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/ModuleBuilder.cpp (original)
+++ cfe/trunk/lib/CodeGen/ModuleBuilder.cpp Tue Apr 15 17:42:06 2008
@@ -63,8 +63,9 @@
       
       if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
         Builder->EmitFunction(FD);
-      } else if (FileVarDecl *FVD = dyn_cast<FileVarDecl>(D)) {
-        Builder->EmitGlobalVarDeclarator(FVD);
+      } else if (VarDecl *VD = dyn_cast<VarDecl>(D)) {
+        if (VD->isFileVarDecl())
+          Builder->EmitGlobalVarDeclarator(VD);
       } else if (isa<ObjCClassDecl>(D) || isa<ObjCCategoryDecl>(D)) {
         // Forward declaration.  Only used for type checking.
       } else if (ObjCMethodDecl *OMD = dyn_cast<ObjCMethodDecl>(D)){

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=49748&r1=49747&r2=49748&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Apr 15 17:42:06 2008
@@ -372,26 +372,23 @@
     return New;
   }
   // We've verified the types match, now handle "tentative" definitions.
-  FileVarDecl *OldFSDecl = dyn_cast<FileVarDecl>(Old);
-  FileVarDecl *NewFSDecl = dyn_cast<FileVarDecl>(New);
-  
-  if (OldFSDecl && NewFSDecl) {
+  if (Old->isFileVarDecl() && New->isFileVarDecl()) {
     // Handle C "tentative" external object definitions (C99 6.9.2).
     bool OldIsTentative = false;
     bool NewIsTentative = false;
     
-    if (!OldFSDecl->getInit() &&
-        (OldFSDecl->getStorageClass() == VarDecl::None ||
-         OldFSDecl->getStorageClass() == VarDecl::Static))
+    if (!Old->getInit() &&
+        (Old->getStorageClass() == VarDecl::None ||
+         Old->getStorageClass() == VarDecl::Static))
       OldIsTentative = true;
       
     // FIXME: this check doesn't work (since the initializer hasn't been
     // attached yet). This check should be moved to FinalizeDeclaratorGroup.
     // Unfortunately, by the time we get to FinializeDeclaratorGroup, we've 
     // thrown out the old decl.
-    if (!NewFSDecl->getInit() &&
-        (NewFSDecl->getStorageClass() == VarDecl::None ||
-         NewFSDecl->getStorageClass() == VarDecl::Static))
+    if (!New->getInit() &&
+        (New->getStorageClass() == VarDecl::None ||
+         New->getStorageClass() == VarDecl::Static))
       ; // change to NewIsTentative = true; once the code is moved.
     
     if (NewIsTentative || OldIsTentative)
@@ -880,13 +877,11 @@
              R.getAsString());
         InvalidDecl = true;
       }
-      NewVD = FileVarDecl::Create(Context, CurContext, D.getIdentifierLoc(),
-                                  II, R, SC,
-                                  LastDeclarator);
+      NewVD = VarDecl::Create(Context, CurContext, D.getIdentifierLoc(),
+                              II, R, SC, LastDeclarator);
     } else {
-      NewVD = BlockVarDecl::Create(Context, CurContext, D.getIdentifierLoc(),
-                                   II, R, SC,
-                                   LastDeclarator);
+      NewVD = VarDecl::Create(Context, CurContext, D.getIdentifierLoc(),
+                              II, R, SC, LastDeclarator);
     }
     // Handle attributes prior to checking for duplicates in MergeVarDecl
     HandleDeclAttributes(NewVD, D.getDeclSpec().getAttributes(),
@@ -952,23 +947,23 @@
   // Get the decls type and save a reference for later, since
   // CheckInitializerTypes may change it.
   QualType DclT = VDecl->getType(), SavT = DclT;
-  if (BlockVarDecl *BVD = dyn_cast<BlockVarDecl>(VDecl)) {
-    VarDecl::StorageClass SC = BVD->getStorageClass();
+  if (VDecl->isBlockVarDecl()) {
+    VarDecl::StorageClass SC = VDecl->getStorageClass();
     if (SC == VarDecl::Extern) { // C99 6.7.8p5
       Diag(VDecl->getLocation(), diag::err_block_extern_cant_init);
-      BVD->setInvalidDecl();
-    } else if (!BVD->isInvalidDecl()) {
+      VDecl->setInvalidDecl();
+    } else if (!VDecl->isInvalidDecl()) {
       if (CheckInitializerTypes(Init, DclT))
-        BVD->setInvalidDecl();
+        VDecl->setInvalidDecl();
       if (SC == VarDecl::Static) // C99 6.7.8p4.
         CheckForConstantInitializer(Init, DclT);
     }
-  } else if (FileVarDecl *FVD = dyn_cast<FileVarDecl>(VDecl)) {
-    if (FVD->getStorageClass() == VarDecl::Extern)
+  } else if (VDecl->isFileVarDecl()) {
+    if (VDecl->getStorageClass() == VarDecl::Extern)
       Diag(VDecl->getLocation(), diag::warn_extern_init);
-    if (!FVD->isInvalidDecl())
+    if (!VDecl->isInvalidDecl())
       if (CheckInitializerTypes(Init, DclT))
-        FVD->setInvalidDecl();
+        VDecl->setInvalidDecl();
     
     // C99 6.7.8p4. All file scoped initializers need to be constant.
     CheckForConstantInitializer(Init, DclT);
@@ -1012,13 +1007,12 @@
     VarDecl *IDecl = dyn_cast<VarDecl>(ID);
     if (!IDecl)
       continue;
-    FileVarDecl *FVD = dyn_cast<FileVarDecl>(IDecl);
-    BlockVarDecl *BVD = dyn_cast<BlockVarDecl>(IDecl);
     QualType T = IDecl->getType();
     
     // C99 6.7.5.2p2: If an identifier is declared to be an object with 
     // static storage duration, it shall not have a variable length array.
-    if ((FVD || BVD) && IDecl->getStorageClass() == VarDecl::Static) {
+    if ((IDecl->isFileVarDecl() || IDecl->isBlockVarDecl()) && 
+        IDecl->getStorageClass() == VarDecl::Static) {
       if (T->getAsVariableArrayType()) {
         Diag(IDecl->getLocation(), diag::err_typecheck_illegal_vla);
         IDecl->setInvalidDecl();
@@ -1026,7 +1020,8 @@
     }
     // Block scope. C99 6.7p7: If an identifier for an object is declared with
     // no linkage (C99 6.2.2p6), the type for the object shall be complete...
-    if (BVD && IDecl->getStorageClass() != VarDecl::Extern) {
+    if (IDecl->isBlockVarDecl() && 
+        IDecl->getStorageClass() != VarDecl::Extern) {
       if (T->isIncompleteType() && !IDecl->isInvalidDecl()) {
         Diag(IDecl->getLocation(), diag::err_typecheck_decl_incomplete_type,
              T.getAsString());
@@ -1038,8 +1033,9 @@
     // storage-class specifier or with the storage-class specifier "static",
     // constitutes a tentative definition. Note: A tentative definition with
     // external linkage is valid (C99 6.2.2p5).
-    if (FVD && !FVD->getInit() && (FVD->getStorageClass() == VarDecl::Static || 
-                                   FVD->getStorageClass() == VarDecl::None)) {
+    if (IDecl && !IDecl->getInit() && 
+        (IDecl->getStorageClass() == VarDecl::Static || 
+         IDecl->getStorageClass() == VarDecl::None)) {
       if (T->isIncompleteArrayType()) {
         // C99 6.9.2 (p2, p5): Implicit initialization causes an incomplete
         // array to be completed. Don't issue a diagnostic.

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=49748&r1=49747&r2=49748&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Apr 15 17:42:06 2008
@@ -74,13 +74,14 @@
       return S->Diag(DRE->getSourceRange().getBegin(), 
                      diag::err_param_default_argument_references_param,
                      Param->getName(), DefaultArg->getSourceRange());
-    } else if (BlockVarDecl *BlockVar = dyn_cast<BlockVarDecl>(Decl)) {
+    } else if (VarDecl *VDecl = dyn_cast<VarDecl>(Decl)) {
       // C++ [dcl.fct.default]p7
       //   Local variables shall not be used in default argument
       //   expressions.
-      return S->Diag(DRE->getSourceRange().getBegin(), 
-                     diag::err_param_default_argument_references_local,
-                     BlockVar->getName(), DefaultArg->getSourceRange());
+      if (VDecl->isBlockVarDecl())
+        return S->Diag(DRE->getSourceRange().getBegin(), 
+                       diag::err_param_default_argument_references_local,
+                       VDecl->getName(), DefaultArg->getSourceRange());
     }
 
     // FIXME: when Clang has support for member functions, "this"

Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=49748&r1=49747&r2=49748&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Tue Apr 15 17:42:06 2008
@@ -521,10 +521,10 @@
     // C99 6.8.5p3: The declaration part of a 'for' statement shall only declare
     // identifiers for objects having storage class 'auto' or 'register'.
     for (ScopedDecl *D = DS->getDecl(); D; D = D->getNextDeclarator()) {
-      BlockVarDecl *BVD = dyn_cast<BlockVarDecl>(D);
-      if (BVD && !BVD->hasLocalStorage())
-        BVD = 0;
-      if (BVD == 0)
+      VarDecl *VD = dyn_cast<VarDecl>(D);
+      if (VD && VD->isBlockVarDecl() && !VD->hasLocalStorage())
+        VD = 0;
+      if (VD == 0)
         Diag(dyn_cast<ScopedDecl>(D)->getLocation(), 
              diag::err_non_variable_decl_in_for);
       // FIXME: mark decl erroneous!
@@ -556,13 +556,12 @@
       // C99 6.8.5p3: The declaration part of a 'for' statement shall only declare
       // identifiers for objects having storage class 'auto' or 'register'.
       ScopedDecl *D = DS->getDecl();
-      BlockVarDecl *BVD = cast<BlockVarDecl>(D);
-      if (!BVD->hasLocalStorage())
-        return Diag(BVD->getLocation(), diag::err_non_variable_decl_in_for);
+      VarDecl *VD = cast<VarDecl>(D);
+      if (VD->isBlockVarDecl() && !VD->hasLocalStorage())
+        return Diag(VD->getLocation(), diag::err_non_variable_decl_in_for);
       if (D->getNextDeclarator())
         return Diag(D->getLocation(), diag::err_toomany_element_decls);
-    }
-    else
+    } else
       FirstType = static_cast<Expr*>(first)->getType();
     if (!isObjCObjectPointerType(FirstType))
         Diag(ForLoc, diag::err_selector_element_type,





More information about the cfe-commits mailing list