aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-02-26 23:50:07 +0000
committerDouglas Gregor <dgregor@apple.com>2009-02-26 23:50:07 +0000
commit72564e73277e29f6db3305d1f27ba408abb7ed88 (patch)
tree857ee84221eb8cb9b57d6b2e787347696c282f63 /lib/CodeGen
parent3a2503227c3db04a3619735127483263c1075ef7 (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')
-rw-r--r--lib/CodeGen/CGBlocks.cpp10
-rw-r--r--lib/CodeGen/CGCall.cpp8
-rw-r--r--lib/CodeGen/CGDebugInfo.cpp24
-rw-r--r--lib/CodeGen/CodeGenFunction.cpp2
-rw-r--r--lib/CodeGen/CodeGenFunction.h2
-rw-r--r--lib/CodeGen/CodeGenTypes.cpp23
-rw-r--r--lib/CodeGen/CodeGenTypes.h6
-rw-r--r--lib/CodeGen/Mangle.cpp4
8 files changed, 46 insertions, 33 deletions
diff --git a/lib/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp
index 65f6cb11e8..276c46fdb5 100644
--- a/lib/CodeGen/CGBlocks.cpp
+++ b/lib/CodeGen/CGBlocks.cpp
@@ -321,12 +321,12 @@ CodeGenModule::getGenericExtendedBlockLiteralType() {
/// function type for the block, including the first block literal argument.
static QualType getBlockFunctionType(ASTContext &Ctx,
const BlockPointerType *BPT) {
- const FunctionTypeProto *FTy = cast<FunctionTypeProto>(BPT->getPointeeType());
+ const FunctionProtoType *FTy = cast<FunctionProtoType>(BPT->getPointeeType());
llvm::SmallVector<QualType, 8> Types;
Types.push_back(Ctx.getPointerType(Ctx.VoidTy));
- for (FunctionTypeProto::arg_type_iterator i = FTy->arg_type_begin(),
+ for (FunctionProtoType::arg_type_iterator i = FTy->arg_type_begin(),
e = FTy->arg_type_end(); i != e; ++i)
Types.push_back(*i);
@@ -455,9 +455,9 @@ llvm::Function *CodeGenFunction::GenerateBlockFunction(const BlockExpr *Expr,
const BlockInfo& Info,
uint64_t &Size,
uint64_t &Align,
- llvm::SmallVector<ValueDecl *, 8> &subBlockDeclRefDecls) {
- const FunctionTypeProto *FTy =
- cast<FunctionTypeProto>(Expr->getFunctionType());
+ llvm::SmallVector<ValueDecl *, 8> &subBlockDeclRefDecls) {
+ const FunctionProtoType *FTy =
+ cast<FunctionProtoType>(Expr->getFunctionType());
FunctionArgList Args;
diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp
index 7a98b0c1c6..38f6e96c14 100644
--- a/lib/CodeGen/CGCall.cpp
+++ b/lib/CodeGen/CGCall.cpp
@@ -37,13 +37,13 @@ using namespace CodeGen;
// FIXME: Use iterator and sidestep silly type array creation.
const
-CGFunctionInfo &CodeGenTypes::getFunctionInfo(const FunctionTypeNoProto *FTNP) {
+CGFunctionInfo &CodeGenTypes::getFunctionInfo(const FunctionNoProtoType *FTNP) {
return getFunctionInfo(FTNP->getResultType(),
llvm::SmallVector<QualType, 16>());
}
const
-CGFunctionInfo &CodeGenTypes::getFunctionInfo(const FunctionTypeProto *FTP) {
+CGFunctionInfo &CodeGenTypes::getFunctionInfo(const FunctionProtoType *FTP) {
llvm::SmallVector<QualType, 16> ArgTys;
// FIXME: Kill copy.
for (unsigned i = 0, e = FTP->getNumArgs(); i != e; ++i)
@@ -53,9 +53,9 @@ CGFunctionInfo &CodeGenTypes::getFunctionInfo(const FunctionTypeProto *FTP) {
const CGFunctionInfo &CodeGenTypes::getFunctionInfo(const FunctionDecl *FD) {
const FunctionType *FTy = FD->getType()->getAsFunctionType();
- if (const FunctionTypeProto *FTP = dyn_cast<FunctionTypeProto>(FTy))
+ if (const FunctionProtoType *FTP = dyn_cast<FunctionProtoType>(FTy))
return getFunctionInfo(FTP);
- return getFunctionInfo(cast<FunctionTypeNoProto>(FTy));
+ return getFunctionInfo(cast<FunctionNoProtoType>(FTy));
}
const CGFunctionInfo &CodeGenTypes::getFunctionInfo(const ObjCMethodDecl *MD) {
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp
index 5e78c5817d..6c67ba5814 100644
--- a/lib/CodeGen/CGDebugInfo.cpp
+++ b/lib/CodeGen/CGDebugInfo.cpp
@@ -179,7 +179,7 @@ llvm::DIType CGDebugInfo::CreateType(const FunctionType *Ty,
// Set up remainder of arguments if there is a prototype.
// FIXME: IF NOT, HOW IS THIS REPRESENTED? llvm-gcc doesn't represent '...'!
- if (const FunctionTypeProto *FTP = dyn_cast<FunctionTypeProto>(Ty)) {
+ if (const FunctionProtoType *FTP = dyn_cast<FunctionProtoType>(Ty)) {
for (unsigned i = 0, e = FTP->getNumArgs(); i != e; ++i)
EltTys.push_back(getOrCreateType(FTP->getArgType(i), Unit));
} else {
@@ -481,6 +481,13 @@ llvm::DIType CGDebugInfo::getOrCreateType(QualType Ty,
// Work out details of type.
switch (Ty->getTypeClass()) {
+#define TYPE(Class, Base)
+#define ABSTRACT_TYPE(Class, Base)
+#define NON_CANONICAL_TYPE(Class, Base)
+#define DEPENDENT_TYPE(Class, Base) case Type::Class:
+#include "clang/AST/TypeNodes.def"
+ assert(false && "Dependent types cannot show up in debug information");
+
case Type::Complex:
case Type::Reference:
case Type::Vector:
@@ -489,13 +496,16 @@ llvm::DIType CGDebugInfo::getOrCreateType(QualType Ty,
case Type::ObjCInterface:
case Type::ObjCQualifiedInterface:
case Type::ObjCQualifiedId:
- default:
return llvm::DIType();
case Type::Builtin: Slot = CreateType(cast<BuiltinType>(Ty), Unit); break;
case Type::Pointer: Slot = CreateType(cast<PointerType>(Ty), Unit); break;
- case Type::TypeName: Slot = CreateType(cast<TypedefType>(Ty), Unit); break;
- case Type::Tagged: Slot = CreateType(cast<TagType>(Ty), Unit); break;
+ case Type::Typedef: Slot = CreateType(cast<TypedefType>(Ty), Unit); break;
+ case Type::Record:
+ case Type::CXXRecord:
+ case Type::Enum:
+ Slot = CreateType(cast<TagType>(Ty), Unit);
+ break;
case Type::FunctionProto:
case Type::FunctionNoProto:
return Slot = CreateType(cast<FunctionType>(Ty), Unit);
@@ -504,10 +514,10 @@ llvm::DIType CGDebugInfo::getOrCreateType(QualType Ty,
case Type::VariableArray:
case Type::IncompleteArray:
return Slot = CreateType(cast<ArrayType>(Ty), Unit);
- case Type::TypeOfExp:
- return Slot = getOrCreateType(cast<TypeOfExpr>(Ty)->getUnderlyingExpr()
+ case Type::TypeOfExpr:
+ return Slot = getOrCreateType(cast<TypeOfExprType>(Ty)->getUnderlyingExpr()
->getType(), Unit);
- case Type::TypeOfTyp:
+ case Type::TypeOf:
return Slot = getOrCreateType(cast<TypeOfType>(Ty)->getUnderlyingType(),
Unit);
}
diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp
index 81fd3871d6..d6e3394b8d 100644
--- a/lib/CodeGen/CodeGenFunction.cpp
+++ b/lib/CodeGen/CodeGenFunction.cpp
@@ -209,7 +209,7 @@ void CodeGenFunction::GenerateCode(const FunctionDecl *FD,
FunctionArgList Args;
if (FD->getNumParams()) {
- const FunctionTypeProto* FProto = FD->getType()->getAsFunctionTypeProto();
+ const FunctionProtoType* FProto = FD->getType()->getAsFunctionProtoType();
assert(FProto && "Function def must have prototype!");
for (unsigned i = 0, e = FD->getNumParams(); i != e; ++i)
diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h
index 918646f955..057f554ac6 100644
--- a/lib/CodeGen/CodeGenFunction.h
+++ b/lib/CodeGen/CodeGenFunction.h
@@ -41,7 +41,7 @@ namespace clang {
class Decl;
class EnumConstantDecl;
class FunctionDecl;
- class FunctionTypeProto;
+ class FunctionProtoType;
class LabelStmt;
class ObjCContainerDecl;
class ObjCInterfaceDecl;
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);
diff --git a/lib/CodeGen/CodeGenTypes.h b/lib/CodeGen/CodeGenTypes.h
index 228502d0cd..e5dbd84f43 100644
--- a/lib/CodeGen/CodeGenTypes.h
+++ b/lib/CodeGen/CodeGenTypes.h
@@ -33,7 +33,7 @@ namespace clang {
class ABIInfo;
class ASTContext;
class FieldDecl;
- class FunctionTypeProto;
+ class FunctionProtoType;
class ObjCInterfaceDecl;
class ObjCIvarDecl;
class PointerType;
@@ -166,8 +166,8 @@ public:
const llvm::SmallVector<QualType,16>
&ArgTys);
- const CGFunctionInfo &getFunctionInfo(const FunctionTypeNoProto *FTNP);
- const CGFunctionInfo &getFunctionInfo(const FunctionTypeProto *FTP);
+ const CGFunctionInfo &getFunctionInfo(const FunctionNoProtoType *FTNP);
+ const CGFunctionInfo &getFunctionInfo(const FunctionProtoType *FTP);
const CGFunctionInfo &getFunctionInfo(const FunctionDecl *FD);
const CGFunctionInfo &getFunctionInfo(const ObjCMethodDecl *MD);
const CGFunctionInfo &getFunctionInfo(QualType ResTy,
diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp
index c802966686..525f0fe1d6 100644
--- a/lib/CodeGen/Mangle.cpp
+++ b/lib/CodeGen/Mangle.cpp
@@ -454,10 +454,10 @@ void CXXNameMangler::mangleBareFunctionType(const FunctionType *T,
if (MangleReturnType)
mangleType(T->getResultType());
- const FunctionTypeProto *Proto = dyn_cast<FunctionTypeProto>(T);
+ const FunctionProtoType *Proto = dyn_cast<FunctionProtoType>(T);
assert(Proto && "Can't mangle K&R function prototypes");
- for (FunctionTypeProto::arg_type_iterator Arg = Proto->arg_type_begin(),
+ for (FunctionProtoType::arg_type_iterator Arg = Proto->arg_type_begin(),
ArgEnd = Proto->arg_type_end();
Arg != ArgEnd; ++Arg)
mangleType(*Arg);