aboutsummaryrefslogtreecommitdiff
path: root/lib/AST
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2008-06-09 23:19:58 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2008-06-09 23:19:58 +0000
commit39ba4aeca296b1c9f04bde7d9d3cbbf129f1abd3 (patch)
tree0bd41bdbfdd41514deb4fbd92ddf3bade3030d8b /lib/AST
parentd3bb44f0f1a83cb208d3e61ee80afe6a4d20d2d8 (diff)
-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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52160 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST')
-rw-r--r--lib/AST/ASTContext.cpp14
-rw-r--r--lib/AST/Decl.cpp9
-rw-r--r--lib/AST/DeclCXX.cpp9
-rw-r--r--lib/AST/Type.cpp29
4 files changed, 37 insertions, 24 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index d8e2c06fc0..11ca78a479 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -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];
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index b5dba1029b..47334f53cc 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -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);
}
diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp
index c319191bae..b62ca58d72 100644
--- a/lib/AST/DeclCXX.cpp
+++ b/lib/AST/DeclCXX.cpp
@@ -26,9 +26,16 @@ CXXFieldDecl *CXXFieldDecl::Create(ASTContext &C, CXXRecordDecl *RD,
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);
}
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp
index e561a1074c..7e09bb1ae3 100644
--- a/lib/AST/Type.cpp
+++ b/lib/AST/Type.cpp
@@ -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;
}