[cfe-commits] r52160 - in /cfe/trunk: Driver/RewriteObjC.cpp include/clang/AST/Decl.h include/clang/AST/DeclCXX.h lib/AST/ASTContext.cpp lib/AST/Decl.cpp lib/AST/DeclCXX.cpp lib/AST/Type.cpp lib/CodeGen/CodeGenTypes.cpp lib/Sema/Sema.cpp lib/Sema/SemaDecl.cpp lib/Sema/SemaDeclCXX.cpp lib/Sema/SemaInit.cpp

Argiris Kirtzidis akyrtzi at gmail.com
Mon Jun 9 16:20:00 PDT 2008


Author: akirtzidis
Date: Mon Jun  9 18:19:58 2008
New Revision: 52160

URL: http://llvm.org/viewvc/llvm-project?rev=52160&view=rev
Log:
-Changes to TagDecl:
  Added TagKind enum.
  Added getTagKind() method.
  Added convenience methods: isEnum(), isStruct(), isUnion(), isClass().
-RecordDecl/CXXRecordDecl::Create() accept a TagKind enum instead of a DeclKind one.

Modified:
    cfe/trunk/Driver/RewriteObjC.cpp
    cfe/trunk/include/clang/AST/Decl.h
    cfe/trunk/include/clang/AST/DeclCXX.h
    cfe/trunk/lib/AST/ASTContext.cpp
    cfe/trunk/lib/AST/Decl.cpp
    cfe/trunk/lib/AST/DeclCXX.cpp
    cfe/trunk/lib/AST/Type.cpp
    cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
    cfe/trunk/lib/Sema/Sema.cpp
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
    cfe/trunk/lib/Sema/SemaInit.cpp

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

==============================================================================
--- cfe/trunk/Driver/RewriteObjC.cpp (original)
+++ cfe/trunk/Driver/RewriteObjC.cpp Mon Jun  9 18:19:58 2008
@@ -836,7 +836,7 @@
       std::string RecName = clsDeclared->getIdentifier()->getName();
       RecName += "_IMPL";
       IdentifierInfo *II = &Context->Idents.get(RecName.c_str());
