summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/AST')
-rw-r--r--clang/lib/AST/ASTContext.cpp128
-rw-r--r--clang/lib/AST/Builtins.cpp2
-rw-r--r--clang/lib/AST/Decl.cpp4
-rw-r--r--clang/lib/AST/DeclCXX.cpp8
-rw-r--r--clang/lib/AST/StmtPrinter.cpp6
-rw-r--r--clang/lib/AST/Type.cpp45
-rw-r--r--clang/lib/AST/TypeSerialization.cpp48
7 files changed, 140 insertions, 101 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index d059201b5cd..53aaf513382 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -91,7 +91,7 @@ void ASTContext::PrintStats() const {
unsigned NumTagStruct = 0, NumTagUnion = 0, NumTagEnum = 0, NumTagClass = 0;
unsigned NumObjCInterfaces = 0, NumObjCQualifiedInterfaces = 0;
unsigned NumObjCQualifiedIds = 0;
- unsigned NumTypeOfTypes = 0, NumTypeOfExprs = 0;
+ unsigned NumTypeOfTypes = 0, NumTypeOfExprTypes = 0;
for (unsigned i = 0, e = Types.size(); i != e; ++i) {
Type *T = Types[i];
@@ -111,9 +111,9 @@ void ASTContext::PrintStats() const {
++NumArray;
else if (isa<VectorType>(T))
++NumVector;
- else if (isa<FunctionTypeNoProto>(T))
+ else if (isa<FunctionNoProtoType>(T))
++NumFunctionNP;
- else if (isa<FunctionTypeProto>(T))
+ else if (isa<FunctionProtoType>(T))
++NumFunctionP;
else if (isa<TypedefType>(T))
++NumTypeName;
@@ -134,8 +134,8 @@ void ASTContext::PrintStats() const {
++NumObjCQualifiedIds;
else if (isa<TypeOfType>(T))
++NumTypeOfTypes;
- else if (isa<TypeOfExpr>(T))
- ++NumTypeOfExprs;
+ else if (isa<TypeOfExprType>(T))
+ ++NumTypeOfExprTypes;
else {
QualType(T, 0).dump();
assert(0 && "Unknown type!");
@@ -164,16 +164,16 @@ void ASTContext::PrintStats() const {
fprintf(stderr, " %d protocol qualified id types\n",
NumObjCQualifiedIds);
fprintf(stderr, " %d typeof types\n", NumTypeOfTypes);
- fprintf(stderr, " %d typeof exprs\n", NumTypeOfExprs);
+ fprintf(stderr, " %d typeof exprs\n", NumTypeOfExprTypes);
fprintf(stderr, "Total bytes = %d\n", int(NumBuiltin*sizeof(BuiltinType)+
NumPointer*sizeof(PointerType)+NumArray*sizeof(ArrayType)+
NumComplex*sizeof(ComplexType)+NumVector*sizeof(VectorType)+
NumMemberPointer*sizeof(MemberPointerType)+
- NumFunctionP*sizeof(FunctionTypeProto)+
- NumFunctionNP*sizeof(FunctionTypeNoProto)+
+ NumFunctionP*sizeof(FunctionProtoType)+
+ NumFunctionNP*sizeof(FunctionNoProtoType)+
NumTypeName*sizeof(TypedefType)+NumTagged*sizeof(TagType)+
- NumTypeOfTypes*sizeof(TypeOfType)+NumTypeOfExprs*sizeof(TypeOfExpr)));
+ NumTypeOfTypes*sizeof(TypeOfType)+NumTypeOfExprTypes*sizeof(TypeOfExprType)));
}
@@ -293,15 +293,20 @@ ASTContext::getTypeInfo(const Type *T) {
uint64_t Width;
unsigned Align;
switch (T->getTypeClass()) {
- case Type::TypeName: assert(0 && "Not a canonical type!");
+#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 && "Should not see non-canonical or dependent types");
+ break;
+
case Type::FunctionNoProto:
case Type::FunctionProto:
- default:
+ case Type::IncompleteArray:
assert(0 && "Incomplete types have no size!");
case Type::VariableArray:
assert(0 && "VLAs not implemented yet!");
- case Type::DependentSizedArray:
- assert(0 && "Dependently-sized arrays don't have a known size");
case Type::ConstantArray: {
const ConstantArrayType *CAT = cast<ConstantArrayType>(T);
@@ -390,6 +395,7 @@ ASTContext::getTypeInfo(const Type *T) {
return getTypeInfo(QualType(cast<ExtQualType>(T)->getBaseType(), 0));
case Type::ObjCQualifiedId:
case Type::ObjCQualifiedClass:
+ case Type::ObjCQualifiedInterface:
Width = Target.getPointerWidth(0);
Align = Target.getPointerAlign(0);
break;
@@ -441,7 +447,9 @@ ASTContext::getTypeInfo(const Type *T) {
Align = Layout.getAlignment();
break;
}
- case Type::Tagged: {
+ case Type::Record:
+ case Type::CXXRecord:
+ case Type::Enum: {
const TagType *TT = cast<TagType>(T);
if (TT->getDecl()->isInvalidDecl()) {
@@ -1127,32 +1135,32 @@ QualType ASTContext::getExtVectorType(QualType vecType, unsigned NumElts) {
return QualType(New, 0);
}
-/// getFunctionTypeNoProto - Return a K&R style C function type like 'int()'.
+/// getFunctionNoProtoType - Return a K&R style C function type like 'int()'.
///
-QualType ASTContext::getFunctionTypeNoProto(QualType ResultTy) {
+QualType ASTContext::getFunctionNoProtoType(QualType ResultTy) {
// Unique functions, to guarantee there is only one function of a particular
// structure.
llvm::FoldingSetNodeID ID;
- FunctionTypeNoProto::Profile(ID, ResultTy);
+ FunctionNoProtoType::Profile(ID, ResultTy);
void *InsertPos = 0;
- if (FunctionTypeNoProto *FT =
- FunctionTypeNoProtos.FindNodeOrInsertPos(ID, InsertPos))
+ if (FunctionNoProtoType *FT =
+ FunctionNoProtoTypes.FindNodeOrInsertPos(ID, InsertPos))
return QualType(FT, 0);
QualType Canonical;
if (!ResultTy->isCanonical()) {
- Canonical = getFunctionTypeNoProto(getCanonicalType(ResultTy));
+ Canonical = getFunctionNoProtoType(getCanonicalType(ResultTy));
// Get the new insert position for the node we care about.
- FunctionTypeNoProto *NewIP =
- FunctionTypeNoProtos.FindNodeOrInsertPos(ID, InsertPos);
+ FunctionNoProtoType *NewIP =
+ FunctionNoProtoTypes.FindNodeOrInsertPos(ID, InsertPos);
assert(NewIP == 0 && "Shouldn't be in the map!"); NewIP = NewIP;
}
- FunctionTypeNoProto *New =new(*this,8)FunctionTypeNoProto(ResultTy,Canonical);
+ FunctionNoProtoType *New =new(*this,8)FunctionNoProtoType(ResultTy,Canonical);
Types.push_back(New);
- FunctionTypeNoProtos.InsertNode(New, InsertPos);
+ FunctionNoProtoTypes.InsertNode(New, InsertPos);
return QualType(New, 0);
}
@@ -1164,12 +1172,12 @@ QualType ASTContext::getFunctionType(QualType ResultTy,const QualType *ArgArray,
// Unique functions, to guarantee there is only one function of a particular
// structure.
llvm::FoldingSetNodeID ID;
- FunctionTypeProto::Profile(ID, ResultTy, ArgArray, NumArgs, isVariadic,
+ FunctionProtoType::Profile(ID, ResultTy, ArgArray, NumArgs, isVariadic,
TypeQuals);
void *InsertPos = 0;
- if (FunctionTypeProto *FTP =
- FunctionTypeProtos.FindNodeOrInsertPos(ID, InsertPos))
+ if (FunctionProtoType *FTP =
+ FunctionProtoTypes.FindNodeOrInsertPos(ID, InsertPos))
return QualType(FTP, 0);
// Determine whether the type being created is already canonical or not.
@@ -1191,20 +1199,20 @@ QualType ASTContext::getFunctionType(QualType ResultTy,const QualType *ArgArray,
isVariadic, TypeQuals);
// Get the new insert position for the node we care about.
- FunctionTypeProto *NewIP =
- FunctionTypeProtos.FindNodeOrInsertPos(ID, InsertPos);
+ FunctionProtoType *NewIP =
+ FunctionProtoTypes.FindNodeOrInsertPos(ID, InsertPos);
assert(NewIP == 0 && "Shouldn't be in the map!"); NewIP = NewIP;
}
- // FunctionTypeProto objects are allocated with extra bytes after them
+ // FunctionProtoType objects are allocated with extra bytes after them
// for a variable size array (for parameter types) at the end of them.
- FunctionTypeProto *FTP =
- (FunctionTypeProto*)Allocate(sizeof(FunctionTypeProto) +
+ FunctionProtoType *FTP =
+ (FunctionProtoType*)Allocate(sizeof(FunctionProtoType) +
NumArgs*sizeof(QualType), 8);
- new (FTP) FunctionTypeProto(ResultTy, ArgArray, NumArgs, isVariadic,
+ new (FTP) FunctionProtoType(ResultTy, ArgArray, NumArgs, isVariadic,
TypeQuals, Canonical);
Types.push_back(FTP);
- FunctionTypeProtos.InsertNode(FTP, InsertPos);
+ FunctionProtoTypes.InsertNode(FTP, InsertPos);
return QualType(FTP, 0);
}
@@ -1252,7 +1260,7 @@ QualType ASTContext::getTypedefType(TypedefDecl *Decl) {
if (Decl->TypeForDecl) return QualType(Decl->TypeForDecl, 0);
QualType Canonical = getCanonicalType(Decl->getUnderlyingType());
- Decl->TypeForDecl = new(*this,8) TypedefType(Type::TypeName, Decl, Canonical);
+ Decl->TypeForDecl = new(*this,8) TypedefType(Type::Typedef, Decl, Canonical);
Types.push_back(Decl->TypeForDecl);
return QualType(Decl->TypeForDecl, 0);
}
@@ -1401,14 +1409,14 @@ QualType ASTContext::getObjCQualifiedIdType(ObjCProtocolDecl **Protocols,
return QualType(QType, 0);
}
-/// getTypeOfExpr - Unlike many "get<Type>" functions, we can't unique
-/// TypeOfExpr AST's (since expression's are never shared). For example,
+/// getTypeOfExprType - Unlike many "get<Type>" functions, we can't unique
+/// TypeOfExprType AST's (since expression's are never shared). For example,
/// multiple declarations that refer to "typeof(x)" all contain different
/// DeclRefExpr's. This doesn't effect the type checker, since it operates
/// on canonical type's (which are always unique).
-QualType ASTContext::getTypeOfExpr(Expr *tofExpr) {
+QualType ASTContext::getTypeOfExprType(Expr *tofExpr) {
QualType Canonical = getCanonicalType(tofExpr->getType());
- TypeOfExpr *toe = new (*this,8) TypeOfExpr(tofExpr, Canonical);
+ TypeOfExprType *toe = new (*this,8) TypeOfExprType(tofExpr, Canonical);
Types.push_back(toe);
return QualType(toe, 0);
}
@@ -2458,8 +2466,8 @@ QualType::GCAttrTypes ASTContext::getObjCGCAttrKind(const QualType &Ty) const {
bool ASTContext::typesAreBlockCompatible(QualType lhs, QualType rhs) {
const FunctionType *lbase = lhs->getAsFunctionType();
const FunctionType *rbase = rhs->getAsFunctionType();
- const FunctionTypeProto *lproto = dyn_cast<FunctionTypeProto>(lbase);
- const FunctionTypeProto *rproto = dyn_cast<FunctionTypeProto>(rbase);
+ const FunctionProtoType *lproto = dyn_cast<FunctionProtoType>(lbase);
+ const FunctionProtoType *rproto = dyn_cast<FunctionProtoType>(rbase);
if (lproto && rproto)
return !mergeTypes(lhs, rhs).isNull();
return false;
@@ -2561,8 +2569,8 @@ bool ASTContext::typesAreCompatible(QualType LHS, QualType RHS) {
QualType ASTContext::mergeFunctionTypes(QualType lhs, QualType rhs) {
const FunctionType *lbase = lhs->getAsFunctionType();
const FunctionType *rbase = rhs->getAsFunctionType();
- const FunctionTypeProto *lproto = dyn_cast<FunctionTypeProto>(lbase);
- const FunctionTypeProto *rproto = dyn_cast<FunctionTypeProto>(rbase);
+ const FunctionProtoType *lproto = dyn_cast<FunctionProtoType>(lbase);
+ const FunctionProtoType *rproto = dyn_cast<FunctionProtoType>(rbase);
bool allLTypes = true;
bool allRTypes = true;
@@ -2611,7 +2619,7 @@ QualType ASTContext::mergeFunctionTypes(QualType lhs, QualType rhs) {
if (lproto) allRTypes = false;
if (rproto) allLTypes = false;
- const FunctionTypeProto *proto = lproto ? lproto : rproto;
+ const FunctionProtoType *proto = lproto ? lproto : rproto;
if (proto) {
if (proto->isVariadic()) return QualType();
// Check that the types are compatible with the types that
@@ -2636,7 +2644,7 @@ QualType ASTContext::mergeFunctionTypes(QualType lhs, QualType rhs) {
if (allLTypes) return lhs;
if (allRTypes) return rhs;
- return getFunctionTypeNoProto(retType);
+ return getFunctionNoProtoType(retType);
}
QualType ASTContext::mergeTypes(QualType LHS, QualType RHS) {
@@ -2739,6 +2747,27 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS) {
// The canonical type classes match.
switch (LHSClass) {
+#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 and dependent types shouldn't get here");
+ return QualType();
+
+ case Type::Reference:
+ case Type::MemberPointer:
+ assert(false && "C++ should never be in mergeTypes");
+ return QualType();
+
+ case Type::IncompleteArray:
+ case Type::VariableArray:
+ case Type::FunctionProto:
+ case Type::ExtVector:
+ case Type::ObjCQualifiedInterface:
+ assert(false && "Types are eliminated above");
+ return QualType();
+
case Type::Pointer:
{
// Merge two pointer types, while trying to preserve typedef info
@@ -2808,7 +2837,9 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS) {
}
case Type::FunctionNoProto:
return mergeFunctionTypes(LHS, RHS);
- case Type::Tagged:
+ case Type::Record:
+ case Type::CXXRecord:
+ case Type::Enum:
// FIXME: Why are these compatible?
if (isObjCIdStructType(LHS) && isObjCClassStructType(RHS)) return LHS;
if (isObjCClassStructType(LHS) && isObjCIdStructType(RHS)) return LHS;
@@ -2836,10 +2867,9 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS) {
case Type::ObjCQualifiedId:
// Distinct qualified id's are not compatible.
return QualType();
- default:
- assert(0 && "unexpected type");
- return QualType();
}
+
+ return QualType();
}
//===----------------------------------------------------------------------===//
diff --git a/clang/lib/AST/Builtins.cpp b/clang/lib/AST/Builtins.cpp
index b572e8e04b5..46b0346ca46 100644
--- a/clang/lib/AST/Builtins.cpp
+++ b/clang/lib/AST/Builtins.cpp
@@ -264,7 +264,7 @@ QualType Builtin::Context::GetBuiltinType(unsigned id, ASTContext &Context,
// handle untyped/variadic arguments "T c99Style();" or "T cppStyle(...);".
if (ArgTypes.size() == 0 && TypeStr[0] == '.')
- return Context.getFunctionTypeNoProto(ResType);
+ return Context.getFunctionNoProtoType(ResType);
return Context.getFunctionType(ResType, &ArgTypes[0], ArgTypes.size(),
TypeStr[0] == '.', 0);
}
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index ab654920238..b30b86980f6 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -320,9 +320,9 @@ unsigned FunctionDecl::getBuiltinID(ASTContext &Context) const {
// Helper function for FunctionDecl::getNumParams and FunctionDecl::setParams()
static unsigned getNumTypeParams(QualType T) {
const FunctionType *FT = T->getAsFunctionType();
- if (isa<FunctionTypeNoProto>(FT))
+ if (isa<FunctionNoProtoType>(FT))
return 0;
- return cast<FunctionTypeProto>(FT)->getNumArgs();
+ return cast<FunctionProtoType>(FT)->getNumArgs();
}
unsigned FunctionDecl::getNumParams() const {
diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 294e94f5f4e..b1394fe788b 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -92,8 +92,8 @@ bool CXXRecordDecl::hasConstCopyAssignment(ASTContext &Context) const {
if (Method->isStatic())
continue;
// TODO: Skip templates? Or is this implicitly done due to parameter types?
- const FunctionTypeProto *FnType =
- Method->getType()->getAsFunctionTypeProto();
+ const FunctionProtoType *FnType =
+ Method->getType()->getAsFunctionProtoType();
assert(FnType && "Overloaded operator has no prototype.");
// Don't assert on this; an invalid decl might have been left in the AST.
if (FnType->getNumArgs() != 1 || FnType->isVariadic())
@@ -146,7 +146,7 @@ void CXXRecordDecl::addedAssignmentOperator(ASTContext &Context,
// We're interested specifically in copy assignment operators.
// Unlike addedConstructor, this method is not called for implicit
// declarations.
- const FunctionTypeProto *FnType = OpDecl->getType()->getAsFunctionTypeProto();
+ const FunctionProtoType *FnType = OpDecl->getType()->getAsFunctionProtoType();
assert(FnType && "Overloaded operator has no proto function type.");
assert(FnType->getNumArgs() == 1 && !FnType->isVariadic());
QualType ArgType = FnType->getArgType(0);
@@ -290,7 +290,7 @@ bool CXXConstructorDecl::isConvertingConstructor() const {
return false;
return (getNumParams() == 0 &&
- getType()->getAsFunctionTypeProto()->isVariadic()) ||
+ getType()->getAsFunctionProtoType()->isVariadic()) ||
(getNumParams() == 1) ||
(getNumParams() > 1 && getParamDecl(1)->getDefaultArg() != 0);
}
diff --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp
index 1d563e246a0..4468c79e91b 100644
--- a/clang/lib/AST/StmtPrinter.cpp
+++ b/clang/lib/AST/StmtPrinter.cpp
@@ -1193,9 +1193,9 @@ void StmtPrinter::VisitBlockExpr(BlockExpr *Node) {
const FunctionType *AFT = Node->getFunctionType();
- if (isa<FunctionTypeNoProto>(AFT)) {
+ if (isa<FunctionNoProtoType>(AFT)) {
OS << "()";
- } else if (!BD->param_empty() || cast<FunctionTypeProto>(AFT)->isVariadic()) {
+ } else if (!BD->param_empty() || cast<FunctionProtoType>(AFT)->isVariadic()) {
OS << '(';
std::string ParamStr;
for (BlockDecl::param_iterator AI = BD->param_begin(),
@@ -1206,7 +1206,7 @@ void StmtPrinter::VisitBlockExpr(BlockExpr *Node) {
OS << ParamStr;
}
- const FunctionTypeProto *FT = cast<FunctionTypeProto>(AFT);
+ const FunctionProtoType *FT = cast<FunctionProtoType>(AFT);
if (FT->isVariadic()) {
if (!BD->param_empty()) OS << ", ";
OS << "...";
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 31565080633..06ae9eb4e25 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -78,7 +78,7 @@ const Type *Type::getArrayElementTypeNoTypeQual() const {
QualType Type::getDesugaredType() const {
if (const TypedefType *TDT = dyn_cast<TypedefType>(this))
return TDT->LookThroughTypedefs();
- if (const TypeOfExpr *TOE = dyn_cast<TypeOfExpr>(this))
+ if (const TypeOfExprType *TOE = dyn_cast<TypeOfExprType>(this))
return TOE->getUnderlyingExpr()->getType();
if (const TypeOfType *TOT = dyn_cast<TypeOfType>(this))
return TOT->getUnderlyingType();
@@ -118,9 +118,9 @@ bool Type::isDerivedType() const {
case FunctionProto:
case FunctionNoProto:
case Reference:
+ case Record:
+ case CXXRecord:
return true;
- case Tagged:
- return !cast<TagType>(CanonicalType)->getDecl()->isEnum();
default:
return false;
}
@@ -216,12 +216,12 @@ const FunctionType *Type::getAsFunctionType() const {
return getDesugaredType()->getAsFunctionType();
}
-const FunctionTypeNoProto *Type::getAsFunctionTypeNoProto() const {
- return dyn_cast_or_null<FunctionTypeNoProto>(getAsFunctionType());
+const FunctionNoProtoType *Type::getAsFunctionNoProtoType() const {
+ return dyn_cast_or_null<FunctionNoProtoType>(getAsFunctionType());
}
-const FunctionTypeProto *Type::getAsFunctionTypeProto() const {
- return dyn_cast_or_null<FunctionTypeProto>(getAsFunctionType());
+const FunctionProtoType *Type::getAsFunctionProtoType() const {
+ return dyn_cast_or_null<FunctionProtoType>(getAsFunctionType());
}
@@ -742,7 +742,9 @@ bool Type::isIncompleteType() const {
// Void is the only incomplete builtin type. Per C99 6.2.5p19, it can never
// be completed.
return isVoidType();
- case Tagged:
+ case Record:
+ case CXXRecord:
+ case Enum:
// A tagged type (struct/union/enum/class) is incomplete if the decl is a
// forward declaration, but not a full definition (C99 6.2.5p22).
return !cast<TagType>(CanonicalType)->getDecl()->isDefinition();
@@ -778,14 +780,15 @@ bool Type::isPODType() const {
case ObjCQualifiedId:
return true;
- case Tagged:
- if (isEnumeralType())
- return true;
- if (CXXRecordDecl *RDecl = dyn_cast<CXXRecordDecl>(
- cast<TagType>(CanonicalType)->getDecl()))
- return RDecl->isPOD();
+ case Enum:
+ return true;
+
+ case Record:
// C struct/union is POD.
return true;
+
+ case CXXRecord:
+ return cast<CXXRecordType>(CanonicalType)->getDecl()->isPOD();
}
}
@@ -832,7 +835,7 @@ const char *BuiltinType::getName() const {
}
}
-void FunctionTypeProto::Profile(llvm::FoldingSetNodeID &ID, QualType Result,
+void FunctionProtoType::Profile(llvm::FoldingSetNodeID &ID, QualType Result,
arg_type_iterator ArgTys,
unsigned NumArgs, bool isVariadic,
unsigned TypeQuals) {
@@ -843,7 +846,7 @@ void FunctionTypeProto::Profile(llvm::FoldingSetNodeID &ID, QualType Result,
ID.AddInteger(TypeQuals);
}
-void FunctionTypeProto::Profile(llvm::FoldingSetNodeID &ID) {
+void FunctionProtoType::Profile(llvm::FoldingSetNodeID &ID) {
Profile(ID, getResultType(), arg_type_begin(), NumArgs, isVariadic(),
getTypeQuals());
}
@@ -903,8 +906,8 @@ QualType TypedefType::LookThroughTypedefs() const {
}
}
-TypeOfExpr::TypeOfExpr(Expr *E, QualType can)
- : Type(TypeOfExp, can, E->isTypeDependent()), TOExpr(E) {
+TypeOfExprType::TypeOfExprType(Expr *E, QualType can)
+ : Type(TypeOfExpr, can, E->isTypeDependent()), TOExpr(E) {
assert(!isa<TypedefType>(can) && "Invalid canonical type");
}
@@ -1197,7 +1200,7 @@ void ExtVectorType::getAsStringInternal(std::string &S) const {
ElementType.getAsStringInternal(S);
}
-void TypeOfExpr::getAsStringInternal(std::string &InnerString) const {
+void TypeOfExprType::getAsStringInternal(std::string &InnerString) const {
if (!InnerString.empty()) // Prefix the basic type, e.g. 'typeof(e) X'.
InnerString = ' ' + InnerString;
std::string Str;
@@ -1214,7 +1217,7 @@ void TypeOfType::getAsStringInternal(std::string &InnerString) const {
InnerString = "typeof(" + Tmp + ")" + InnerString;
}
-void FunctionTypeNoProto::getAsStringInternal(std::string &S) const {
+void FunctionNoProtoType::getAsStringInternal(std::string &S) const {
// If needed for precedence reasons, wrap the inner part in grouping parens.
if (!S.empty())
S = "(" + S + ")";
@@ -1223,7 +1226,7 @@ void FunctionTypeNoProto::getAsStringInternal(std::string &S) const {
getResultType().getAsStringInternal(S);
}
-void FunctionTypeProto::getAsStringInternal(std::string &S) const {
+void FunctionProtoType::getAsStringInternal(std::string &S) const {
// If needed for precedence reasons, wrap the inner part in grouping parens.
if (!S.empty())
S = "(" + S + ")";
diff --git a/clang/lib/AST/TypeSerialization.cpp b/clang/lib/AST/TypeSerialization.cpp
index a8580b0e4df..2d052aa270f 100644
--- a/clang/lib/AST/TypeSerialization.cpp
+++ b/clang/lib/AST/TypeSerialization.cpp
@@ -84,11 +84,11 @@ void Type::Create(ASTContext& Context, unsigned i, Deserializer& D) {
break;
case Type::FunctionNoProto:
- D.RegisterPtr(PtrID,FunctionTypeNoProto::CreateImpl(Context,D));
+ D.RegisterPtr(PtrID,FunctionNoProtoType::CreateImpl(Context,D));
break;
case Type::FunctionProto:
- D.RegisterPtr(PtrID,FunctionTypeProto::CreateImpl(Context,D));
+ D.RegisterPtr(PtrID,FunctionProtoType::CreateImpl(Context,D));
break;
case Type::IncompleteArray:
@@ -111,19 +111,22 @@ void Type::Create(ASTContext& Context, unsigned i, Deserializer& D) {
D.RegisterPtr(PtrID, ReferenceType::CreateImpl(Context, D));
break;
- case Type::Tagged:
- D.RegisterPtr(PtrID, TagType::CreateImpl(Context, D));
+ case Type::Record:
+ case Type::CXXRecord:
+ case Type::Enum:
+ // FIXME: Implement this!
+ assert(false && "Can't deserialize tag types!");
break;
- case Type::TypeName:
+ case Type::Typedef:
D.RegisterPtr(PtrID, TypedefType::CreateImpl(Context, D));
break;
- case Type::TypeOfExp:
- D.RegisterPtr(PtrID, TypeOfExpr::CreateImpl(Context, D));
+ case Type::TypeOfExpr:
+ D.RegisterPtr(PtrID, TypeOfExprType::CreateImpl(Context, D));
break;
- case Type::TypeOfTyp:
+ case Type::TypeOf:
D.RegisterPtr(PtrID, TypeOfType::CreateImpl(Context, D));
break;
@@ -199,22 +202,22 @@ Type* ConstantArrayType::CreateImpl(ASTContext& Context, Deserializer& D) {
}
//===----------------------------------------------------------------------===//
-// FunctionTypeNoProto
+// FunctionNoProtoType
//===----------------------------------------------------------------------===//
-void FunctionTypeNoProto::EmitImpl(Serializer& S) const {
+void FunctionNoProtoType::EmitImpl(Serializer& S) const {
S.Emit(getResultType());
}
-Type* FunctionTypeNoProto::CreateImpl(ASTContext& Context, Deserializer& D) {
- return Context.getFunctionTypeNoProto(QualType::ReadVal(D)).getTypePtr();
+Type* FunctionNoProtoType::CreateImpl(ASTContext& Context, Deserializer& D) {
+ return Context.getFunctionNoProtoType(QualType::ReadVal(D)).getTypePtr();
}
//===----------------------------------------------------------------------===//
-// FunctionTypeProto
+// FunctionProtoType
//===----------------------------------------------------------------------===//
-void FunctionTypeProto::EmitImpl(Serializer& S) const {
+void FunctionProtoType::EmitImpl(Serializer& S) const {
S.Emit(getResultType());
S.EmitBool(isVariadic());
S.EmitInt(getTypeQuals());
@@ -224,7 +227,7 @@ void FunctionTypeProto::EmitImpl(Serializer& S) const {
S.Emit(*I);
}
-Type* FunctionTypeProto::CreateImpl(ASTContext& Context, Deserializer& D) {
+Type* FunctionProtoType::CreateImpl(ASTContext& Context, Deserializer& D) {
QualType ResultType = QualType::ReadVal(D);
bool isVariadic = D.ReadBool();
unsigned TypeQuals = D.ReadInt();
@@ -290,7 +293,9 @@ Type* TagType::CreateImpl(ASTContext& Context, Deserializer& D) {
std::vector<Type*>& Types =
const_cast<std::vector<Type*>&>(Context.getTypes());
- TagType* T = new TagType(NULL,QualType());
+ // FIXME: This is wrong: we need the subclasses to do the
+ // (de-)serialization.
+ TagType* T = new TagType(Record, NULL,QualType());
Types.push_back(T);
// Deserialize the decl.
@@ -313,7 +318,7 @@ Type* TypedefType::CreateImpl(ASTContext& Context, Deserializer& D) {
std::vector<Type*>& Types =
const_cast<std::vector<Type*>&>(Context.getTypes());
- TypedefType* T = new TypedefType(Type::TypeName, NULL, QualType::ReadVal(D));
+ TypedefType* T = new TypedefType(Type::Typedef, NULL, QualType::ReadVal(D));
Types.push_back(T);
D.ReadPtr(T->Decl); // May be backpatched.
@@ -321,20 +326,21 @@ Type* TypedefType::CreateImpl(ASTContext& Context, Deserializer& D) {
}
//===----------------------------------------------------------------------===//
-// TypeOfExpr
+// TypeOfExprType
//===----------------------------------------------------------------------===//
-void TypeOfExpr::EmitImpl(llvm::Serializer& S) const {
+void TypeOfExprType::EmitImpl(llvm::Serializer& S) const {
S.EmitOwnedPtr(TOExpr);
}
-Type* TypeOfExpr::CreateImpl(ASTContext& Context, Deserializer& D) {
+Type* TypeOfExprType::CreateImpl(ASTContext& Context, Deserializer& D) {
Expr* E = D.ReadOwnedPtr<Expr>(Context);
std::vector<Type*>& Types =
const_cast<std::vector<Type*>&>(Context.getTypes());
- TypeOfExpr* T = new TypeOfExpr(E, Context.getCanonicalType(E->getType()));
+ TypeOfExprType* T
+ = new TypeOfExprType(E, Context.getCanonicalType(E->getType()));
Types.push_back(T);
return T;
OpenPOWER on IntegriCloud