diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-02-26 23:50:07 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-02-26 23:50:07 +0000 |
commit | 72564e73277e29f6db3305d1f27ba408abb7ed88 (patch) | |
tree | 857ee84221eb8cb9b57d6b2e787347696c282f63 /lib/CodeGen/CodeGenTypes.cpp | |
parent | 3a2503227c3db04a3619735127483263c1075ef7 (diff) |
Create a new TypeNodes.def file that enumerates all of the types,
giving them rough classifications (normal types, never-canonical
types, always-dependent types, abstract type representations) and
making it far easier to make sure that we've hit all of the cases when
decoding types.
Switched some switch() statements on the type class over to using this
mechanism, and filtering out those things we don't care about. For
example, CodeGen should never see always-dependent or non-canonical
types, while debug info generation should never see always-dependent
types. More switch() statements on the type class need to be moved
over to using this approach, so that we'll get warnings when we add a
new type then fail to account for it somewhere in the compiler.
As part of this, some types have been renamed:
TypeOfExpr -> TypeOfExprType
FunctionTypeProto -> FunctionProtoType
FunctionTypeNoProto -> FunctionNoProtoType
There shouldn't be any functionality change...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65591 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenTypes.cpp')
-rw-r--r-- | lib/CodeGen/CodeGenTypes.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/lib/CodeGen/CodeGenTypes.cpp b/lib/CodeGen/CodeGenTypes.cpp index 1458ccd91b..0912183053 100644 --- a/lib/CodeGen/CodeGenTypes.cpp +++ b/lib/CodeGen/CodeGenTypes.cpp @@ -174,13 +174,14 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) { const clang::Type &Ty = *Context.getCanonicalType(T); switch (Ty.getTypeClass()) { - case Type::TypeName: // typedef isn't canonical. - case Type::TemplateTypeParm:// template type parameters never generated - case Type::ClassTemplateSpecialization: // these types are always sugar - case Type::DependentSizedArray: // dependent types are never generated - case Type::TypeOfExp: // typeof isn't canonical. - case Type::TypeOfTyp: // typeof isn't canonical. - assert(0 && "Non-canonical type, shouldn't happen"); +#define TYPE(Class, Base) +#define ABSTRACT_TYPE(Class, Base) +#define NON_CANONICAL_TYPE(Class, Base) case Type::Class: +#define DEPENDENT_TYPE(Class, Base) case Type::Class: +#include "clang/AST/TypeNodes.def" + assert(false && "Non-canonical or dependent types aren't possible."); + break; + case Type::Builtin: { switch (cast<BuiltinType>(Ty).getKind()) { default: assert(0 && "Unknown builtin type!"); @@ -265,10 +266,10 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) { VT.getNumElements()); } case Type::FunctionNoProto: - return GetFunctionType(getFunctionInfo(cast<FunctionTypeNoProto>(&Ty)), + return GetFunctionType(getFunctionInfo(cast<FunctionNoProtoType>(&Ty)), true); case Type::FunctionProto: { - const FunctionTypeProto *FTP = cast<FunctionTypeProto>(&Ty); + const FunctionProtoType *FTP = cast<FunctionProtoType>(&Ty); return GetFunctionType(getFunctionInfo(FTP), FTP->isVariadic()); } @@ -300,7 +301,9 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) { // Protocols don't influence the LLVM type. return ConvertTypeRecursive(Context.getObjCIdType()); - case Type::Tagged: { + case Type::Record: + case Type::CXXRecord: + case Type::Enum: { const TagDecl *TD = cast<TagType>(Ty).getDecl(); const llvm::Type *Res = ConvertTagDeclType(TD); |