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
diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h
index 68e0ce8..22bfee4 100644
--- a/lib/Sema/Sema.h
+++ b/lib/Sema/Sema.h
@@ -458,7 +458,7 @@
Expr *From, QualType ToType,
OverloadCandidateSet& CandidateSet);
void AddSurrogateCandidate(CXXConversionDecl *Conversion,
- const FunctionTypeProto *Proto,
+ const FunctionProtoType *Proto,
Expr *Object, Expr **Args, unsigned NumArgs,
OverloadCandidateSet& CandidateSet);
bool AddOperatorCandidates(OverloadedOperatorKind Op, Scope *S,
@@ -1107,7 +1107,7 @@
IdentifierInfo &Member);
bool ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
FunctionDecl *FDecl,
- const FunctionTypeProto *Proto,
+ const FunctionProtoType *Proto,
Expr **Args, unsigned NumArgs,
SourceLocation RParenLoc);
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp
index fdd22fa..3e6bd5a 100644
--- a/lib/Sema/SemaChecking.cpp
+++ b/lib/Sema/SemaChecking.cpp
@@ -144,8 +144,8 @@
if (const FormatAttr *Format = FDecl->getAttr<FormatAttr>()) {
if (Format->getType() == "printf") {
bool HasVAListArg = false;
- if (const FunctionTypeProto *Proto
- = FDecl->getType()->getAsFunctionTypeProto())
+ if (const FunctionProtoType *Proto
+ = FDecl->getType()->getAsFunctionProtoType())
HasVAListArg = !Proto->isVariadic();
CheckPrintfArguments(TheCall, HasVAListArg, Format->getFormatIdx() - 1,
Format->getFirstArg() - 1);
@@ -210,8 +210,8 @@
// Determine whether the current function is variadic or not.
bool isVariadic;
if (getCurFunctionDecl()) {
- if (FunctionTypeProto* FTP =
- dyn_cast<FunctionTypeProto>(getCurFunctionDecl()->getType()))
+ if (FunctionProtoType* FTP =
+ dyn_cast<FunctionProtoType>(getCurFunctionDecl()->getType()))
isVariadic = FTP->isVariadic();
else
isVariadic = false;
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 0ad3839..b3f2500 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -340,7 +340,7 @@
// Create Decl objects for each parameter, adding them to the
// FunctionDecl.
- if (FunctionTypeProto *FT = dyn_cast<FunctionTypeProto>(R)) {
+ if (FunctionProtoType *FT = dyn_cast<FunctionProtoType>(R)) {
llvm::SmallVector<ParmVarDecl*, 16> Params;
for (unsigned i = 0, e = FT->getNumArgs(); i != e; ++i)
Params.push_back(ParmVarDecl::Create(Context, New, SourceLocation(), 0,
@@ -609,9 +609,9 @@
if (!getLangOptions().CPlusPlus &&
Context.typesAreCompatible(OldQType, NewQType)) {
const FunctionType *NewFuncType = NewQType->getAsFunctionType();
- const FunctionTypeProto *OldProto = 0;
- if (isa<FunctionTypeNoProto>(NewFuncType) &&
- (OldProto = OldQType->getAsFunctionTypeProto())) {
+ const FunctionProtoType *OldProto = 0;
+ if (isa<FunctionNoProtoType>(NewFuncType) &&
+ (OldProto = OldQType->getAsFunctionProtoType())) {
// The old declaration provided a function prototype, but the
// new declaration does not. Merge in the prototype.
llvm::SmallVector<QualType, 16> ParamTypes(OldProto->arg_type_begin(),
@@ -625,7 +625,7 @@
// Synthesize a parameter for each argument type.
llvm::SmallVector<ParmVarDecl*, 16> Params;
- for (FunctionTypeProto::arg_type_iterator
+ for (FunctionProtoType::arg_type_iterator
ParamType = OldProto->arg_type_begin(),
ParamEnd = OldProto->arg_type_end();
ParamType != ParamEnd; ++ParamType) {
@@ -1834,7 +1834,7 @@
// typedef void fn(int);
// fn f;
// @endcode
- const FunctionTypeProto *FT = R->getAsFunctionTypeProto();
+ const FunctionProtoType *FT = R->getAsFunctionProtoType();
if (!FT) {
// This is a typedef of a function with no prototype, so we
// don't need to do anything.
@@ -1845,7 +1845,7 @@
} else {
// Synthesize a parameter for each argument type.
llvm::SmallVector<ParmVarDecl*, 16> Params;
- for (FunctionTypeProto::arg_type_iterator ArgType = FT->arg_type_begin();
+ for (FunctionProtoType::arg_type_iterator ArgType = FT->arg_type_begin();
ArgType != FT->arg_type_end(); ++ArgType) {
ParmVarDecl *Param = ParmVarDecl::Create(Context, DC,
SourceLocation(), 0,
@@ -1900,7 +1900,7 @@
// Functions marked "overloadable" must have a prototype (that
// we can't get through declaration merging).
- if (!R->getAsFunctionTypeProto()) {
+ if (!R->getAsFunctionProtoType()) {
Diag(NewFD->getLocation(), diag::err_attribute_overloadable_no_prototype)
<< NewFD;
InvalidDecl = true;
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
index fb8b795..8757005 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -56,7 +56,7 @@
/// isFunctionOrMethod.
static bool hasFunctionProto(Decl *d) {
if (const FunctionType *FnTy = getFunctionType(d)) {
- return isa<FunctionTypeProto>(FnTy);
+ return isa<FunctionProtoType>(FnTy);
} else {
assert(isa<ObjCMethodDecl>(d));
return true;
@@ -68,20 +68,20 @@
/// hasFunctionProto first).
static unsigned getFunctionOrMethodNumArgs(Decl *d) {
if (const FunctionType *FnTy = getFunctionType(d))
- return cast<FunctionTypeProto>(FnTy)->getNumArgs();
+ return cast<FunctionProtoType>(FnTy)->getNumArgs();
return cast<ObjCMethodDecl>(d)->param_size();
}
static QualType getFunctionOrMethodArgType(Decl *d, unsigned Idx) {
if (const FunctionType *FnTy = getFunctionType(d))
- return cast<FunctionTypeProto>(FnTy)->getArgType(Idx);
+ return cast<FunctionProtoType>(FnTy)->getArgType(Idx);
return cast<ObjCMethodDecl>(d)->param_begin()[Idx]->getType();
}
static bool isFunctionOrMethodVariadic(Decl *d) {
if (const FunctionType *FnTy = getFunctionType(d)) {
- const FunctionTypeProto *proto = cast<FunctionTypeProto>(FnTy);
+ const FunctionProtoType *proto = cast<FunctionProtoType>(FnTy);
return proto->isVariadic();
} else {
return cast<ObjCMethodDecl>(d)->isVariadic();
@@ -688,7 +688,7 @@
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(d)) {
QualType FT = FD->getType();
- if (!FT->getAsFunctionTypeProto()->isVariadic()) {
+ if (!FT->getAsFunctionProtoType()->isVariadic()) {
S.Diag(Attr.getLoc(), diag::warn_attribute_sentinel_not_variadic);
return;
}
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index 8dd409b..1c98529 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -1077,7 +1077,7 @@
<< SourceRange(D.getDeclSpec().getTypeSpecTypeLoc())
<< SourceRange(D.getIdentifierLoc());
}
- if (R->getAsFunctionTypeProto()->getTypeQuals() != 0) {
+ if (R->getAsFunctionProtoType()->getTypeQuals() != 0) {
DeclaratorChunk::FunctionTypeInfo &FTI = D.getTypeObject(0).Fun;
if (FTI.TypeQuals & QualType::Const)
Diag(D.getIdentifierLoc(), diag::err_invalid_qualified_constructor)
@@ -1095,7 +1095,7 @@
// return type, since constructors don't have return types. We
// *always* have to do this, because GetTypeForDeclarator will
// put in a result type of "int" when none was specified.
- const FunctionTypeProto *Proto = R->getAsFunctionTypeProto();
+ const FunctionProtoType *Proto = R->getAsFunctionProtoType();
R = Context.getFunctionType(Context.VoidTy, Proto->arg_type_begin(),
Proto->getNumArgs(),
Proto->isVariadic(),
@@ -1187,7 +1187,7 @@
<< SourceRange(D.getDeclSpec().getTypeSpecTypeLoc())
<< SourceRange(D.getIdentifierLoc());
}
- if (R->getAsFunctionTypeProto()->getTypeQuals() != 0) {
+ if (R->getAsFunctionProtoType()->getTypeQuals() != 0) {
DeclaratorChunk::FunctionTypeInfo &FTI = D.getTypeObject(0).Fun;
if (FTI.TypeQuals & QualType::Const)
Diag(D.getIdentifierLoc(), diag::err_invalid_qualified_destructor)
@@ -1201,7 +1201,7 @@
}
// Make sure we don't have any parameters.
- if (R->getAsFunctionTypeProto()->getNumArgs() > 0) {
+ if (R->getAsFunctionProtoType()->getNumArgs() > 0) {
Diag(D.getIdentifierLoc(), diag::err_destructor_with_params);
// Delete the parameters.
@@ -1209,7 +1209,7 @@
}
// Make sure the destructor isn't variadic.
- if (R->getAsFunctionTypeProto()->isVariadic())
+ if (R->getAsFunctionProtoType()->isVariadic())
Diag(D.getIdentifierLoc(), diag::err_destructor_variadic);
// Rebuild the function type "R" without any type qualifiers or
@@ -1258,7 +1258,7 @@
}
// Make sure we don't have any parameters.
- if (R->getAsFunctionTypeProto()->getNumArgs() > 0) {
+ if (R->getAsFunctionProtoType()->getNumArgs() > 0) {
Diag(D.getIdentifierLoc(), diag::err_conv_function_with_params);
// Delete the parameters.
@@ -1266,7 +1266,7 @@
}
// Make sure the conversion function isn't variadic.
- if (R->getAsFunctionTypeProto()->isVariadic())
+ if (R->getAsFunctionProtoType()->isVariadic())
Diag(D.getIdentifierLoc(), diag::err_conv_function_variadic);
// C++ [class.conv.fct]p4:
@@ -1285,7 +1285,7 @@
// of the errors above fired) and with the conversion type as the
// return type.
R = Context.getFunctionType(ConvType, 0, 0, false,
- R->getAsFunctionTypeProto()->getTypeQuals());
+ R->getAsFunctionProtoType()->getTypeQuals());
// C++0x explicit conversion operators.
if (D.getDeclSpec().isExplicitSpecified() && !getLangOptions().CPlusPlus0x)
@@ -2122,7 +2122,7 @@
// Overloaded operators other than operator() cannot be variadic.
if (Op != OO_Call &&
- FnDecl->getType()->getAsFunctionTypeProto()->isVariadic()) {
+ FnDecl->getType()->getAsFunctionProtoType()->isVariadic()) {
return Diag(FnDecl->getLocation(), diag::err_operator_overload_variadic)
<< FnDecl->getDeclName();
}
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 01be6b2..29d5f59 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -887,8 +887,8 @@
// type.
QualType T = Func->getType();
QualType NoProtoType = T;
- if (const FunctionTypeProto *Proto = T->getAsFunctionTypeProto())
- NoProtoType = Context.getFunctionTypeNoProto(Proto->getResultType());
+ if (const FunctionProtoType *Proto = T->getAsFunctionProtoType())
+ NoProtoType = Context.getFunctionNoProtoType(Proto->getResultType());
return Owned(BuildDeclRefExpr(VD, NoProtoType, Loc, false, false, SS));
}
}
@@ -1949,7 +1949,7 @@
bool
Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
FunctionDecl *FDecl,
- const FunctionTypeProto *Proto,
+ const FunctionProtoType *Proto,
Expr **Args, unsigned NumArgs,
SourceLocation RParenLoc) {
// C99 6.5.2.2p7 - the arguments are implicitly converted, as if by
@@ -2164,12 +2164,12 @@
// We know the result type of the call, set it.
TheCall->setType(FuncT->getResultType().getNonReferenceType());
- if (const FunctionTypeProto *Proto = dyn_cast<FunctionTypeProto>(FuncT)) {
+ if (const FunctionProtoType *Proto = dyn_cast<FunctionProtoType>(FuncT)) {
if (ConvertArgumentsForCall(&*TheCall, Fn, FDecl, Proto, Args, NumArgs,
RParenLoc))
return ExprError();
} else {
- assert(isa<FunctionTypeNoProto>(FuncT) && "Unknown FunctionType!");
+ assert(isa<FunctionNoProtoType>(FuncT) && "Unknown FunctionType!");
// Promote the arguments (C99 6.5.2.2p6).
for (unsigned i = 0; i != NumArgs; i++) {
@@ -4501,7 +4501,7 @@
QualType BlockTy;
if (!BSI->hasPrototype)
- BlockTy = Context.getFunctionTypeNoProto(RetTy);
+ BlockTy = Context.getFunctionNoProtoType(RetTy);
else
BlockTy = Context.getFunctionType(RetTy, &ArgTypes[0], ArgTypes.size(),
BSI->isVariadic, 0);
diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp
index 7c5464a..00849a6 100644
--- a/lib/Sema/SemaLookup.cpp
+++ b/lib/Sema/SemaLookup.cpp
@@ -1269,12 +1269,12 @@
Context,
AssociatedNamespaces, AssociatedClasses);
- const FunctionTypeProto *Proto = dyn_cast<FunctionTypeProto>(FunctionType);
+ const FunctionProtoType *Proto = dyn_cast<FunctionProtoType>(FunctionType);
if (!Proto)
return;
// Argument types
- 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)
addAssociatedClassesAndNamespaces(*Arg, Context,
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index 5392af4..c33389e 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -310,12 +310,12 @@
// If either of these functions is a K&R-style function (no
// prototype), then we consider them to have matching signatures.
- if (isa<FunctionTypeNoProto>(OldQType.getTypePtr()) ||
- isa<FunctionTypeNoProto>(NewQType.getTypePtr()))
+ if (isa<FunctionNoProtoType>(OldQType.getTypePtr()) ||
+ isa<FunctionNoProtoType>(NewQType.getTypePtr()))
return false;
- FunctionTypeProto* OldType = cast<FunctionTypeProto>(OldQType.getTypePtr());
- FunctionTypeProto* NewType = cast<FunctionTypeProto>(NewQType.getTypePtr());
+ FunctionProtoType* OldType = cast<FunctionProtoType>(OldQType.getTypePtr());
+ FunctionProtoType* NewType = cast<FunctionProtoType>(NewQType.getTypePtr());
// The signature of a function includes the types of its
// parameters (C++ 1.3.10), which includes the presence or absence
@@ -1052,10 +1052,10 @@
// differences in the argument and result types are in Objective-C
// pointer conversions. If so, we permit the conversion (but
// complain about it).
- const FunctionTypeProto *FromFunctionType
- = FromPointeeType->getAsFunctionTypeProto();
- const FunctionTypeProto *ToFunctionType
- = ToPointeeType->getAsFunctionTypeProto();
+ const FunctionProtoType *FromFunctionType
+ = FromPointeeType->getAsFunctionProtoType();
+ const FunctionProtoType *ToFunctionType
+ = ToPointeeType->getAsFunctionProtoType();
if (FromFunctionType && ToFunctionType) {
// If the function types are exactly the same, this isn't an
// Objective-C pointer conversion.
@@ -1985,8 +1985,8 @@
OverloadCandidateSet& CandidateSet,
bool SuppressUserConversions)
{
- const FunctionTypeProto* Proto
- = dyn_cast<FunctionTypeProto>(Function->getType()->getAsFunctionType());
+ const FunctionProtoType* Proto
+ = dyn_cast<FunctionProtoType>(Function->getType()->getAsFunctionType());
assert(Proto && "Functions without a prototype cannot be overloaded");
assert(!isa<CXXConversionDecl>(Function) &&
"Use AddConversionCandidate for conversion functions");
@@ -2075,8 +2075,8 @@
OverloadCandidateSet& CandidateSet,
bool SuppressUserConversions)
{
- const FunctionTypeProto* Proto
- = dyn_cast<FunctionTypeProto>(Method->getType()->getAsFunctionType());
+ const FunctionProtoType* Proto
+ = dyn_cast<FunctionProtoType>(Method->getType()->getAsFunctionType());
assert(Proto && "Methods without a prototype cannot be overloaded");
assert(!isa<CXXConversionDecl>(Method) &&
"Use AddConversionCandidate for conversion functions");
@@ -2228,7 +2228,7 @@
/// with the given arguments (C++ [over.call.object]p2-4). Proto is
/// the type of function that we'll eventually be calling.
void Sema::AddSurrogateCandidate(CXXConversionDecl *Conversion,
- const FunctionTypeProto *Proto,
+ const FunctionProtoType *Proto,
Expr *Object, Expr **Args, unsigned NumArgs,
OverloadCandidateSet& CandidateSet) {
CandidateSet.push_back(OverloadCandidate());
@@ -2318,7 +2318,7 @@
if (T1->isRecordType() || (!T2.isNull() && T2->isRecordType()))
return true;
- const FunctionTypeProto *Proto = Fn->getType()->getAsFunctionTypeProto();
+ const FunctionProtoType *Proto = Fn->getType()->getAsFunctionProtoType();
if (Proto->getNumArgs() < 1)
return false;
@@ -3773,7 +3773,7 @@
MemExpr->setBase(ObjectArg);
// Convert the rest of the arguments
- const FunctionTypeProto *Proto = cast<FunctionTypeProto>(Method->getType());
+ const FunctionProtoType *Proto = cast<FunctionProtoType>(Method->getType());
if (ConvertArgumentsForCall(&*TheCall, MemExpr, Method, Proto, Args, NumArgs,
RParenLoc))
return true;
@@ -3842,7 +3842,7 @@
if (const PointerType *ConvPtrType = ConvType->getAsPointerType())
ConvType = ConvPtrType->getPointeeType();
- if (const FunctionTypeProto *Proto = ConvType->getAsFunctionTypeProto())
+ if (const FunctionProtoType *Proto = ConvType->getAsFunctionProtoType())
AddSurrogateCandidate(Conv, Proto, Object, Args, NumArgs, CandidateSet);
}
@@ -3909,7 +3909,7 @@
// that calls this method, using Object for the implicit object
// parameter and passing along the remaining arguments.
CXXMethodDecl *Method = cast<CXXMethodDecl>(Best->Function);
- const FunctionTypeProto *Proto = Method->getType()->getAsFunctionTypeProto();
+ const FunctionProtoType *Proto = Method->getType()->getAsFunctionProtoType();
unsigned NumArgsInProto = Proto->getNumArgs();
unsigned NumArgsToCheck = NumArgs;
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index 47cf8e5..d1dcca6 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -172,7 +172,7 @@
Expr *E = static_cast<Expr *>(DS.getTypeRep());
assert(E && "Didn't get an expression for typeof?");
// TypeQuals handled by caller.
- Result = Context.getTypeOfExpr(E);
+ Result = Context.getTypeOfExprType(E);
break;
}
case DeclSpec::TST_error:
@@ -505,7 +505,7 @@
T = Context.getFunctionType(T, NULL, 0, FTI.isVariadic, 0);
} else {
// Simple void foo(), where the incoming T is the result type.
- T = Context.getFunctionTypeNoProto(T);
+ T = Context.getFunctionNoProtoType(T);
}
} else if (FTI.ArgInfo[0].Param == 0) {
// C99 6.7.5.3p3: Reject int(x,y,z) when it's not a function definition.
@@ -540,7 +540,7 @@
// Look for 'void'. void is allowed only as a single argument to a
// function with no other parameters (C99 6.7.5.3p10). We record
- // int(void) as a FunctionTypeProto with an empty argument list.
+ // int(void) as a FunctionProtoType with an empty argument list.
else if (ArgTy->isVoidType()) {
// If this is something like 'float(int, void)', reject it. 'void'
// is an incomplete type (C99 6.2.5p19) and function decls cannot
@@ -634,8 +634,8 @@
}
if (getLangOptions().CPlusPlus && T->isFunctionType()) {
- const FunctionTypeProto *FnTy = T->getAsFunctionTypeProto();
- assert(FnTy && "Why oh why is there not a FunctionTypeProto here ?");
+ const FunctionProtoType *FnTy = T->getAsFunctionProtoType();
+ assert(FnTy && "Why oh why is there not a FunctionProtoType here ?");
// C++ 8.3.5p4: A cv-qualifier-seq shall only be part of the function type
// for a nonstatic member function, the function type to which a pointer