aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbramo Bagnara <abramo.bagnara@gmail.com>2010-05-11 21:36:43 +0000
committerAbramo Bagnara <abramo.bagnara@gmail.com>2010-05-11 21:36:43 +0000
commit465d41b92b2c862f3062c412a0538db65c6a2661 (patch)
tree0743a1451f3715b8acabca167d0a0bcc357550bd
parent380c2139959d8608782292984b457640a143a70d (diff)
Merged Elaborated and QualifiedName types.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103517 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/ASTContext.h10
-rw-r--r--include/clang/AST/Decl.h26
-rw-r--r--include/clang/AST/RecursiveASTVisitor.h19
-rw-r--r--include/clang/AST/TemplateName.h2
-rw-r--r--include/clang/AST/Type.h203
-rw-r--r--include/clang/AST/TypeLoc.h12
-rw-r--r--include/clang/AST/TypeNodes.def1
-rw-r--r--include/clang/Frontend/TypeXML.def25
-rw-r--r--lib/AST/ASTContext.cpp65
-rw-r--r--lib/AST/ASTDiagnostic.cpp6
-rw-r--r--lib/AST/ASTImporter.cpp56
-rw-r--r--lib/AST/Decl.cpp12
-rw-r--r--lib/AST/DeclCXX.cpp2
-rw-r--r--lib/AST/NestedNameSpecifier.cpp6
-rw-r--r--lib/AST/Type.cpp108
-rw-r--r--lib/AST/TypePrinter.cpp31
-rw-r--r--lib/Checker/LLVMConventionsChecker.cpp2
-rw-r--r--lib/CodeGen/CGDebugInfo.cpp8
-rw-r--r--lib/CodeGen/CGObjCMac.cpp4
-rw-r--r--lib/Frontend/PCHReader.cpp11
-rw-r--r--lib/Frontend/PCHReaderDecl.cpp4
-rw-r--r--lib/Frontend/PCHWriter.cpp20
-rw-r--r--lib/Frontend/RewriteObjC.cpp16
-rw-r--r--lib/Sema/Sema.cpp4
-rw-r--r--lib/Sema/Sema.h3
-rw-r--r--lib/Sema/SemaCodeComplete.cpp6
-rw-r--r--lib/Sema/SemaDecl.cpp39
-rw-r--r--lib/Sema/SemaDeclAttr.cpp2
-rw-r--r--lib/Sema/SemaDeclCXX.cpp6
-rw-r--r--lib/Sema/SemaExprCXX.cpp2
-rw-r--r--lib/Sema/SemaInit.cpp4
-rw-r--r--lib/Sema/SemaTemplate.cpp78
-rw-r--r--lib/Sema/SemaTemplateInstantiate.cpp26
-rw-r--r--lib/Sema/SemaType.cpp41
-rw-r--r--lib/Sema/TreeTransform.h97
-rw-r--r--tools/libclang/CIndexUSRs.cpp8
-rw-r--r--tools/libclang/CXCursor.cpp8
37 files changed, 452 insertions, 521 deletions
diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h
index eed1dfd597..a53d803ecd 100644
--- a/include/clang/AST/ASTContext.h
+++ b/include/clang/AST/ASTContext.h
@@ -96,11 +96,10 @@ class ASTContext {
llvm::FoldingSet<TemplateTypeParmType> TemplateTypeParmTypes;
llvm::FoldingSet<SubstTemplateTypeParmType> SubstTemplateTypeParmTypes;
llvm::FoldingSet<TemplateSpecializationType> TemplateSpecializationTypes;
- llvm::FoldingSet<QualifiedNameType> QualifiedNameTypes;
+ llvm::FoldingSet<ElaboratedType> ElaboratedTypes;
llvm::FoldingSet<DependentNameType> DependentNameTypes;
llvm::FoldingSet<ObjCInterfaceType> ObjCInterfaceTypes;
llvm::FoldingSet<ObjCObjectPointerType> ObjCObjectPointerTypes;
- llvm::FoldingSet<ElaboratedType> ElaboratedTypes;
llvm::FoldingSet<QualifiedTemplateName> QualifiedTemplateNames;
llvm::FoldingSet<DependentTemplateName> DependentTemplateNames;
@@ -613,8 +612,9 @@ public:
const TemplateArgumentListInfo &Args,
QualType Canon = QualType());
- QualType getQualifiedNameType(NestedNameSpecifier *NNS,
- QualType NamedType);
+ QualType getElaboratedType(ElaboratedTypeKeyword Keyword,
+ NestedNameSpecifier *NNS,
+ QualType NamedType);
QualType getDependentNameType(ElaboratedTypeKeyword Keyword,
NestedNameSpecifier *NNS,
const IdentifierInfo *Name,
@@ -623,8 +623,6 @@ public:
NestedNameSpecifier *NNS,
const TemplateSpecializationType *TemplateId,
QualType Canon = QualType());
- QualType getElaboratedType(QualType UnderlyingType,
- ElaboratedType::TagKind Tag);
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl,
ObjCProtocolDecl **Protocols = 0,
diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h
index e65d4484da..7b2300bc4e 100644
--- a/include/clang/AST/Decl.h
+++ b/include/clang/AST/Decl.h
@@ -1648,11 +1648,7 @@ class TagDecl
: public TypeDecl, public DeclContext, public Redeclarable<TagDecl> {
public:
// This is really ugly.
- typedef ElaboratedType::TagKind TagKind;
- static const TagKind TK_struct = ElaboratedType::TK_struct;
- static const TagKind TK_union = ElaboratedType::TK_union;
- static const TagKind TK_class = ElaboratedType::TK_class;
- static const TagKind TK_enum = ElaboratedType::TK_enum;
+ typedef TagTypeKind TagKind;
private:
// FIXME: This can be packed into the bitfields in Decl.
@@ -1703,7 +1699,8 @@ protected:
TagDecl *PrevDecl, SourceLocation TKL = SourceLocation())
: TypeDecl(DK, DC, L, Id), DeclContext(DK), TagKeywordLoc(TKL),
TypedefDeclOrQualifier((TypedefDecl*) 0) {
- assert((DK != Enum || TK == TK_enum) &&"EnumDecl not matched with TK_enum");
+ assert((DK != Enum || TK == TTK_Enum) &&
+ "EnumDecl not matched with TTK_Enum");
TagDeclKind = TK;
IsDefinition = false;
IsEmbeddedInDeclarator = false;
@@ -1776,24 +1773,19 @@ public:
void setDefinition(bool V) { IsDefinition = V; }
const char *getKindName() const {
- return ElaboratedType::getNameForTagKind(getTagKind());
+ return TypeWithKeyword::getTagTypeKindName(getTagKind());
}
- /// getTagKindForTypeSpec - Converts a type specifier (DeclSpec::TST)
- /// into a tag kind. It is an error to provide a type specifier
- /// which *isn't* a tag kind here.
- static TagKind getTagKindForTypeSpec(unsigned TypeSpec);
-
TagKind getTagKind() const {
return TagKind(TagDeclKind);
}
void setTagKind(TagKind TK) { TagDeclKind = TK; }
- bool isStruct() const { return getTagKind() == TK_struct; }
- bool isClass() const { return getTagKind() == TK_class; }
- bool isUnion() const { return getTagKind() == TK_union; }
- bool isEnum() const { return getTagKind() == TK_enum; }
+ bool isStruct() const { return getTagKind() == TTK_Struct; }
+ bool isClass() const { return getTagKind() == TTK_Class; }
+ bool isUnion() const { return getTagKind() == TTK_Union; }
+ bool isEnum() const { return getTagKind() == TTK_Enum; }
TypedefDecl *getTypedefForAnonDecl() const {
return hasExtInfo() ? 0 : TypedefDeclOrQualifier.get<TypedefDecl*>();
@@ -1852,7 +1844,7 @@ class EnumDecl : public TagDecl {
EnumDecl(DeclContext *DC, SourceLocation L,
IdentifierInfo *Id, EnumDecl *PrevDecl, SourceLocation TKL)
- : TagDecl(Enum, TK_enum, DC, L, Id, PrevDecl, TKL), InstantiatedFrom(0) {
+ : TagDecl(Enum, TTK_Enum, DC, L, Id, PrevDecl, TKL), InstantiatedFrom(0) {
IntegerType = QualType();
}
public:
diff --git a/include/clang/AST/RecursiveASTVisitor.h b/include/clang/AST/RecursiveASTVisitor.h
index 27823694c7..a7a13409eb 100644
--- a/include/clang/AST/RecursiveASTVisitor.h
+++ b/include/clang/AST/RecursiveASTVisitor.h
@@ -567,14 +567,6 @@ case Stmt::CLASS ## Class: DISPATCH(CLASS, CLASS, S);
}
template<typename Derived>
- bool RecursiveASTVisitor<Derived>::VisitElaboratedType(ElaboratedType *T) {
- if (Visit(T->getUnderlyingType()))
- return true;
-
- return getDerived().VisitType(T);
- }
-
- template<typename Derived>
bool RecursiveASTVisitor<Derived>::VisitTemplateTypeParmType(
TemplateTypeParmType *T) {
return getDerived().VisitType(T);
@@ -603,12 +595,13 @@ case Stmt::CLASS ## Class: DISPATCH(CLASS, CLASS, S);
}
template<typename Derived>
- bool RecursiveASTVisitor<Derived>::VisitQualifiedNameType(
- QualifiedNameType *T) {
- if (getDerived().VisitNestedNameSpecifier(T->getQualifier()) ||
- Visit(T->getNamedType()))
+ bool RecursiveASTVisitor<Derived>::VisitElaboratedType(ElaboratedType *T) {
+ if (T->getQualifier() &&
+ getDerived().VisitNestedNameSpecifier(T->getQualifier()))
return true;
-
+ if (Visit(T->getNamedType()))
+ return true;
+
return getDerived().VisitType(T);
}
diff --git a/include/clang/AST/TemplateName.h b/include/clang/AST/TemplateName.h
index f3de9fa011..2e3b6df054 100644
--- a/include/clang/AST/TemplateName.h
+++ b/include/clang/AST/TemplateName.h
@@ -188,7 +188,7 @@ const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
/// declaration for "vector". The QualifiedTemplateName class is only
/// used to provide "sugar" for template names that were expressed
/// with a qualified name, and has no semantic meaning. In this
-/// manner, it is to TemplateName what QualifiedNameType is to Type,
+/// manner, it is to TemplateName what ElaboratedType is to Type,
/// providing extra syntactic sugar for downstream clients.
class QualifiedTemplateName : public llvm::FoldingSetNode {
/// \brief The nested name specifier that qualifies the template name.
diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h
index 030c74c640..dbf64371ab 100644
--- a/include/clang/AST/Type.h
+++ b/include/clang/AST/Type.h
@@ -92,7 +92,7 @@ namespace clang {
class TemplateArgumentLoc;
class TemplateArgumentListInfo;
class Type;
- class QualifiedNameType;
+ class ElaboratedType;
struct PrintingPolicy;
template <typename> class CanQual;
@@ -2264,68 +2264,6 @@ public:
static bool classof(const EnumType *) { return true; }
};
-/// ElaboratedType - A non-canonical type used to represents uses of
-/// elaborated type specifiers in C++. For example:
-///
-/// void foo(union MyUnion);
-/// ^^^^^^^^^^^^^
-///
-/// At the moment, for efficiency we do not create elaborated types in
-/// C, since outside of typedefs all references to structs would
-/// necessarily be elaborated.
-class ElaboratedType : public Type, public llvm::FoldingSetNode {
-public:
- enum TagKind {
- TK_struct,
- TK_union,
- TK_class,
- TK_enum
- };
-
-private:
- /// The tag that was used in this elaborated type specifier.
- TagKind Tag;
-
- /// The underlying type.
- QualType UnderlyingType;
-
- explicit ElaboratedType(QualType Ty, TagKind Tag, QualType Canon)
- : Type(Elaborated, Canon, Canon->isDependentType()),
- Tag(Tag), UnderlyingType(Ty) { }
- friend class ASTContext; // ASTContext creates these.
-
-public:
- TagKind getTagKind() const { return Tag; }
- QualType getUnderlyingType() const { return UnderlyingType; }
-
- /// \brief Remove a single level of sugar.
- QualType desugar() const { return getUnderlyingType(); }
-
- /// \brief Returns whether this type directly provides sugar.
- bool isSugared() const { return true; }
-
- static const char *getNameForTagKind(TagKind Kind) {
- switch (Kind) {
- 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";
- }
- }
-
- void Profile(llvm::FoldingSetNodeID &ID) {
- Profile(ID, getUnderlyingType(), getTagKind());
- }
- static void Profile(llvm::FoldingSetNodeID &ID, QualType T, TagKind Tag) {
- ID.AddPointer(T.getAsOpaquePtr());
- ID.AddInteger(Tag);
- }
-
- static bool classof(const ElaboratedType*) { return true; }
- static bool classof(const Type *T) { return T->getTypeClass() == Elaborated; }
-};
-
class TemplateTypeParmType : public Type, public llvm::FoldingSetNode {
unsigned Depth : 15;
unsigned Index : 16;
@@ -2592,46 +2530,116 @@ public:
static bool classof(const InjectedClassNameType *T) { return true; }
};
+/// \brief The kind of a tag type.
+enum TagTypeKind {
+ /// \brief The "struct" keyword.
+ TTK_Struct,
+ /// \brief The "union" keyword.
+ TTK_Union,
+ /// \brief The "class" keyword.
+ TTK_Class,
+ /// \brief The "enum" keyword.
+ TTK_Enum
+};
+
/// \brief The elaboration keyword that precedes a qualified type name or
/// introduces an elaborated-type-specifier.
enum ElaboratedTypeKeyword {
- /// \brief No keyword precedes the qualified type name.
- ETK_None,
- /// \brief The "typename" keyword precedes the qualified type name, e.g.,
- /// \c typename T::type.
- ETK_Typename,
- /// \brief The "class" keyword introduces the elaborated-type-specifier.
- ETK_Class,
/// \brief The "struct" keyword introduces the elaborated-type-specifier.
ETK_Struct,
/// \brief The "union" keyword introduces the elaborated-type-specifier.
ETK_Union,
+ /// \brief The "class" keyword introduces the elaborated-type-specifier.
+ ETK_Class,
/// \brief The "enum" keyword introduces the elaborated-type-specifier.
- ETK_Enum
+ ETK_Enum,
+ /// \brief The "typename" keyword precedes the qualified type name, e.g.,
+ /// \c typename T::type.
+ ETK_Typename,
+ /// \brief No keyword precedes the qualified type name.
+ ETK_None
};
-
-/// \brief Represents a type that was referred to via a qualified
-/// name, e.g., N::M::type.
+
+/// A helper class for Type nodes having an ElaboratedTypeKeyword.
+/// The keyword in stored in the free bits of the base class.
+/// Also provides a few static helpers for converting and printing
+/// elaborated type keyword and tag type kind enumerations.
+class TypeWithKeyword : public Type {
+ /// Keyword - Encodes an ElaboratedTypeKeyword enumeration constant.
+ unsigned Keyword : 3;
+
+protected:
+ TypeWithKeyword(ElaboratedTypeKeyword Keyword, TypeClass tc,
+ QualType Canonical, bool dependent)
+ : Type(tc, Canonical, dependent), Keyword(Keyword) {}
+
+public:
+ virtual ~TypeWithKeyword(); // pin vtable to Type.cpp
+
+ ElaboratedTypeKeyword getKeyword() const {
+ return static_cast<ElaboratedTypeKeyword>(Keyword);
+ }
+
+ /// getKeywordForTypeSpec - Converts a type specifier (DeclSpec::TST)
+ /// into an elaborated type keyword.
+ static ElaboratedTypeKeyword getKeywordForTypeSpec(unsigned TypeSpec);
+
+ /// getTagTypeKindForTypeSpec - Converts a type specifier (DeclSpec::TST)
+ /// into a tag type kind. It is an error to provide a type specifier
+ /// which *isn't* a tag kind here.
+ static TagTypeKind getTagTypeKindForTypeSpec(unsigned TypeSpec);
+
+ /// getKeywordForTagDeclKind - Converts a TagTypeKind into an
+ /// elaborated type keyword.
+ static ElaboratedTypeKeyword getKeywordForTagTypeKind(TagTypeKind Tag);
+
+ /// getTagTypeKindForKeyword - Converts an elaborated type keyword into
+ // a TagTypeKind. It is an error to provide an elaborated type keyword
+ /// which *isn't* a tag kind here.
+ static TagTypeKind getTagTypeKindForKeyword(ElaboratedTypeKeyword Keyword);
+
+ static bool KeywordIsTagTypeKind(ElaboratedTypeKeyword Keyword);
+
+ static const char *getKeywordName(ElaboratedTypeKeyword Keyword);
+
+ static const char *getTagTypeKindName(TagTypeKind Kind) {
+ return getKeywordName(getKeywordForTagTypeKind(Kind));
+ }
+
+ class CannotCastToThisType {};
+ static CannotCastToThisType classof(const Type *);
+};
+
+/// \brief Represents a type that was referred to using an elaborated type
+/// keyword, e.g., struct S, or via a qualified name, e.g., N::M::type,
+/// or both.
///
/// This type is used to keep track of a type name as written in the
-/// source code, including any nested-name-specifiers. The type itself
-/// is always "sugar", used to express what was written in the source
-/// code but containing no additional semantic information.
-class QualifiedNameType : public Type, public llvm::FoldingSetNode {
+/// source code, including tag keywords and any nested-name-specifiers.
+/// The type itself is always "sugar", used to express what was written
+/// in the source code but containing no additional semantic information.
+class ElaboratedType : public TypeWithKeyword, public llvm::FoldingSetNode {
+
/// \brief The nested name specifier containing the qualifier.
NestedNameSpecifier *NNS;
/// \brief The type that this qualified name refers to.
QualType NamedType;
- QualifiedNameType(NestedNameSpecifier *NNS, QualType NamedType,
- QualType CanonType)
- : Type(QualifiedName, CanonType, NamedType->isDependentType()),
- NNS(NNS), NamedType(NamedType) { }
+ ElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS,
+ QualType NamedType, QualType CanonType)
+ : TypeWithKeyword(Keyword, Elaborated, CanonType,
+ NamedType->isDependentType()),
+ NNS(NNS), NamedType(NamedType) {
+ assert(!(Keyword == ETK_None && NNS == 0) &&
+ "ElaboratedType cannot have elaborated type keyword "
+ "and name qualifier both null.");
+ }
friend class ASTContext; // ASTContext creates these
public:
+
/// \brief Retrieve the qualification on this type.
NestedNameSpecifier *getQualifier() const { return NNS; }
@@ -2645,19 +2653,20 @@ public:
bool isSugared() const { return true; }
void Profile(llvm::FoldingSetNodeID &ID) {
- Profile(ID, NNS, NamedType);
+ Profile(ID, getKeyword(), NNS, NamedType);
}
- static void Profile(llvm::FoldingSetNodeID &ID, NestedNameSpecifier *NNS,
- QualType NamedType) {
+ static void Profile(llvm::FoldingSetNodeID &ID, ElaboratedTypeKeyword Keyword,
+ NestedNameSpecifier *NNS, QualType NamedType) {
+ ID.AddInteger(Keyword);
ID.AddPointer(NNS);
NamedType.Profile(ID);
}
static bool classof(const Type *T) {
- return T->getTypeClass() == QualifiedName;
+ return T->getTypeClass() == Elaborated;
}
- static bool classof(const QualifiedNameType *T) { return true; }
+ static bool classof(const ElaboratedType *T) { return true; }
};
/// \brief Represents a qualified type name for which the type name is
@@ -2669,10 +2678,8 @@ public:
/// typename-specifier), "class", "struct", "union", or "enum" (for a
/// dependent elaborated-type-specifier), or nothing (in contexts where we
/// know that we must be referring to a type, e.g., in a base class specifier).
-class DependentNameType : public Type, public llvm::FoldingSetNode {
- /// \brief The keyword used to elaborate this type.
- ElaboratedTypeKeyword Keyword;
-
+class DependentNameType : public TypeWithKeyword, public llvm::FoldingSetNode {
+
/// \brief The nested name specifier containing the qualifier.
NestedNameSpecifier *NNS;
@@ -2684,16 +2691,16 @@ class DependentNameType : public Type, public llvm::FoldingSetNode {
DependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS,
const IdentifierInfo *Name, QualType CanonType)
- : Type(DependentName, CanonType, true),
- Keyword(Keyword), NNS(NNS), Name(Name) {
+ : TypeWithKeyword(Keyword, DependentName, CanonType, true),
+ NNS(NNS), Name(Name) {
assert(NNS->isDependent() &&
"DependentNameType requires a dependent nested-name-specifier");
}
DependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS,
const TemplateSpecializationType *Ty, QualType CanonType)
- : Type(DependentName, CanonType, true),
- Keyword(Keyword), NNS(NNS), Name(Ty) {
+ : TypeWithKeyword(Keyword, DependentName, CanonType, true),
+ NNS(NNS), Name(Ty) {
assert(NNS->isDependent() &&
"DependentNameType requires a dependent nested-name-specifier");
}
@@ -2701,9 +2708,7 @@ class DependentNameType : public Type, public llvm::FoldingSetNode {
friend class ASTContext; // ASTContext creates these
public:
- /// \brief Retrieve the keyword used to elaborate this type.
- ElaboratedTypeKeyword getKeyword() const { return Keyword; }
-
+
/// \brief Retrieve the qualification on this type.
NestedNameSpecifier *getQualifier() const { return NNS; }
@@ -2727,7 +2732,7 @@ public:
QualType desugar() const { return QualType(this, 0); }
void Profile(llvm::FoldingSetNodeID &ID) {
- Profile(ID, Keyword, NNS, Name);
+ Profile(ID, getKeyword(), NNS, Name);
}
static void Profile(llvm::FoldingSetNodeID &ID, ElaboratedTypeKeyword Keyword,
diff --git a/include/clang/AST/TypeLoc.h b/include/clang/AST/TypeLoc.h
index aeedd0f90a..9927ae7edb 100644
--- a/include/clang/AST/TypeLoc.h
+++ b/include/clang/AST/TypeLoc.h
@@ -1231,18 +1231,12 @@ class DecltypeTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
DecltypeType> {
};
-// FIXME: location of the tag keyword.
-class ElaboratedTypeLoc : public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
- ElaboratedTypeLoc,
- ElaboratedType> {
-};
-
// FIXME: locations for the nested name specifier; at the very least,
// a SourceRange.
-class QualifiedNameTypeLoc :
+class ElaboratedTypeLoc :
public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
- QualifiedNameTypeLoc,
- QualifiedNameType> {
+ ElaboratedTypeLoc,
+ ElaboratedType> {
};
// FIXME: locations for the typename keyword and nested name specifier.
diff --git a/include/clang/AST/TypeNodes.def b/include/clang/AST/TypeNodes.def
index c665073025..ca27a2b949 100644
--- a/include/clang/AST/TypeNodes.def
+++ b/include/clang/AST/TypeNodes.def
@@ -90,7 +90,6 @@ NON_CANONICAL_TYPE(Elaborated, Type)
DEPENDENT_TYPE(TemplateTypeParm, Type)
NON_CANONICAL_TYPE(SubstTemplateTypeParm, Type)
NON_CANONICAL_UNLESS_DEPENDENT_TYPE(TemplateSpecialization, Type)
-NON_CANONICAL_TYPE(QualifiedName, Type)
DEPENDENT_TYPE(InjectedClassName, Type)
DEPENDENT_TYPE(DependentName, Type)
TYPE(ObjCInterface, Type)
diff --git a/include/clang/Frontend/TypeXML.def b/include/clang/Frontend/TypeXML.def
index 802cc4297b..069d718d9d 100644
--- a/include/clang/Frontend/TypeXML.def
+++ b/include/clang/Frontend/TypeXML.def
@@ -211,22 +211,13 @@ NODE_XML(RecordType, "Record")
ID_ATTRIBUTE_XML
ATTRIBUTE_XML(getDecl()->getNameAsString(), "name") // string
ATTRIBUTE_ENUM_XML(getDecl()->getTagKind(), "kind")
- ENUM_XML(TagDecl::TK_struct, "struct")
- ENUM_XML(TagDecl::TK_union, "union")
- ENUM_XML(TagDecl::TK_class, "class")
+ ENUM_XML(TTK_Struct, "struct")
+ ENUM_XML(TTK_Union, "union")
+ ENUM_XML(TTK_Class, "class")
END_ENUM_XML
CONTEXT_ATTRIBUTE_XML(getDecl()->getDeclContext())
END_NODE_XML
-NODE_XML(ElaboratedType, "Elaborated")
- ID_ATTRIBUTE_XML
- ATTRIBUTE_ENUM_XML(getTagKind(), "kind")
- ENUM_XML(ElaboratedType::TK_struct, "struct")
- ENUM_XML(ElaboratedType::TK_union, "union")
- ENUM_XML(ElaboratedType::TK_class, "class")
- END_ENUM_XML
-END_NODE_XML
-
NODE_XML(EnumType, "Enum")
ID_ATTRIBUTE_XML
ATTRIBUTE_XML(getDecl()->getNameAsString(), "name") // string
@@ -241,8 +232,16 @@ NODE_XML(TemplateSpecializationType, "TemplateSpecializationType")
ID_ATTRIBUTE_XML
END_NODE_XML
-NODE_XML(QualifiedNameType, "QualifiedNameType")
+NODE_XML(ElaboratedType, "ElaboratedType")
ID_ATTRIBUTE_XML
+ ATTRIBUTE_ENUM_XML(getKeyword(), "keyword")
+ ENUM_XML(ETK_None, "none")
+ ENUM_XML(ETK_Typename, "typename")
+ ENUM_XML(ETK_Struct, "struct")
+ ENUM_XML(ETK_Union, "union")
+ ENUM_XML(ETK_Class, "class")
+ ENUM_XML(ETK_Enum, "enum")
+ END_ENUM_XML
TYPE_ATTRIBUTE_XML(getNamedType())
END_NODE_XML
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index 71ef09ab18..81b56add8e 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -626,10 +626,6 @@ ASTContext::getTypeInfo(const Type *T) {
return getTypeInfo(cast<SubstTemplateTypeParmType>(T)->
getReplacementType().getTypePtr());
- case Type::Elaborated:
- return getTypeInfo(cast<ElaboratedType>(T)->getUnderlyingType()
- .getTypePtr());
-
case Type::Typedef: {
const TypedefDecl *Typedef = cast<TypedefType>(T)->getDecl();
if (const AlignedAttr *Aligned = Typedef->getAttr<AlignedAttr>()) {
@@ -652,8 +648,8 @@ ASTContext::getTypeInfo(const Type *T) {
return getTypeInfo(cast<DecltypeType>(T)->getUnderlyingExpr()->getType()
.getTypePtr());
- case Type::QualifiedName:
- return getTypeInfo(cast<QualifiedNameType>(T)->getNamedType().getTypePtr());
+ case Type::Elaborated:
+ return getTypeInfo(cast<ElaboratedType>(T)->getNamedType().getTypePtr());
case Type::TemplateSpecialization:
assert(getCanonicalType(T) != T &&
@@ -1890,29 +1886,28 @@ ASTContext::getTemplateSpecializationType(TemplateName Template,
}
QualType
-ASTContext::getQualifiedNameType(NestedNameSpecifier *NNS,
- QualType NamedType) {
+ASTContext::getElaboratedType(ElaboratedTypeKeyword Keyword,
+ NestedNameSpecifier *NNS,
+ QualType NamedType) {
llvm::FoldingSetNodeID ID;
- QualifiedNameType::Profile(ID, NNS, NamedType);
+ ElaboratedType::Profile(ID, Keyword, NNS, NamedType);
void *InsertPos = 0;
- QualifiedNameType *T
- = QualifiedNameTypes.FindNodeOrInsertPos(ID, InsertPos);
+ ElaboratedType *T = ElaboratedTypes.FindNodeOrInsertPos(ID, InsertPos);
if (T)
return QualType(T, 0);
QualType Canon = NamedType;
if (!Canon.isCanonical()) {
Canon = getCanonicalType(NamedType);
- QualifiedNameType *CheckT
- = QualifiedNameTypes.FindNodeOrInsertPos(ID, InsertPos);
- assert(!CheckT && "Qualified name canonical type broken");
+ ElaboratedType *CheckT = ElaboratedTypes.FindNodeOrInsertPos(ID, InsertPos);
+ assert(!CheckT && "Elaborated canonical type broken");
(void)CheckT;
}
- T = new (*this) QualifiedNameType(NNS, NamedType, Canon);
+ T = new (*this) ElaboratedType(Keyword, NNS, NamedType, Canon);
Types.push_back(T);
- QualifiedNameTypes.InsertNode(T, InsertPos);
+ ElaboratedTypes.InsertNode(T, InsertPos);
return QualType(T, 0);
}
@@ -1989,30 +1984,6 @@ ASTContext::getDependentNameType(ElaboratedTypeKeyword Keyword,
return QualType(T, 0);
}
-QualType
-ASTContext::getElaboratedType(QualType UnderlyingType,
- ElaboratedType::TagKind Tag) {
- llvm::FoldingSetNodeID ID;
- ElaboratedType::Profile(ID, UnderlyingType, Tag);
-
- void *InsertPos = 0;
- ElaboratedType *T = ElaboratedTypes.FindNodeOrInsertPos(ID, InsertPos);
- if (T)
- return QualType(T, 0);
-
- QualType Canon = UnderlyingType;
- if (!Canon.isCanonical()) {
- Canon = getCanonicalType(Canon);
- ElaboratedType *CheckT = ElaboratedTypes.FindNodeOrInsertPos(ID, InsertPos);
- assert(!CheckT && "Elaborated canonical type is broken"); (void)CheckT;
- }
-
- T = new (*this) ElaboratedType(UnderlyingType, Tag, Canon);
- Types.push_back(T);
- ElaboratedTypes.InsertNode(T, InsertPos);
- return QualType(T, 0);
-}
-
/// CmpProtocolNames - Comparison predicate for sorting protocols
/// alphabetically.
static bool CmpProtocolNames(const ObjCProtocolDecl *LHS,
@@ -2813,7 +2784,7 @@ CreateRecordDecl(ASTContext &Ctx, RecordDecl::TagKind TK, DeclContext *DC,
QualType ASTContext::getCFConstantStringType() {
if (!CFConstantStringTypeDecl) {
CFConstantStringTypeDecl =
- CreateRecordDecl(*this, TagDecl::TK_struct, TUDecl, SourceLocation(),
+ CreateRecordDecl(*this, TTK_Struct, TUDecl, SourceLocation(),
&Idents.get("NSConstantString"));
CFConstantStringTypeDecl->startDefinition();
@@ -2855,7 +2826,7 @@ void ASTContext::setCFConstantStringType(QualType T) {
QualType ASTContext::getNSConstantStringType() {
if (!NSConstantStringTypeDecl) {
NSConstantStringTypeDecl =
- CreateRecordDecl(*this, TagDecl::TK_struct, TUDecl, SourceLocation(),
+ CreateRecordDecl(*this, TTK_Struct, TUDecl, SourceLocation(),
&Idents.get("__builtin_NSString"));
NSConstantStringTypeDecl->startDefinition();
@@ -2894,7 +2865,7 @@ void ASTContext::setNSConstantStringType(QualType T) {
QualType ASTContext::getObjCFastEnumerationStateType() {
if (!ObjCFastEnumerationStateTypeDecl) {
ObjCFastEnumerationStateTypeDecl =
- CreateRecordDecl(*this, TagDecl::TK_struct, TUDecl, SourceLocation(),
+ CreateRecordDecl(*this, TTK_Struct, TUDecl, SourceLocation(),
&Idents.get("__objcFastEnumerationState"));
ObjCFastEnumerationStateTypeDecl->startDefinition();
@@ -2929,7 +2900,7 @@ QualType ASTContext::getBlockDescriptorType() {
RecordDecl *T;
// FIXME: Needs the FlagAppleBlock bit.
- T = CreateRecordDecl(*this, TagDecl::TK_struct, TUDecl, SourceLocation(),
+ T = CreateRecordDecl(*this, TTK_Struct, TUDecl, SourceLocation(),
&Idents.get("__block_descriptor"));
T->startDefinition();
@@ -2974,7 +2945,7 @@ QualType ASTContext::getBlockDescriptorExtendedType() {
RecordDecl *T;
// FIXME: Needs the FlagAppleBloc