-      RecordDecl *RD = RecordDecl::Create(*Context, Decl::Struct, TUDecl,
+      RecordDecl *RD = RecordDecl::Create(*Context, TagDecl::TK_struct, TUDecl,
                                           SourceLocation(), II, 0);
       assert(RD && "RewriteObjCIvarRefExpr(): Can't find RecordDecl");
       QualType castT = Context->getPointerType(Context->getTagDeclType(RD));
@@ -877,7 +877,7 @@
       std::string RecName = clsDeclared->getIdentifier()->getName();
       RecName += "_IMPL";
       IdentifierInfo *II = &Context->Idents.get(RecName.c_str());
-      RecordDecl *RD = RecordDecl::Create(*Context, Decl::Struct, TUDecl,
+      RecordDecl *RD = RecordDecl::Create(*Context, TagDecl::TK_struct, TUDecl,
                                           SourceLocation(), II, 0);
       assert(RD && "RewriteObjCIvarRefExpr(): Can't find RecordDecl");
       QualType castT = Context->getPointerType(Context->getTagDeclType(RD));
@@ -1692,7 +1692,7 @@
 void RewriteObjC::SynthMsgSendSuperFunctionDecl() {
   IdentifierInfo *msgSendIdent = &Context->Idents.get("objc_msgSendSuper");
   llvm::SmallVector<QualType, 16> ArgTys;
-  RecordDecl *RD = RecordDecl::Create(*Context, Decl::Struct, TUDecl,
+  RecordDecl *RD = RecordDecl::Create(*Context, TagDecl::TK_struct, TUDecl,
                                       SourceLocation(),
                                       &Context->Idents.get("objc_super"), 0);
   QualType argT = Context->getPointerType(Context->getTagDeclType(RD));
@@ -1735,7 +1735,7 @@
   IdentifierInfo *msgSendIdent = 
     &Context->Idents.get("objc_msgSendSuper_stret");
   llvm::SmallVector<QualType, 16> ArgTys;
-  RecordDecl *RD = RecordDecl::Create(*Context, Decl::Struct, TUDecl,
+  RecordDecl *RD = RecordDecl::Create(*Context, TagDecl::TK_struct, TUDecl,
                                       SourceLocation(),
                                       &Context->Idents.get("objc_super"), 0);
   QualType argT = Context->getPointerType(Context->getTagDeclType(RD));
@@ -1878,7 +1878,7 @@
 // struct objc_super { struct objc_object *receiver; struct objc_class *super; };
 QualType RewriteObjC::getSuperStructType() {
   if (!SuperStructDecl) {
-    SuperStructDecl = RecordDecl::Create(*Context, Decl::Struct, TUDecl,
+    SuperStructDecl = RecordDecl::Create(*Context, TagDecl::TK_struct, TUDecl,
                                          SourceLocation(), 
                                          &Context->Idents.get("objc_super"), 0);
     QualType FieldTypes[2];
@@ -1901,7 +1901,7 @@
 
 QualType RewriteObjC::getConstantStringStructType() {
   if (!ConstantStringDecl) {
-    ConstantStringDecl = RecordDecl::Create(*Context, Decl::Struct, TUDecl,
+    ConstantStringDecl = RecordDecl::Create(*Context, TagDecl::TK_struct, TUDecl,
                                             SourceLocation(), 
                          &Context->Idents.get("__NSConstantStringImpl"), 0);
     QualType FieldTypes[4];
@@ -3108,3 +3108,5 @@
 }
 
 
+
+

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

==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Mon Jun  9 18:19:58 2008
@@ -658,6 +658,15 @@
 
 /// TagDecl - Represents the declaration of a struct/union/class/enum.
 class TagDecl : public TypeDecl {
+public:
+  enum TagKind {
+    TK_struct,
+    TK_union,
+    TK_class,
+    TK_enum
+  };
+
+private:
   /// IsDefinition - True if this is a definition ("struct foo {};"), false if
   /// it is a declaration ("struct foo;").
   bool IsDefinition : 1;
@@ -675,14 +684,29 @@
   }
   
   const char *getKindName() const {
+    switch (getTagKind()) {
+    default: assert(0 && "Unknown TagKind!");
+    case TK_struct: return "struct";
+    case TK_union:  return "union";
+    case TK_class:  return "class";
+    case TK_enum:   return "enum";
+    }
+  }
+
+  TagKind getTagKind() const {
     switch (getKind()) {
     default: assert(0 && "Unknown TagDecl!");
-    case Struct: return "struct";
-    case Union:  return "union";
-    case Class:  return "class";
-    case Enum:   return "enum";
+    case Struct: case CXXStruct: return TK_struct;
+    case Union:  case CXXUnion:  return TK_union;
+    case Class:  case CXXClass:  return TK_class;
+    case Enum:                   return TK_enum;
     }
   }
+
+  bool isStruct() const { return getKind() == Struct || getKind() == CXXStruct;}
+  bool isClass()  const { return getKind() == Class  || getKind() == CXXClass; }
+  bool isUnion()  const { return getKind() == Union  || getKind() == CXXUnion; }
+  bool isEnum()   const { return getKind() == Enum; }
   
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Decl *D) {
@@ -777,7 +801,7 @@
   }
 public:
   
-  static RecordDecl *Create(ASTContext &C, Kind DK, DeclContext *DC,
+  static RecordDecl *Create(ASTContext &C, TagKind TK, DeclContext *DC,
                             SourceLocation L, IdentifierInfo *Id,
                             ScopedDecl *PrevDecl);
   

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

==============================================================================
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Mon Jun  9 18:19:58 2008
@@ -49,7 +49,7 @@
     assert(classof(static_cast<Decl*>(this)) && "Invalid Kind!");
   }
 public:
-  static CXXRecordDecl *Create(ASTContext &C, Kind DK, DeclContext *DC,
+  static CXXRecordDecl *Create(ASTContext &C, TagKind TK, DeclContext *DC,
                             SourceLocation L, IdentifierInfo *Id,
                             ScopedDecl *PrevDecl);
   

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

==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Mon Jun  9 18:19:58 2008
@@ -70,12 +70,12 @@
       ++NumTypeName;
     else if (TagType *TT = dyn_cast<TagType>(T)) {
       ++NumTagged;
-      switch (TT->getDecl()->getKind()) {
+      switch (TT->getDecl()->getTagKind()) {
       default: assert(0 && "Unknown tagged type!");
-      case Decl::Struct: ++NumTagStruct; break;
-      case Decl::Union:  ++NumTagUnion; break;
-      case Decl::Class:  ++NumTagClass; break; 
-      case Decl::Enum:   ++NumTagEnum; break;
+      case TagDecl::TK_struct: ++NumTagStruct; break;
+      case TagDecl::TK_union:  ++NumTagUnion; break;
+      case TagDecl::TK_class:  ++NumTagClass; break; 
+      case TagDecl::TK_enum:   ++NumTagEnum; break;
       }
     } else if (isa<ObjCInterfaceType>(T))
       ++NumObjCInterfaces;
@@ -458,7 +458,7 @@
 
   NewEntry->InitializeLayout(D->getNumMembers());
   bool StructIsPacked = D->getAttr<PackedAttr>();
-  bool IsUnion = (D->getKind() == Decl::Union);
+  bool IsUnion = D->isUnion();
 
   if (const AlignedAttr *AA = D->getAttr<AlignedAttr>())
     NewEntry->SetAlignment(std::max(NewEntry->getAlignment(), 
@@ -1214,7 +1214,7 @@
 QualType ASTContext::getCFConstantStringType() {
   if (!CFConstantStringTypeDecl) {
     CFConstantStringTypeDecl = 
-      RecordDecl::Create(*this, Decl::Struct, TUDecl, SourceLocation(), 
+      RecordDecl::Create(*this, TagDecl::TK_struct, TUDecl, SourceLocation(), 
                          &Idents.get("NSConstantString"), 0);
     QualType FieldTypes[4];
   

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

==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Mon Jun  9 18:19:58 2008
@@ -101,10 +101,17 @@
   return new (Mem) EnumDecl(DC, L, Id, PrevDecl);
 }
 
-RecordDecl *RecordDecl::Create(ASTContext &C, Kind DK, DeclContext *DC,
+RecordDecl *RecordDecl::Create(ASTContext &C, TagKind TK, DeclContext *DC,
                                SourceLocation L, IdentifierInfo *Id,
                                ScopedDecl *PrevDecl) {
   void *Mem = C.getAllocator().Allocate<RecordDecl>();
+  Kind DK;
+  switch (TK) {
+  case TK_enum:   assert(0 && "Enum TagKind passed for Record!");
+  case TK_struct: DK = Struct; break;
+  case TK_union:  DK = Union;  break;
+  case TK_class:  DK = Class;  break;
+  }
   return new (Mem) RecordDecl(DK, DC, L, Id, PrevDecl);
 }
 

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

==============================================================================
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Mon Jun  9 18:19:58 2008
@@ -26,9 +26,16 @@
   return new (Mem) CXXFieldDecl(RD, L, Id, T, BW);
 }
 
-CXXRecordDecl *CXXRecordDecl::Create(ASTContext &C, Kind DK, DeclContext *DC,
+CXXRecordDecl *CXXRecordDecl::Create(ASTContext &C, TagKind TK, DeclContext *DC,
                                      SourceLocation L, IdentifierInfo *Id,
                                      ScopedDecl *PrevDecl) {
+  Kind DK;
+  switch (TK) {
+  case TK_enum:   assert(0 && "Enum TagKind passed for Record!");
+  case TK_struct: DK = Struct; break;
+  case TK_union:  DK = Union;  break;
+  case TK_class:  DK = Class;  break;
+  }
   void *Mem = C.getAllocator().Allocate<CXXRecordDecl>();
   return new (Mem) CXXRecordDecl(DK, DC, L, Id, PrevDecl);
 }

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

==============================================================================
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Mon Jun  9 18:19:58 2008
@@ -63,8 +63,7 @@
     return true;
   case Tagged: {
     const TagType *TT = cast<TagType>(CanonicalType);
-    const Decl::Kind Kind = TT->getDecl()->getKind();
-    return Kind == Decl::Struct || Kind == Decl::Union;
+    return !TT->getDecl()->isEnum();
   }
   default:
     return false;
@@ -73,19 +72,19 @@
 
 bool Type::isClassType() const {
   if (const RecordType *RT = dyn_cast<RecordType>(CanonicalType))
-    if (RT->getDecl()->getKind() == Decl::Class)
+    if (RT->getDecl()->isClass())
       return true;
   return false;
 }
 bool Type::isStructureType() const {
   if (const RecordType *RT = dyn_cast<RecordType>(CanonicalType))
-    if (RT->getDecl()->getKind() == Decl::Struct)
+    if (RT->getDecl()->isStruct())
       return true;
   return false;
 }
 bool Type::isUnionType() const {
   if (const RecordType *RT = dyn_cast<RecordType>(CanonicalType))
-    if (RT->getDecl()->getKind() == Decl::Union)
+    if (RT->getDecl()->isUnion())
       return true;
   return false;
 }
@@ -349,13 +348,13 @@
 const RecordType *Type::getAsStructureType() const {
   // If this is directly a structure type, return it.
   if (const RecordType *RT = dyn_cast<RecordType>(this)) {
-    if (RT->getDecl()->getKind() == Decl::Struct)
+    if (RT->getDecl()->isStruct())
       return RT;
   }
 
   // If the canonical form of this type isn't the right kind, reject it.
   if (const RecordType *RT = dyn_cast<RecordType>(CanonicalType)) {
-    if (RT->getDecl()->getKind() != Decl::Struct)
+    if (!RT->getDecl()->isStruct())
       return 0;
     
     // If this is a typedef for a structure type, strip the typedef off without
@@ -371,13 +370,13 @@
 const RecordType *Type::getAsUnionType() const { 
   // If this is directly a union type, return it.
   if (const RecordType *RT = dyn_cast<RecordType>(this)) {
-    if (RT->getDecl()->getKind() == Decl::Union)
+    if (RT->getDecl()->isUnion())
       return RT;
   }
     
   // If the canonical form of this type isn't the right kind, reject it.
   if (const RecordType *RT = dyn_cast<RecordType>(CanonicalType)) {
-    if (RT->getDecl()->getKind() != Decl::Union)
+    if (!RT->getDecl()->isUnion())
       return 0;
 
     // If this is a typedef for a union type, strip the typedef off without
@@ -470,7 +469,7 @@
     return BT->getKind() >= BuiltinType::Bool &&
            BT->getKind() <= BuiltinType::LongLong;
   if (const TagType *TT = dyn_cast<TagType>(CanonicalType))
-    if (TT->getDecl()->getKind() == Decl::Enum)
+    if (TT->getDecl()->isEnum())
       return true;
   if (const VectorType *VT = dyn_cast<VectorType>(CanonicalType))
     return VT->getElementType()->isIntegerType();
@@ -484,7 +483,7 @@
     return BT->getKind() >= BuiltinType::Bool &&
     BT->getKind() <= BuiltinType::LongLong;
   if (const TagType *TT = dyn_cast<TagType>(CanonicalType))
-    if (TT->getDecl()->getKind() == Decl::Enum)
+    if (TT->getDecl()->isEnum())
       return true;
   if (const ASQualType *ASQT = dyn_cast<ASQualType>(CanonicalType))
     return ASQT->getBaseType()->isIntegralType();
@@ -493,7 +492,7 @@
 
 bool Type::isEnumeralType() const {
   if (const TagType *TT = dyn_cast<TagType>(CanonicalType))
-    return TT->getDecl()->getKind() == Decl::Enum;
+    return TT->getDecl()->isEnum();
   if (const ASQualType *ASQT = dyn_cast<ASQualType>(CanonicalType))
     return ASQT->getBaseType()->isEnumeralType();
   return false;
@@ -587,7 +586,7 @@
     return BT->getKind() >= BuiltinType::Bool &&
            BT->getKind() <= BuiltinType::LongDouble;
   if (const TagType *TT = dyn_cast<TagType>(CanonicalType))
-    return TT->getDecl()->getKind() == Decl::Enum;
+    return TT->getDecl()->isEnum();
   if (const VectorType *VT = dyn_cast<VectorType>(CanonicalType))
     return VT->getElementType()->isRealType();
   if (const ASQualType *ASQT = dyn_cast<ASQualType>(CanonicalType))
@@ -611,7 +610,7 @@
   if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
     return BT->getKind() != BuiltinType::Void;
   if (const TagType *TT = dyn_cast<TagType>(CanonicalType)) {
-    if (TT->getDecl()->getKind() == Decl::Enum)
+    if (TT->getDecl()->isEnum())
       return true;
     return false;
   }
@@ -623,7 +622,7 @@
 
 bool Type::isAggregateType() const {
   if (const TagType *TT = dyn_cast<TagType>(CanonicalType)) {
-    if (TT->getDecl()->getKind() == Decl::Struct)
+    if (TT->getDecl()->isStruct())
       return true;
     return false;
   }

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

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenTypes.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTypes.cpp Mon Jun  9 18:19:58 2008
@@ -375,7 +375,7 @@
   
   // Okay, this is a definition of a type.  Compile the implementation now.
   
-  if (TD->getKind() == Decl::Enum) {
+  if (TD->isEnum()) {
     // Don't bother storing enums in TagDeclTypes.
     return ConvertTypeRecursive(cast<EnumDecl>(TD)->getIntegerType());
   }
@@ -391,7 +391,7 @@
   
   const llvm::Type *ResultType;
   const RecordDecl *RD = cast<const RecordDecl>(TD);
-  if (TD->getKind() == Decl::Struct || TD->getKind() == Decl::Class) {
+  if (TD->isStruct() || TD->isClass()) {
     // Layout fields.
     RecordOrganizer RO(*this, *RD);
     
@@ -402,7 +402,7 @@
                                              RO.getPaddingFields());
     ResultType = RO.getLLVMType();
     
-  } else if (TD->getKind() == Decl::Union) {
+  } else if (TD->isUnion()) {
     // Just use the largest element of the union, breaking ties with the
     // highest aligned member.
     if (RD->getNumMembers() != 0) {

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

==============================================================================
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Mon Jun  9 18:19:58 2008
@@ -57,7 +57,7 @@
   PushOnScopeChains(IDecl, TUScope);
   
   // Synthesize "typedef struct objc_selector *SEL;"
-  RecordDecl *SelTag = RecordDecl::Create(Context, Decl::Struct, CurContext,
+  RecordDecl *SelTag = RecordDecl::Create(Context, TagDecl::TK_struct, CurContext,
                                           SourceLocation(), 
                                           &Context.Idents.get("objc_selector"),
                                           0);
@@ -98,7 +98,7 @@
     TranslationUnitDecl *TUDecl = Context.getTranslationUnitDecl();
 
     // Synthesize "typedef struct objc_class *Class;"
-    RecordDecl *ClassTag = RecordDecl::Create(Context, Decl::Struct,
+    RecordDecl *ClassTag = RecordDecl::Create(Context, TagDecl::TK_struct,
                                               TUDecl,
                                               SourceLocation(),
                                               &IT.get("objc_class"), 0);
@@ -117,7 +117,7 @@
     
     // Synthesize "typedef struct objc_object { Class isa; } *id;"
     RecordDecl *ObjectTag = 
-      RecordDecl::Create(Context, Decl::Struct, TUDecl,
+      RecordDecl::Create(Context, TagDecl::TK_struct, TUDecl,
                          SourceLocation(),
                          &IT.get("objc_object"), 0);
     FieldDecl *IsaDecl = FieldDecl::Create(Context, SourceLocation(),

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Jun  9 18:19:58 2008
@@ -1637,13 +1637,13 @@
   assert((Name != 0 || TK == TK_Definition) &&
          "Nameless record must be a definition!");
   
-  Decl::Kind Kind;
+  TagDecl::TagKind Kind;
   switch (TagType) {
   default: assert(0 && "Unknown tag type!");
-  case DeclSpec::TST_struct: Kind = Decl::Struct; break;
-  case DeclSpec::TST_union:  Kind = Decl::Union; break;
-  case DeclSpec::TST_class:  Kind = Decl::Class; break;
-  case DeclSpec::TST_enum:   Kind = Decl::Enum; break;
+  case DeclSpec::TST_struct: Kind = TagDecl::TK_struct; break;
+  case DeclSpec::TST_union:  Kind = TagDecl::TK_union; break;
+  case DeclSpec::TST_class:  Kind = TagDecl::TK_class; break;
+  case DeclSpec::TST_enum:   Kind = TagDecl::TK_enum; break;
   }
   
   // If this is a named struct, check to see if there was a previous forward
@@ -1662,7 +1662,7 @@
           IdResolver.isDeclInScope(PrevDecl, CurContext, S)) {
         // Make sure that this wasn't declared as an enum and now used as a struct
         // or something similar.
-        if (PrevDecl->getKind() != Kind) {
+        if (PrevTagDecl->getTagKind() != Kind) {
           Diag(KWLoc, diag::err_use_with_wrong_tag, Name->getName());
           Diag(PrevDecl->getLocation(), diag::err_previous_use);
         }
@@ -1705,22 +1705,18 @@
   
   // Otherwise, if this is the first time we've seen this tag, create the decl.
   TagDecl *New;
-  switch (Kind) {
-  default: assert(0 && "Unknown tag kind!");
-  case Decl::Enum:
+  if (Kind == TagDecl::TK_enum) {
     // FIXME: Tag decls should be chained to any simultaneous vardecls, e.g.:
     // enum X { A, B, C } D;    D should chain to X.
     New = EnumDecl::Create(Context, CurContext, Loc, Name, 0);
     // If this is an undefined enum, warn.
     if (TK != TK_Definition) Diag(Loc, diag::ext_forward_ref_enum);
-    break;
-  case Decl::Union:
-  case Decl::Struct:
-  case Decl::Class:
+  } else {
+    // struct/union/class
+
     // FIXME: Tag decls should be chained to any simultaneous vardecls, e.g.:
     // struct X { int A; } D;    D should chain to X.
     New = RecordDecl::Create(Context, Kind, CurContext, Loc, Name, 0);
-    break;
   }    
   
   // If this has an identifier, add it to the scope stack.
@@ -1959,7 +1955,7 @@
         continue;
       }
       if (i != NumFields-1 ||                   // ... that the last member ...
-          Record->getKind() != Decl::Struct ||  // ... of a structure ...
+          !Record->isStruct() ||  // ... of a structure ...
           !FDTy->isArrayType()) {         //... may have incomplete array type.
         Diag(FD->getLocation(), diag::err_field_incomplete, FD->getName());
         FD->setInvalidDecl();
@@ -1982,7 +1978,7 @@
     if (const RecordType *FDTTy = FDTy->getAsRecordType()) {
       if (FDTTy->getDecl()->hasFlexibleArrayMember()) {
         // If this is a member of a union, then entire union becomes "flexible".
-        if (Record && Record->getKind() == Decl::Union) {
+        if (Record && Record->isUnion()) {
           Record->setHasFlexibleArrayMember(true);
         } else {
           // If this is a struct/class and this is not the last element, reject

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Jun  9 18:19:58 2008
@@ -285,7 +285,7 @@
 
   // C++ [class.union]p1:
   //   A union shall not have base classes.
-  if (Decl->getKind() == Decl::Union) {
+  if (Decl->isUnion()) {
     Diag(Decl->getLocation(), diag::err_base_clause_on_union,
          SpecifierRange);
     Decl->setInvalidDecl();

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Mon Jun  9 18:19:58 2008
@@ -42,7 +42,7 @@
   for (int i = 0; i < structDecl->getNumMembers(); i++)
     if (structDecl->getMember(i)->getIdentifier())
       ++InitializableMembers;
-  if (structDecl->getKind() == Decl::Union)
+  if (structDecl->isUnion())
     return std::min(InitializableMembers, 1);
   return InitializableMembers - structDecl->hasFlexibleArrayMember();
 }





More information about the cfe-commits mailing list