]> granicus.if.org Git - clang/commitdiff
-Changes to TagDecl:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 9 Jun 2008 23:19:58 +0000 (23:19 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 9 Jun 2008 23:19:58 +0000 (23:19 +0000)
  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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52160 91177308-0d34-0410-b5e6-96231b3b80d8

12 files changed:
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

index 694456d670cf78752ba0e643d11cd2d30e424e19..fe71e54a86b784d0494375c1f6eda5433610c88c 100644 (file)
@@ -836,7 +836,7 @@ Stmt *RewriteObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV,
       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 @@ Stmt *RewriteObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV,
       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::SynthMsgSendFunctionDecl() {
 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 @@ void RewriteObjC::SynthMsgSendSuperStretFunctionDecl() {
   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 @@ ObjCInterfaceDecl *RewriteObjC::isSuperReceiver(Expr *recExpr) {
 // 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::getSuperStructType() {
 
 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 @@ void RewriteObjC::RewriteImplementations(std::string &Result) {
 }
 
 
+
+
index c404e4ff9907128be96d6b3485ca64df120c04b1..3e865f94c9f06af45419d222506092847e96d724 100644 (file)
@@ -658,6 +658,15 @@ protected:
 
 /// 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 @@ public:
   }
   
   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 @@ protected:
   }
 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);
   
index 4c152f5adf26fa5af958b634252fe37581418ebb..10ff6feec8be79889094d914415f6172a36181e3 100644 (file)
@@ -49,7 +49,7 @@ protected:
     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);
   
index d8e2c06fc0311895939243cf55ab6ab3bdbeedc7..11ca78a479860193bee6ba6974ca3314cadb595d 100644 (file)
@@ -70,12 +70,12 @@ void ASTContext::PrintStats() const {
       ++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 @@ const ASTRecordLayout &ASTContext::getASTRecordLayout(const RecordDecl *D) {
 
   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 @@ int ASTContext::getIntegerTypeOrder(QualType LHS, QualType RHS) {
 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];
   
index b5dba1029b880da381407952dec101d129d01d1b..47334f53cc8314b86cab14d760222cdee8137655 100644 (file)
@@ -101,10 +101,17 @@ EnumDecl *EnumDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L,
   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);
 }
 
index c319191bae6a30cb6da57f83f95913baddb860ab..b62ca58d72d3a93821fa287862fd3e2fbe0781b7 100644 (file)
@@ -26,9 +26,16 @@ CXXFieldDecl *CXXFieldDecl::Create(ASTContext &C, CXXRecordDecl *RD,
   return new (Mem) CXXFieldDecl(RD, L, Id, T, BW);\r
 }\r
 \r
-CXXRecordDecl *CXXRecordDecl::Create(ASTContext &C, Kind DK, DeclContext *DC,\r
+CXXRecordDecl *CXXRecordDecl::Create(ASTContext &C, TagKind TK, DeclContext *DC,\r
                                      SourceLocation L, IdentifierInfo *Id,\r
                                      ScopedDecl *PrevDecl) {\r
+  Kind DK;\r
+  switch (TK) {\r
+  case TK_enum:   assert(0 && "Enum TagKind passed for Record!");\r
+  case TK_struct: DK = Struct; break;\r
+  case TK_union:  DK = Union;  break;\r
+  case TK_class:  DK = Class;  break;\r
+  }\r
   void *Mem = C.getAllocator().Allocate<CXXRecordDecl>();\r
   return new (Mem) CXXRecordDecl(DK, DC, L, Id, PrevDecl);\r
 }\r
index e561a1074cea650f304e4aee310c181d73ede948..7e09bb1ae37d6d1bf23d3317f841f94c4d8b27ab 100644 (file)
@@ -63,8 +63,7 @@ bool Type::isDerivedType() const {
     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::isDerivedType() const {
 
 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::getAsRecordType() const {
 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::getAsStructureType() const {
 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 @@ bool Type::isIntegerType() const {
     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 @@ bool Type::isIntegralType() const {
     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::isIntegralType() const {
 
 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 @@ bool Type::isRealType() const {
     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 @@ bool Type::isScalarType() const {
   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::isScalarType() const {
 
 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;
   }
index bab5a21a6ad4f036e137d34b59aa0362ae39c7ca..2f8784f7d5c4eeb68cf6012601daf371f2ad0933 100644 (file)
@@ -375,7 +375,7 @@ const llvm::Type *CodeGenTypes::ConvertTagDeclType(const TagDecl *TD) {
   
   // 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 *CodeGenTypes::ConvertTagDeclType(const TagDecl *TD) {
   
   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 @@ const llvm::Type *CodeGenTypes::ConvertTagDeclType(const TagDecl *TD) {
                                              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) {
index 980717f15e2efe3bea58c0f5c1a49fbb70b8ba5a..3861d04bf0a8e8d8c408b58bcd39108e8d134ba9 100644 (file)
@@ -57,7 +57,7 @@ void Sema::ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) {
   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 @@ Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer)
     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 @@ Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer)
     
     // 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(),
index 1b1e636a76109bb5a2a7d24297f22be4718d8a64..ba005b2c6069325fb4944a8a9ef2660da86edb7a 100644 (file)
@@ -1637,13 +1637,13 @@ Sema::DeclTy *Sema::ActOnTag(Scope *S, unsigned TagType, TagKind TK,
   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 @@ Sema::DeclTy *Sema::ActOnTag(Scope *S, unsigned TagType, TagKind TK,
           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 @@ Sema::DeclTy *Sema::ActOnTag(Scope *S, unsigned TagType, TagKind TK,
   
   // 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 @@ void Sema::ActOnFields(Scope* S,
         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 @@ void Sema::ActOnFields(Scope* S,
     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
index a7135ea4cfdd2078ab6ba8f73f854161e1f29731..45affcab16b91c1753c1fb03a9897eb3bc1d219b 100644 (file)
@@ -285,7 +285,7 @@ void Sema::ActOnBaseSpecifier(DeclTy *classdecl, SourceRange SpecifierRange,
 
   // 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();
index e2377e18bae300b8f70d21dbe4b535f04aaec0cc..0078cc149cd05f6b7ab927c24a5d93c15746e50f 100644 (file)
@@ -42,7 +42,7 @@ int InitListChecker::numStructUnionElements(QualType DeclType) {
   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();
 }