[cfe-commits] r121763 - in /cfe/trunk: include/clang/AST/ include/clang/Sema/ lib/AST/ lib/CodeGen/ lib/Rewrite/ lib/Sema/ lib/Serialization/
John McCall
rjmccall at apple.com
Tue Dec 14 00:05:41 PST 2010
Author: rjmccall
Date: Tue Dec 14 02:05:40 2010
New Revision: 121763
URL: http://llvm.org/viewvc/llvm-project?rev=121763&view=rev
Log:
Restore r121752 without modification.
Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/ExprCXX.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/Rewrite/RewriteObjC.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=121763&r1=121762&r2=121763&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Tue Dec 14 02:05:40 2010
@@ -626,14 +626,11 @@
return getFunctionNoProtoType(ResultTy, FunctionType::ExtInfo());
}
- /// getFunctionType - Return a normal function type with a typed argument
- /// list. isVariadic indicates whether the argument list includes '...'.
- QualType getFunctionType(QualType ResultTy, const QualType *ArgArray,
- unsigned NumArgs, bool isVariadic,
- unsigned TypeQuals, bool hasExceptionSpec,
- bool hasAnyExceptionSpec,
- unsigned NumExs, const QualType *ExArray,
- const FunctionType::ExtInfo &Info);
+ /// getFunctionType - Return a normal function type with a typed
+ /// argument list.
+ QualType getFunctionType(QualType ResultTy,
+ const QualType *Args, unsigned NumArgs,
+ const FunctionProtoType::ExtProtoInfo &EPI);
/// getTypeDeclType - Return the unique reference to the type for
/// the specified type declaration.
Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=121763&r1=121762&r2=121763&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Tue Dec 14 02:05:40 2010
@@ -1278,22 +1278,7 @@
TypeSourceInfo *ScopeType,
SourceLocation ColonColonLoc,
SourceLocation TildeLoc,
- PseudoDestructorTypeStorage DestroyedType)
- : Expr(CXXPseudoDestructorExprClass,
- Context.getPointerType(Context.getFunctionType(Context.VoidTy, 0, 0,
- false, 0, false,
- false, 0, 0,
- FunctionType::ExtInfo())),
- VK_RValue, OK_Ordinary,
- /*isTypeDependent=*/(Base->isTypeDependent() ||
- (DestroyedType.getTypeSourceInfo() &&
- DestroyedType.getTypeSourceInfo()->getType()->isDependentType())),
- /*isValueDependent=*/Base->isValueDependent()),
- Base(static_cast<Stmt *>(Base)), IsArrow(isArrow),
- OperatorLoc(OperatorLoc), Qualifier(Qualifier),
- QualifierRange(QualifierRange),
- ScopeType(ScopeType), ColonColonLoc(ColonColonLoc), TildeLoc(TildeLoc),
- DestroyedType(DestroyedType) { }
+ PseudoDestructorTypeStorage DestroyedType);
explicit CXXPseudoDestructorExpr(EmptyShell Shell)
: Expr(CXXPseudoDestructorExprClass, Shell),
Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=121763&r1=121762&r2=121763&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Tue Dec 14 02:05:40 2010
@@ -925,8 +925,8 @@
/// regparm and the calling convention.
unsigned ExtInfo : 8;
- /// A bit to be used by the subclass.
- unsigned SubclassInfo : 1;
+ /// Whether the function is variadic. Only used by FunctionProtoType.
+ unsigned Variadic : 1;
/// TypeQuals - Used only by FunctionProtoType, put here to pack with the
/// other bitfields.
@@ -2196,13 +2196,13 @@
return ExtInfo((Bits & ~CallConvMask) | (unsigned) cc);
}
- void Profile(llvm::FoldingSetNodeID &ID) {
+ void Profile(llvm::FoldingSetNodeID &ID) const {
ID.AddInteger(Bits);
}
};
protected:
- FunctionType(TypeClass tc, QualType res, bool SubclassInfo,
+ FunctionType(TypeClass tc, QualType res, bool variadic,
unsigned typeQuals, QualType Canonical, bool Dependent,
bool VariablyModified, bool ContainsUnexpandedParameterPack,
ExtInfo Info)
@@ -2210,10 +2210,10 @@
ContainsUnexpandedParameterPack),
ResultType(res) {
FunctionTypeBits.ExtInfo = Info.Bits;
- FunctionTypeBits.SubclassInfo = SubclassInfo;
+ FunctionTypeBits.Variadic = variadic;
FunctionTypeBits.TypeQuals = typeQuals;
}
- bool getSubClassData() const { return FunctionTypeBits.SubclassInfo; }
+ bool isVariadic() const { return FunctionTypeBits.Variadic; }
unsigned getTypeQuals() const { return FunctionTypeBits.TypeQuals; }
public:
@@ -2276,6 +2276,23 @@
/// exception specification, but this specification is not part of the canonical
/// type.
class FunctionProtoType : public FunctionType, public llvm::FoldingSetNode {
+public:
+ /// ExtProtoInfo - Extra information about a function prototype.
+ struct ExtProtoInfo {
+ ExtProtoInfo() :
+ Variadic(false), HasExceptionSpec(false), HasAnyExceptionSpec(false),
+ TypeQuals(0), NumExceptions(0), Exceptions(0) {}
+
+ FunctionType::ExtInfo ExtInfo;
+ bool Variadic;
+ bool HasExceptionSpec;
+ bool HasAnyExceptionSpec;
+ unsigned char TypeQuals;
+ unsigned NumExceptions;
+ const QualType *Exceptions;
+ };
+
+private:
/// \brief Determine whether there are any argument types that
/// contain an unexpanded parameter pack.
static bool containsAnyUnexpandedParameterPack(const QualType *ArgArray,
@@ -2287,11 +2304,8 @@
return false;
}
- FunctionProtoType(QualType Result, const QualType *ArgArray, unsigned numArgs,
- bool isVariadic, unsigned typeQuals, bool hasExs,
- bool hasAnyExs, const QualType *ExArray,
- unsigned numExs, QualType Canonical,
- const ExtInfo &Info);
+ FunctionProtoType(QualType result, const QualType *args, unsigned numArgs,
+ QualType canonical, const ExtProtoInfo &epi);
/// NumArgs - The number of arguments this function has, not counting '...'.
unsigned NumArgs : 20;
@@ -2302,8 +2316,8 @@
/// HasExceptionSpec - Whether this function has an exception spec at all.
unsigned HasExceptionSpec : 1;
- /// AnyExceptionSpec - Whether this function has a throw(...) spec.
- unsigned AnyExceptionSpec : 1;
+ /// HasAnyExceptionSpec - Whether this function has a throw(...) spec.
+ unsigned HasAnyExceptionSpec : 1;
/// ArgInfo - There is an variable size array after the class in memory that
/// holds the argument types.
@@ -2320,8 +2334,20 @@
return arg_type_begin()[i];
}
+ ExtProtoInfo getExtProtoInfo() const {
+ ExtProtoInfo EPI;
+ EPI.ExtInfo = getExtInfo();
+ EPI.Variadic = isVariadic();
+ EPI.HasExceptionSpec = hasExceptionSpec();
+ EPI.HasAnyExceptionSpec = hasAnyExceptionSpec();
+ EPI.TypeQuals = static_cast<unsigned char>(getTypeQuals());
+ EPI.NumExceptions = NumExceptions;
+ EPI.Exceptions = exception_begin();
+ return EPI;
+ }
+
bool hasExceptionSpec() const { return HasExceptionSpec; }
- bool hasAnyExceptionSpec() const { return AnyExceptionSpec; }
+ bool hasAnyExceptionSpec() const { return HasAnyExceptionSpec; }
unsigned getNumExceptions() const { return NumExceptions; }
QualType getExceptionType(unsigned i) const {
assert(i < NumExceptions && "Invalid exception number!");
@@ -2332,7 +2358,7 @@
getNumExceptions() == 0;
}
- bool isVariadic() const { return getSubClassData(); }
+ using FunctionType::isVariadic;
unsigned getTypeQuals() const { return FunctionType::getTypeQuals(); }
typedef const QualType *arg_type_iterator;
@@ -2361,10 +2387,7 @@
void Profile(llvm::FoldingSetNodeID &ID);
static void Profile(llvm::FoldingSetNodeID &ID, QualType Result,
arg_type_iterator ArgTys, unsigned NumArgs,
- bool isVariadic, unsigned TypeQuals,
- bool hasExceptionSpec, bool anyExceptionSpec,
- unsigned NumExceptions, exception_iterator Exs,
- ExtInfo ExtInfo);
+ const ExtProtoInfo &EPI);
};
Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=121763&r1=121762&r2=121763&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Dec 14 02:05:40 2010
@@ -615,7 +615,7 @@
QualType *ParamTypes, unsigned NumParamTypes,
bool Variadic, unsigned Quals,
SourceLocation Loc, DeclarationName Entity,
- const FunctionType::ExtInfo &Info);
+ FunctionType::ExtInfo Info);
QualType BuildMemberPointerType(QualType T, QualType Class,
SourceLocation Loc,
DeclarationName Entity);
Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=121763&r1=121762&r2=121763&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Tue Dec 14 02:05:40 2010
@@ -1141,7 +1141,7 @@
}
static QualType getExtFunctionType(ASTContext& Context, QualType T,
- const FunctionType::ExtInfo &Info) {
+ const FunctionType::ExtInfo &Info) {
QualType ResultType;
if (const PointerType *Pointer = T->getAs<PointerType>()) {
QualType Pointee = Pointer->getPointeeType();
@@ -1183,15 +1183,11 @@
Info);
} else {
const FunctionProtoType *FPT = cast<FunctionProtoType>(F);
- ResultType
- = Context.getFunctionType(FPT->getResultType(), FPT->arg_type_begin(),
- FPT->getNumArgs(), FPT->isVariadic(),
- FPT->getTypeQuals(),
- FPT->hasExceptionSpec(),
- FPT->hasAnyExceptionSpec(),
- FPT->getNumExceptions(),
- FPT->exception_begin(),
- Info);
+ FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo();
+ EPI.ExtInfo = Info;
+ ResultType = Context.getFunctionType(FPT->getResultType(),
+ FPT->arg_type_begin(),
+ FPT->getNumArgs(), EPI);
}
} else
return T;
@@ -1201,20 +1197,17 @@
QualType ASTContext::getNoReturnType(QualType T, bool AddNoReturn) {
FunctionType::ExtInfo Info = getFunctionExtInfo(T);
- return getExtFunctionType(*this, T,
- Info.withNoReturn(AddNoReturn));
+ return getExtFunctionType(*this, T, Info.withNoReturn(AddNoReturn));
}
QualType ASTContext::getCallConvType(QualType T, CallingConv CallConv) {
FunctionType::ExtInfo Info = getFunctionExtInfo(T);
- return getExtFunctionType(*this, T,
- Info.withCallingConv(CallConv));
+ return getExtFunctionType(*this, T, Info.withCallingConv(CallConv));
}
QualType ASTContext::getRegParmType(QualType T, unsigned RegParm) {
FunctionType::ExtInfo Info = getFunctionExtInfo(T);
- return getExtFunctionType(*this, T,
- Info.withRegParm(RegParm));
+ return getExtFunctionType(*this, T, Info.withRegParm(RegParm));
}
/// getComplexType - Return the uniqued reference to the type for a complex
@@ -1763,20 +1756,13 @@
/// getFunctionType - Return a normal function type with a typed argument
/// list. isVariadic indicates whether the argument list includes '...'.
-QualType ASTContext::getFunctionType(QualType ResultTy,const QualType *ArgArray,
- unsigned NumArgs, bool isVariadic,
- unsigned TypeQuals, bool hasExceptionSpec,
- bool hasAnyExceptionSpec, unsigned NumExs,
- const QualType *ExArray,
- const FunctionType::ExtInfo &Info) {
-
- const CallingConv CallConv= Info.getCC();
+QualType ASTContext::getFunctionType(QualType ResultTy,
+ const QualType *ArgArray, unsigned NumArgs,
+ const FunctionProtoType::ExtProtoInfo &EPI) {
// Unique functions, to guarantee there is only one function of a particular
// structure.
llvm::FoldingSetNodeID ID;
- FunctionProtoType::Profile(ID, ResultTy, ArgArray, NumArgs, isVariadic,
- TypeQuals, hasExceptionSpec, hasAnyExceptionSpec,
- NumExs, ExArray, Info);
+ FunctionProtoType::Profile(ID, ResultTy, ArgArray, NumArgs, EPI);
void *InsertPos = 0;
if (FunctionProtoType *FTP =
@@ -1784,11 +1770,13 @@
return QualType(FTP, 0);
// Determine whether the type being created is already canonical or not.
- bool isCanonical = !hasExceptionSpec && ResultTy.isCanonical();
+ bool isCanonical = !EPI.HasExceptionSpec && ResultTy.isCanonical();
for (unsigned i = 0; i != NumArgs && isCanonical; ++i)
if (!ArgArray[i].isCanonicalAsParam())
isCanonical = false;
+ const CallingConv CallConv = EPI.ExtInfo.getCC();
+
// If this type isn't canonical, get the canonical version of it.
// The exception spec is not part of the canonical type.
QualType Canonical;
@@ -1798,11 +1786,18 @@
for (unsigned i = 0; i != NumArgs; ++i)
CanonicalArgs.push_back(getCanonicalParamType(ArgArray[i]));
+ FunctionProtoType::ExtProtoInfo CanonicalEPI = EPI;
+ if (CanonicalEPI.HasExceptionSpec) {
+ CanonicalEPI.HasExceptionSpec = false;
+ CanonicalEPI.HasAnyExceptionSpec = false;
+ CanonicalEPI.NumExceptions = 0;
+ }
+ CanonicalEPI.ExtInfo
+ = CanonicalEPI.ExtInfo.withCallingConv(getCanonicalCallConv(CallConv));
+
Canonical = getFunctionType(getCanonicalType(ResultTy),
CanonicalArgs.data(), NumArgs,
- isVariadic, TypeQuals, false,
- false, 0, 0,
- Info.withCallingConv(getCanonicalCallConv(CallConv)));
+ CanonicalEPI);
// Get the new insert position for the node we care about.
FunctionProtoType *NewIP =
@@ -1813,13 +1808,11 @@
// FunctionProtoType objects are allocated with extra bytes after them
// for two variable size arrays (for parameter and exception types) at the
// end of them.
- FunctionProtoType *FTP =
- (FunctionProtoType*)Allocate(sizeof(FunctionProtoType) +
- NumArgs*sizeof(QualType) +
- NumExs*sizeof(QualType), TypeAlignment);
- new (FTP) FunctionProtoType(ResultTy, ArgArray, NumArgs, isVariadic,
- TypeQuals, hasExceptionSpec, hasAnyExceptionSpec,
- ExArray, NumExs, Canonical, Info);
+ size_t Size = sizeof(FunctionProtoType) +
+ NumArgs * sizeof(QualType) +
+ EPI.NumExceptions * sizeof(QualType);
+ FunctionProtoType *FTP = (FunctionProtoType*) Allocate(Size, TypeAlignment);
+ new (FTP) FunctionProtoType(ResultTy, ArgArray, NumArgs, Canonical, EPI);
Types.push_back(FTP);
FunctionProtoTypes.InsertNode(FTP, InsertPos);
return QualType(FTP, 0);
@@ -4852,6 +4845,8 @@
if (!isSameCallConv(lcc, rcc))
return QualType();
+ FunctionType::ExtInfo einfo = FunctionType::ExtInfo(NoReturn, RegParm, lcc);
+
if (lproto && rproto) { // two C99 style function prototypes
assert(!lproto->hasExceptionSpec() && !rproto->hasExceptionSpec() &&
"C++ shouldn't be here");
@@ -4895,10 +4890,10 @@
}
if (allLTypes) return lhs;
if (allRTypes) return rhs;
- return getFunctionType(retType, types.begin(), types.size(),
- lproto->isVariadic(), lproto->getTypeQuals(),
- false, false, 0, 0,
- FunctionType::ExtInfo(NoReturn, RegParm, lcc));
+
+ FunctionProtoType::ExtProtoInfo EPI = lproto->getExtProtoInfo();
+ EPI.ExtInfo = einfo;
+ return getFunctionType(retType, types.begin(), types.size(), EPI);
}
if (lproto) allRTypes = false;
@@ -4929,11 +4924,11 @@
if (allLTypes) return lhs;
if (allRTypes) return rhs;
+
+ FunctionProtoType::ExtProtoInfo EPI = proto->getExtProtoInfo();
+ EPI.ExtInfo = einfo;
return getFunctionType(retType, proto->arg_type_begin(),
- proto->getNumArgs(), proto->isVariadic(),
- proto->getTypeQuals(),
- false, false, 0, 0,
- FunctionType::ExtInfo(NoReturn, RegParm, lcc));
+ proto->getNumArgs(), EPI);
}
if (allLTypes) return lhs;
@@ -5218,16 +5213,11 @@
// In either case, use OldReturnType to build the new function type.
const FunctionType *F = LHS->getAs<FunctionType>();
if (const FunctionProtoType *FPT = cast<FunctionProtoType>(F)) {
- FunctionType::ExtInfo Info = getFunctionExtInfo(LHS);
+ FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo();
+ EPI.ExtInfo = getFunctionExtInfo(LHS);
QualType ResultType
= getFunctionType(OldReturnType, FPT->arg_type_begin(),
- FPT->getNumArgs(), FPT->isVariadic(),
- FPT->getTypeQuals(),
- FPT->hasExceptionSpec(),
- FPT->hasAnyExceptionSpec(),
- FPT->getNumExceptions(),
- FPT->exception_begin(),
- Info);
+ FPT->getNumArgs(), EPI);
return ResultType;
}
}
@@ -5580,10 +5570,11 @@
if (ArgTypes.size() == 0 && TypeStr[0] == '.')
return getFunctionNoProtoType(ResType);
+ FunctionProtoType::ExtProtoInfo EPI;
+ EPI.Variadic = (TypeStr[0] == '.');
// FIXME: Should we create noreturn types?
- return getFunctionType(ResType, ArgTypes.data(), ArgTypes.size(),
- TypeStr[0] == '.', 0, false, false, 0, 0,
- FunctionType::ExtInfo());
+
+ return getFunctionType(ResType, ArgTypes.data(), ArgTypes.size(), EPI);
}
GVALinkage ASTContext::GetGVALinkageForFunction(const FunctionDecl *FD) {
Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=121763&r1=121762&r2=121763&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Tue Dec 14 02:05:40 2010
@@ -1473,16 +1473,12 @@
return QualType();
ExceptionTypes.push_back(ExceptionType);
}
+
+ FunctionProtoType::ExtProtoInfo EPI = T->getExtProtoInfo();
+ EPI.Exceptions = ExceptionTypes.data();
return Importer.getToContext().getFunctionType(ToResultType, ArgTypes.data(),
- ArgTypes.size(),
- T->isVariadic(),
- T->getTypeQuals(),
- T->hasExceptionSpec(),
- T->hasAnyExceptionSpec(),
- ExceptionTypes.size(),
- ExceptionTypes.data(),
- T->getExtInfo());
+ ArgTypes.size(), EPI);
}
QualType ASTNodeImporter::VisitTypedefType(TypedefType *T) {
Modified: cfe/trunk/lib/AST/ExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCXX.cpp?rev=121763&r1=121762&r2=121763&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprCXX.cpp (original)
+++ cfe/trunk/lib/AST/ExprCXX.cpp Tue Dec 14 02:05:40 2010
@@ -185,6 +185,25 @@
Location = Info->getTypeLoc().getLocalSourceRange().getBegin();
}
+CXXPseudoDestructorExpr::CXXPseudoDestructorExpr(ASTContext &Context,
+ Expr *Base, bool isArrow, SourceLocation OperatorLoc,
+ NestedNameSpecifier *Qualifier, SourceRange QualifierRange,
+ TypeSourceInfo *ScopeType, SourceLocation ColonColonLoc,
+ SourceLocation TildeLoc, PseudoDestructorTypeStorage DestroyedType)
+ : Expr(CXXPseudoDestructorExprClass,
+ Context.getPointerType(Context.getFunctionType(Context.VoidTy, 0, 0,
+ FunctionProtoType::ExtProtoInfo())),
+ VK_RValue, OK_Ordinary,
+ /*isTypeDependent=*/(Base->isTypeDependent() ||
+ (DestroyedType.getTypeSourceInfo() &&
+ DestroyedType.getTypeSourceInfo()->getType()->isDependentType())),
+ /*isValueDependent=*/Base->isValueDependent()),
+ Base(static_cast<Stmt *>(Base)), IsArrow(isArrow),
+ OperatorLoc(OperatorLoc), Qualifier(Qualifier),
+ QualifierRange(QualifierRange),
+ ScopeType(ScopeType), ColonColonLoc(ColonColonLoc), TildeLoc(TildeLoc),
+ DestroyedType(DestroyedType) { }
+
QualType CXXPseudoDestructorExpr::getDestroyedType() const {
if (TypeSourceInfo *TInfo = DestroyedType.getTypeSourceInfo())
return TInfo->getType();
Modified: cfe/trunk/lib/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=121763&r1=121762&r2=121763&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Tue Dec 14 02:05:40 2010
@@ -1097,65 +1097,55 @@
return "";
}
-FunctionProtoType::FunctionProtoType(QualType Result, const QualType *ArgArray,
- unsigned numArgs, bool isVariadic,
- unsigned typeQuals, bool hasExs,
- bool hasAnyExs, const QualType *ExArray,
- unsigned numExs, QualType Canonical,
- const ExtInfo &Info)
- : FunctionType(FunctionProto, Result, isVariadic, typeQuals, Canonical,
- Result->isDependentType(),
- Result->isVariablyModifiedType(),
- Result->containsUnexpandedParameterPack(),
- Info),
- NumArgs(numArgs), NumExceptions(numExs), HasExceptionSpec(hasExs),
- AnyExceptionSpec(hasAnyExs)
+FunctionProtoType::FunctionProtoType(QualType result, const QualType *args,
+ unsigned numArgs, QualType canonical,
+ const ExtProtoInfo &epi)
+ : FunctionType(FunctionProto, result, epi.Variadic, epi.TypeQuals, canonical,
+ result->isDependentType(),
+ result->isVariablyModifiedType(),
+ result->containsUnexpandedParameterPack(),
+ epi.ExtInfo),
+ NumArgs(numArgs), NumExceptions(epi.NumExceptions),
+ HasExceptionSpec(epi.HasExceptionSpec),
+ HasAnyExceptionSpec(epi.HasAnyExceptionSpec)
{
// Fill in the trailing argument array.
- QualType *ArgInfo = reinterpret_cast<QualType*>(this+1);
+ QualType *argSlot = reinterpret_cast<QualType*>(this+1);
for (unsigned i = 0; i != numArgs; ++i) {
- if (ArgArray[i]->isDependentType())
+ if (args[i]->isDependentType())
setDependent();
- if (ArgArray[i]->containsUnexpandedParameterPack())
+ if (args[i]->containsUnexpandedParameterPack())
setContainsUnexpandedParameterPack();
- ArgInfo[i] = ArgArray[i];
+ argSlot[i] = args[i];
}
// Fill in the exception array.
- QualType *Ex = ArgInfo + numArgs;
- for (unsigned i = 0; i != numExs; ++i)
- Ex[i] = ExArray[i];
+ QualType *exnSlot = argSlot + numArgs;
+ for (unsigned i = 0, e = epi.NumExceptions; i != e; ++i)
+ exnSlot[i] = epi.Exceptions[i];
}
void FunctionProtoType::Profile(llvm::FoldingSetNodeID &ID, QualType Result,
- arg_type_iterator ArgTys,
- unsigned NumArgs, bool isVariadic,
- unsigned TypeQuals, bool hasExceptionSpec,
- bool anyExceptionSpec, unsigned NumExceptions,
- exception_iterator Exs,
- FunctionType::ExtInfo Info) {
+ const QualType *ArgTys, unsigned NumArgs,
+ const ExtProtoInfo &epi) {
ID.AddPointer(Result.getAsOpaquePtr());
for (unsigned i = 0; i != NumArgs; ++i)
ID.AddPointer(ArgTys[i].getAsOpaquePtr());
- ID.AddInteger(isVariadic);
- ID.AddInteger(TypeQuals);
- ID.AddInteger(hasExceptionSpec);
- if (hasExceptionSpec) {
- ID.AddInteger(anyExceptionSpec);
- for (unsigned i = 0; i != NumExceptions; ++i)
- ID.AddPointer(Exs[i].getAsOpaquePtr());
+ ID.AddBoolean(epi.Variadic);
+ ID.AddInteger(epi.TypeQuals);
+ if (epi.HasExceptionSpec) {
+ ID.AddBoolean(epi.HasAnyExceptionSpec);
+ for (unsigned i = 0; i != epi.NumExceptions; ++i)
+ ID.AddPointer(epi.Exceptions[i].getAsOpaquePtr());
}
- Info.Profile(ID);
+ epi.ExtInfo.Profile(ID);
}
void FunctionProtoType::Profile(llvm::FoldingSetNodeID &ID) {
- Profile(ID, getResultType(), arg_type_begin(), NumArgs, isVariadic(),
- getTypeQuals(), hasExceptionSpec(), hasAnyExceptionSpec(),
- getNumExceptions(), exception_begin(),
- getExtInfo());
+ Profile(ID, getResultType(), arg_type_begin(), NumArgs, getExtProtoInfo());
}
QualType TypedefType::desugar() const {
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=121763&r1=121762&r2=121763&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Tue Dec 14 02:05:40 2010
@@ -250,13 +250,14 @@
Builder.SetInsertPoint(EntryBB);
- QualType FnType = getContext().getFunctionType(RetTy, 0, 0, false, 0,
- false, false, 0, 0,
- /*FIXME?*/
- FunctionType::ExtInfo());
-
// Emit subprogram debug descriptor.
if (CGDebugInfo *DI = getDebugInfo()) {
+ // FIXME: what is going on here and why does it ignore all these
+ // interesting type properties?
+ QualType FnType =
+ getContext().getFunctionType(RetTy, 0, 0,
+ FunctionProtoType::ExtProtoInfo());
+
DI->setLocation(StartLoc);
DI->EmitFunctionStart(GD, FnType, CurFn, Builder);
}
Modified: cfe/trunk/lib/Rewrite/RewriteObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/RewriteObjC.cpp?rev=121763&r1=121762&r2=121763&view=diff
==============================================================================
--- cfe/trunk/lib/Rewrite/RewriteObjC.cpp (original)
+++ cfe/trunk/lib/Rewrite/RewriteObjC.cpp Tue Dec 14 02:05:40 2010
@@ -450,6 +450,15 @@
To += From[i];
}
}
+
+ QualType getSimpleFunctionType(QualType result,
+ const QualType *args,
+ unsigned numArgs,
+ bool variadic = false) {
+ FunctionProtoType::ExtProtoInfo fpi;
+ fpi.Variadic = variadic;
+ return Context->getFunctionType(result, args, numArgs, fpi);
+ }
};
// Helper function: create a CStyleCastExpr with trivial type source info.
@@ -2352,11 +2361,8 @@
IdentifierInfo *SelGetUidIdent = &Context->Idents.get("sel_registerName");
llvm::SmallVector<QualType, 16> ArgTys;
ArgTys.push_back(Context->getPointerType(Context->CharTy.withConst()));
- QualType getFuncType = Context->getFunctionType(Context->getObjCSelType(),
- &ArgTys[0], ArgTys.size(),
- false /*isVariadic*/, 0,
- false, false, 0, 0,
- FunctionType::ExtInfo());
+ QualType getFuncType =
+ getSimpleFunctionType(Context->getObjCSelType(), &ArgTys[0], ArgTys.size());
SelGetUidFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
SourceLocation(),
SelGetUidIdent, getFuncType, 0,
@@ -2451,11 +2457,8 @@
assert(!argT.isNull() && "Can't find 'id' type");
ArgTys.push_back(argT);
ArgTys.push_back(argT);
- QualType msgSendType = Context->getFunctionType(Context->getObjCIdType(),
- &ArgTys[0], ArgTys.size(),
- false, 0,
- false, false, 0, 0,
- FunctionType::ExtInfo());
+ QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(),
+ &ArgTys[0], ArgTys.size());
SuperContructorFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
SourceLocation(),
msgSendIdent, msgSendType, 0,
@@ -2473,11 +2476,9 @@
argT = Context->getObjCSelType();
assert(!argT.isNull() && "Can't find 'SEL' type");
ArgTys.push_back(argT);
- QualType msgSendType = Context->getFunctionType(Context->getObjCIdType(),
- &ArgTys[0], ArgTys.size(),
- true /*isVariadic*/, 0,
- false, false, 0, 0,
- FunctionType::ExtInfo());
+ QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(),
+ &ArgTys[0], ArgTys.size(),
+ true /*isVariadic*/);
MsgSendFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
SourceLocation(),
msgSendIdent, msgSendType, 0,
@@ -2498,11 +2499,9 @@
argT = Context->getObjCSelType();
assert(!argT.isNull() && "Can't find 'SEL' type");
ArgTys.push_back(argT);
- QualType msgSendType = Context->getFunctionType(Context->getObjCIdType(),
- &ArgTys[0], ArgTys.size(),
- true /*isVariadic*/, 0,
- false, false, 0, 0,
- FunctionType::ExtInfo());
+ QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(),
+ &ArgTys[0], ArgTys.size(),
+ true /*isVariadic*/);
MsgSendSuperFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
SourceLocation(),
msgSendIdent, msgSendType, 0,
@@ -2520,11 +2519,9 @@
argT = Context->getObjCSelType();
assert(!argT.isNull() && "Can't find 'SEL' type");
ArgTys.push_back(argT);
- QualType msgSendType = Context->getFunctionType(Context->getObjCIdType(),
- &ArgTys[0], ArgTys.size(),
- true /*isVariadic*/, 0,
- false, false, 0, 0,
- FunctionType::ExtInfo());
+ QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(),
+ &ArgTys[0], ArgTys.size(),
+ true /*isVariadic*/);
MsgSendStretFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
SourceLocation(),
msgSendIdent, msgSendType, 0,
@@ -2547,11 +2544,9 @@
argT = Context->getObjCSelType();
assert(!argT.isNull() && "Can't find 'SEL' type");
ArgTys.push_back(argT);
- QualType msgSendType = Context->getFunctionType(Context->getObjCIdType(),
- &ArgTys[0], ArgTys.size(),
- true /*isVariadic*/, 0,
- false, false, 0, 0,
- FunctionType::ExtInfo());
+ QualType msgSendType = getSimpleFunctionType(Context->getObjCIdType(),
+ &ArgTys[0], ArgTys.size(),
+ true /*isVariadic*/);
MsgSendSuperStretFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
SourceLocation(),
msgSendIdent, msgSendType, 0,
@@ -2569,11 +2564,9 @@
argT = Context->getObjCSelType();
assert(!argT.isNull() && "Can't find 'SEL' type");
ArgTys.push_back(argT);
- QualType msgSendType = Context->getFunctionType(Context->DoubleTy,
- &ArgTys[0], ArgTys.size(),
- true /*isVariadic*/, 0,
- false, false, 0, 0,
- FunctionType::ExtInfo());
+ QualType msgSendType = getSimpleFunctionType(Context->DoubleTy,
+ &ArgTys[0], ArgTys.size(),
+ true /*isVariadic*/);
MsgSendFpretFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
SourceLocation(),
msgSendIdent, msgSendType, 0,
@@ -2586,11 +2579,8 @@
IdentifierInfo *getClassIdent = &Context->Idents.get("objc_getClass");
llvm::SmallVector<QualType, 16> ArgTys;
ArgTys.push_back(Context->getPointerType(Context->CharTy.withConst()));
- QualType getClassType = Context->getFunctionType(Context->getObjCIdType(),
- &ArgTys[0], ArgTys.size(),
- false /*isVariadic*/, 0,
- false, false, 0, 0,
- FunctionType::ExtInfo());
+ QualType getClassType = getSimpleFunctionType(Context->getObjCIdType(),
+ &ArgTys[0], ArgTys.size());
GetClassFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
SourceLocation(),
getClassIdent, getClassType, 0,
@@ -2604,11 +2594,8 @@
&Context->Idents.get("class_getSuperclass");
llvm::SmallVector<QualType, 16> ArgTys;
ArgTys.push_back(Context->getObjCClassType());
- QualType getClassType = Context->getFunctionType(Context->getObjCClassType(),
- &ArgTys[0], ArgTys.size(),
- false /*isVariadic*/, 0,
- false, false, 0, 0,
- FunctionType::ExtInfo());
+ QualType getClassType = getSimpleFunctionType(Context->getObjCClassType(),
+ &ArgTys[0], ArgTys.size());
GetSuperClassFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
SourceLocation(),
getSuperClassIdent,
@@ -2623,11 +2610,8 @@
IdentifierInfo *getClassIdent = &Context->Idents.get("objc_getMetaClass");
llvm::SmallVector<QualType, 16> ArgTys;
ArgTys.push_back(Context->getPointerType(Context->CharTy.withConst()));
- QualType getClassType = Context->getFunctionType(Context->getObjCIdType(),
- &ArgTys[0], ArgTys.size(),
- false /*isVariadic*/, 0,
- false, false, 0, 0,
- FunctionType::ExtInfo());
+ QualType getClassType = getSimpleFunctionType(Context->getObjCIdType(),
+ &ArgTys[0], ArgTys.size());
GetMetaClassFunctionDecl = FunctionDecl::Create(*Context, TUDecl,
SourceLocation(),
getClassIdent, getClassType, 0,
@@ -3075,12 +3059,10 @@
CK_BitCast, DRE);
// Now do the "normal" pointer to function cast.
- QualType castType = Context->getFunctionType(returnType,
- &ArgTypes[0], ArgTypes.size(),
- // If we don't have a method decl, force a variadic cast.
- Exp->getMethodDecl() ? Exp->getMethodDecl()->isVariadic() : true, 0,
- false, false, 0, 0,
- FunctionType::ExtInfo());
+ QualType castType =
+ getSimpleFunctionType(returnType, &ArgTypes[0], ArgTypes.size(),
+ // If we don't have a method decl, force a variadic cast.
+ Exp->getMethodDecl() ? Exp->getMethodDecl()->isVariadic() : true);
castType = Context->getPointerType(castType);
cast = NoTypeInfoCStyleCastExpr(Context, castType, CK_BitCast,
cast);
@@ -3108,11 +3090,8 @@
Context->getPointerType(Context->VoidTy),
CK_BitCast, STDRE);
// Now do the "normal" pointer to function cast.
- castType = Context->getFunctionType(returnType,
- &ArgTypes[0], ArgTypes.size(),
- Exp->getMethodDecl() ? Exp->getMethodDecl()->isVariadic() : false, 0,
- false, false, 0, 0,
- FunctionType::ExtInfo());
+ castType = getSimpleFunctionType(returnType, &ArgTypes[0], ArgTypes.size(),
+ Exp->getMethodDecl() ? Exp->getMethodDecl()->isVariadic() : false);
castType = Context->getPointerType(castType);
cast = NoTypeInfoCStyleCastExpr(Context, castType, CK_BitCast,
cast);
@@ -4649,9 +4628,7 @@
// FIXME. Does this work if block takes no argument but has a return type
// which is of block type?
if (HasBlockType)
- FuncType = Context->getFunctionType(Res,
- &ArgTypes[0], ArgTypes.size(), false/*no variadic*/, 0,
- false, false, 0, 0, FunctionType::ExtInfo());
+ FuncType = getSimpleFunctionType(Res, &ArgTypes[0], ArgTypes.size());
else FuncType = QualType(FT, 0);
return FuncType;
}
@@ -4719,10 +4696,8 @@
}
}
// Now do the pointer to function cast.
- QualType PtrToFuncCastType = Context->getFunctionType(Exp->getType(),
- &ArgTypes[0], ArgTypes.size(), false/*no variadic*/, 0,
- false, false, 0, 0,
- FunctionType::ExtInfo());
+ QualType PtrToFuncCastType
+ = getSimpleFunctionType(Exp->getType(), &ArgTypes[0], ArgTypes.size());
PtrToFuncCastType = Context->getPointerType(PtrToFuncCastType);
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=121763&r1=121762&r2=121763&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Dec 14 02:05:40 2010
@@ -1285,10 +1285,7 @@
OldProto->arg_type_end());
NewQType = Context.getFunctionType(NewFuncType->getResultType(),
ParamTypes.data(), ParamTypes.size(),
- OldProto->isVariadic(),
- OldProto->getTypeQuals(),
- false, false, 0, 0,
- OldProto->getExtInfo());
+ OldProto->getExtProtoInfo());
New->setType(NewQType);
New->setHasInheritedPrototype();
@@ -1370,9 +1367,7 @@
New->setType(Context.getFunctionType(MergedReturn, &ArgTypes[0],
ArgTypes.size(),
- OldProto->isVariadic(), 0,
- false, false, 0, 0,
- OldProto->getExtInfo()));
+ OldProto->getExtProtoInfo()));
return MergeCompatibleFunctionDecls(New, Old);
}
@@ -4046,9 +4041,11 @@
// Turn this into a variadic function with no parameters.
const FunctionType *FT = NewFD->getType()->getAs<FunctionType>();
- QualType R = Context.getFunctionType(FT->getResultType(),
- 0, 0, true, 0, false, false, 0, 0,
- FT->getExtInfo());
+ FunctionProtoType::ExtProtoInfo EPI;
+ EPI.Variadic = true;
+ EPI.ExtInfo = FT->getExtInfo();
+
+ QualType R = Context.getFunctionType(FT->getResultType(), 0, 0, EPI);
NewFD->setType(R);
}
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=121763&r1=121762&r2=121763&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Dec 14 02:05:40 2010
@@ -2851,20 +2851,21 @@
if (FTI.TypeQuals & Qualifiers::Restrict)
Diag(D.getIdentifierLoc(), diag::err_invalid_qualified_constructor)
<< "restrict" << SourceRange(D.getIdentifierLoc());
+ D.setInvalidType();
}
// Rebuild the function type "R" without any type qualifiers (in
// case any of the errors above fired) and with "void" as the
// return type, since constructors don't have return types.
const FunctionProtoType *Proto = R->getAs<FunctionProtoType>();
+ if (Proto->getResultType() == Context.VoidTy && !D.isInvalidType())
+ return R;
+
+ FunctionProtoType::ExtProtoInfo EPI = Proto->getExtProtoInfo();
+ EPI.TypeQuals = 0;
+
return Context.getFunctionType(Context.VoidTy, Proto->arg_type_begin(),
- Proto->getNumArgs(),
- Proto->isVariadic(), 0,
- Proto->hasExceptionSpec(),
- Proto->hasAnyExceptionSpec(),
- Proto->getNumExceptions(),
- Proto->exception_begin(),
- Proto->getExtInfo());
+ Proto->getNumArgs(), EPI);
}
/// CheckConstructor - Checks a fully-formed constructor for
@@ -3022,16 +3023,14 @@
// parameters (in case any of the errors above fired) and with
// "void" as the return type, since destructors don't have return
// types.
+ if (!D.isInvalidType())
+ return R;
+
const FunctionProtoType *Proto = R->getAs<FunctionProtoType>();
- if (!Proto)
- return QualType();
-
- return Context.getFunctionType(Context.VoidTy, 0, 0, false, 0,
- Proto->hasExceptionSpec(),
- Proto->hasAnyExceptionSpec(),
- Proto->getNumExceptions(),
- Proto->exception_begin(),
- Proto->getExtInfo());
+ FunctionProtoType::ExtProtoInfo EPI = Proto->getExtProtoInfo();
+ EPI.Variadic = false;
+ EPI.TypeQuals = 0;
+ return Context.getFunctionType(Context.VoidTy, 0, 0, EPI);
}
/// CheckConversionDeclarator - Called by ActOnDeclarator to check the
@@ -3111,15 +3110,8 @@
// Rebuild the function type "R" without any parameters (in case any
// of the errors above fired) and with the conversion type as the
// return type.
- if (D.isInvalidType()) {
- R = Context.getFunctionType(ConvType, 0, 0, false,
- Proto->getTypeQuals(),
- Proto->hasExceptionSpec(),
- Proto->hasAnyExceptionSpec(),
- Proto->getNumExceptions(),
- Proto->exception_begin(),
- Proto->getExtInfo());
- }
+ if (D.isInvalidType())
+ R = Context.getFunctionType(ConvType, 0, 0, Proto->getExtProtoInfo());
// C++0x explicit conversion operators.
if (D.getDeclSpec().isExplicitSpecified() && !getLangOptions().CPlusPlus0x)
@@ -4310,7 +4302,12 @@
ExceptSpec.CalledDecl(Constructor);
}
}
-
+
+ FunctionProtoType::ExtProtoInfo EPI;
+ EPI.HasExceptionSpec = ExceptSpec.hasExceptionSpecification();
+ EPI.HasAnyExceptionSpec = ExceptSpec.hasAnyExceptionSpecification();
+ EPI.NumExceptions = ExceptSpec.size();
+ EPI.Exceptions = ExceptSpec.data();
// Create the actual constructor declaration.
CanQualType ClassType
@@ -4321,12 +4318,7 @@
CXXConstructorDecl *DefaultCon
= CXXConstructorDecl::Create(Context, ClassDecl, NameInfo,
Context.getFunctionType(Context.VoidTy,
- 0, 0, false, 0,
- ExceptSpec.hasExceptionSpecification(),
- ExceptSpec.hasAnyExceptionSpecification(),
- ExceptSpec.size(),
- ExceptSpec.data(),
- FunctionType::ExtInfo()),
+ 0, 0, EPI),
/*TInfo=*/0,
/*isExplicit=*/false,
/*isInline=*/true,
@@ -4414,13 +4406,12 @@
}
// Create the actual destructor declaration.
- QualType Ty = Context.getFunctionType(Context.VoidTy,
- 0, 0, false, 0,
- ExceptSpec.hasExceptionSpecification(),
- ExceptSpec.hasAnyExceptionSpecification(),
- ExceptSpec.size(),
- ExceptSpec.data(),
- FunctionType::ExtInfo());
+ FunctionProtoType::ExtProtoInfo EPI;
+ EPI.HasExceptionSpec = ExceptSpec.hasExceptionSpecification();
+ EPI.HasAnyExceptionSpec = ExceptSpec.hasAnyExceptionSpecification();
+ EPI.NumExceptions = ExceptSpec.size();
+ EPI.Exceptions = ExceptSpec.data();
+ QualType Ty = Context.getFunctionType(Context.VoidTy, 0, 0, EPI);
CanQualType ClassType
= Context.getCanonicalType(Context.getTypeDeclType(ClassDecl));
@@ -4812,17 +4803,16 @@
// An implicitly-declared copy assignment operator is an inline public
// member of its class.
+ FunctionProtoType::ExtProtoInfo EPI;
+ EPI.HasExceptionSpec = ExceptSpec.hasExceptionSpecification();
+ EPI.HasAnyExceptionSpec = ExceptSpec.hasAnyExceptionSpecification();
+ EPI.NumExceptions = ExceptSpec.size();
+ EPI.Exceptions = ExceptSpec.data();
DeclarationName Name = Context.DeclarationNames.getCXXOperatorName(OO_Equal);
DeclarationNameInfo NameInfo(Name, ClassDecl->getLocation());
CXXMethodDecl *CopyAssignment
= CXXMethodDecl::Create(Context, ClassDecl, NameInfo,
- Context.getFunctionType(RetType, &ArgType, 1,
- false, 0,
- ExceptSpec.hasExceptionSpecification(),
- ExceptSpec.hasAnyExceptionSpecification(),
- ExceptSpec.size(),
- ExceptSpec.data(),
- FunctionType::ExtInfo()),
+ Context.getFunctionType(RetType, &ArgType, 1, EPI),
/*TInfo=*/0, /*isStatic=*/false,
/*StorageClassAsWritten=*/SC_None,
/*isInline=*/true);
@@ -5278,6 +5268,11 @@
// An implicitly-declared copy constructor is an inline public
// member of its class.
+ FunctionProtoType::ExtProtoInfo EPI;
+ EPI.HasExceptionSpec = ExceptSpec.hasExceptionSpecification();
+ EPI.HasAnyExceptionSpec = ExceptSpec.hasAnyExceptionSpecification();
+ EPI.NumExceptions = ExceptSpec.size();
+ EPI.Exceptions = ExceptSpec.data();
DeclarationName Name
= Context.DeclarationNames.getCXXConstructorName(
Context.getCanonicalType(ClassType));
@@ -5285,13 +5280,7 @@
CXXConstructorDecl *CopyConstructor
= CXXConstructorDecl::Create(Context, ClassDecl, NameInfo,
Context.getFunctionType(Context.VoidTy,
- &ArgType, 1,
- false, 0,
- ExceptSpec.hasExceptionSpecification(),
- ExceptSpec.hasAnyExceptionSpecification(),
- ExceptSpec.size(),
- ExceptSpec.data(),
- FunctionType::ExtInfo()),
+ &ArgType, 1, EPI),
/*TInfo=*/0,
/*isExplicit=*/false,
/*isInline=*/true,
Modified: cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExceptionSpec.cpp?rev=121763&r1=121762&r2=121763&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExceptionSpec.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExceptionSpec.cpp Tue Dec 14 02:05:40 2010
@@ -115,6 +115,9 @@
if (!MissingExceptionSpecification && !MissingEmptyExceptionSpecification)
return true;
+ const FunctionProtoType *NewProto
+ = New->getType()->getAs<FunctionProtoType>();
+
// The new function declaration is only missing an empty exception
// specification "throw()". If the throw() specification came from a
// function in a system header that has C linkage, just add an empty
@@ -123,42 +126,38 @@
// to many libc functions as an optimization. Unfortunately, that
// optimization isn't permitted by the C++ standard, so we're forced
// to work around it here.
- if (MissingEmptyExceptionSpecification &&
- isa<FunctionProtoType>(New->getType()) &&
+ if (MissingEmptyExceptionSpecification && NewProto &&
(Old->getLocation().isInvalid() ||
Context.getSourceManager().isInSystemHeader(Old->getLocation())) &&
Old->isExternC()) {
- const FunctionProtoType *NewProto
- = cast<FunctionProtoType>(New->getType());
+ FunctionProtoType::ExtProtoInfo EPI = NewProto->getExtProtoInfo();
+ EPI.HasExceptionSpec = true;
+ EPI.HasAnyExceptionSpec = false;
+ EPI.NumExceptions = 0;
QualType NewType = Context.getFunctionType(NewProto->getResultType(),
NewProto->arg_type_begin(),
NewProto->getNumArgs(),
- NewProto->isVariadic(),
- NewProto->getTypeQuals(),
- true, false, 0, 0,
- NewProto->getExtInfo());
+ EPI);
New->setType(NewType);
return false;
}
- if (MissingExceptionSpecification && isa<FunctionProtoType>(New->getType())) {
- const FunctionProtoType *NewProto
- = cast<FunctionProtoType>(New->getType());
+ if (MissingExceptionSpecification && NewProto) {
const FunctionProtoType *OldProto
= Old->getType()->getAs<FunctionProtoType>();
+ FunctionProtoType::ExtProtoInfo EPI = NewProto->getExtProtoInfo();
+ EPI.HasExceptionSpec = OldProto->hasExceptionSpec();
+ EPI.HasAnyExceptionSpec = OldProto->hasAnyExceptionSpec();
+ EPI.NumExceptions = OldProto->getNumExceptions();
+ EPI.Exceptions = OldProto->exception_begin();
+
// Update the type of the function with the appropriate exception
// specification.
QualType NewType = Context.getFunctionType(NewProto->getResultType(),
NewProto->arg_type_begin(),
NewProto->getNumArgs(),
- NewProto->isVariadic(),
- NewProto->getTypeQuals(),
- OldProto->hasExceptionSpec(),
- OldProto->hasAnyExceptionSpec(),
- OldProto->getNumExceptions(),
- OldProto->exception_begin(),
- NewProto->getExtInfo());
+ EPI);
New->setType(NewType);
// If exceptions are disabled, suppress the warning about missing
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=121763&r1=121762&r2=121763&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Dec 14 02:05:40 2010
@@ -8326,8 +8326,9 @@
// Turn protoless block types into nullary block types.
if (isa<FunctionNoProtoType>(FTy)) {
- BlockTy = Context.getFunctionType(RetTy, 0, 0, false, 0,
- false, false, 0, 0, Ext);
+ FunctionProtoType::ExtProtoInfo EPI;
+ EPI.ExtInfo = Ext;
+ BlockTy = Context.getFunctionType(RetTy, 0, 0, EPI);
// Otherwise, if we don't need to change anything about the function type,
// preserve its sugar structure.
@@ -8338,23 +8339,20 @@
// Otherwise, make the minimal modifications to the function type.
} else {
const FunctionProtoType *FPT = cast<FunctionProtoType>(FTy);
+ FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo();
+ EPI.TypeQuals = 0; // FIXME: silently?
+ EPI.ExtInfo = Ext;
BlockTy = Context.getFunctionType(RetTy,
FPT->arg_type_begin(),
FPT->getNumArgs(),
- FPT->isVariadic(),
- /*quals*/ 0,
- FPT->hasExceptionSpec(),
- FPT->hasAnyExceptionSpec(),
- FPT->getNumExceptions(),
- FPT->exception_begin(),
- Ext);
+ EPI);
}
// If we don't have a function type, just build one from nothing.
} else {
- BlockTy = Context.getFunctionType(RetTy, 0, 0, false, 0,
- false, false, 0, 0,
- FunctionType::ExtInfo(NoReturn, 0, CC_Default));
+ FunctionProtoType::ExtProtoInfo EPI;
+ EPI.ExtInfo = FunctionType::ExtInfo(NoReturn, 0, CC_Default);
+ BlockTy = Context.getFunctionType(RetTy, 0, 0, EPI);
}
DiagnoseUnusedParameters(BSI->TheDecl->param_begin(),
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=121763&r1=121762&r2=121763&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Tue Dec 14 02:05:40 2010
@@ -1074,21 +1074,24 @@
// To perform this comparison, we compute the function type that
// the deallocation function should have, and use that type both
// for template argument deduction and for comparison purposes.
+ //
+ // FIXME: this comparison should ignore CC and the like.
QualType ExpectedFunctionType;
{
const FunctionProtoType *Proto
= OperatorNew->getType()->getAs<FunctionProtoType>();
+
llvm::SmallVector<QualType, 4> ArgTypes;
ArgTypes.push_back(Context.VoidPtrTy);
for (unsigned I = 1, N = Proto->getNumArgs(); I < N; ++I)
ArgTypes.push_back(Proto->getArgType(I));
+ FunctionProtoType::ExtProtoInfo EPI;
+ EPI.Variadic = Proto->isVariadic();
+
ExpectedFunctionType
= Context.getFunctionType(Context.VoidTy, ArgTypes.data(),
- ArgTypes.size(),
- Proto->isVariadic(),
- 0, false, false, 0, 0,
- FunctionType::ExtInfo());
+ ArgTypes.size(), EPI);
}
for (LookupResult::iterator D = FoundDelete.begin(),
@@ -1340,12 +1343,15 @@
assert(StdBadAlloc && "Must have std::bad_alloc declared");
BadAllocType = Context.getTypeDeclType(getStdBadAlloc());
}
+
+ FunctionProtoType::ExtProtoInfo EPI;
+ EPI.HasExceptionSpec = true;
+ if (HasBadAllocExceptionSpec) {
+ EPI.NumExceptions = 1;
+ EPI.Exceptions = &BadAllocType;
+ }
- QualType FnType = Context.getFunctionType(Return, &Argument, 1, false, 0,
- true, false,
- HasBadAllocExceptionSpec? 1 : 0,
- &BadAllocType,
- FunctionType::ExtInfo());
+ QualType FnType = Context.getFunctionType(Return, &Argument, 1, EPI);
FunctionDecl *Alloc =
FunctionDecl::Create(Context, GlobalCtx, SourceLocation(), Name,
FnType, /*TInfo=*/0, SC_None,
Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=121763&r1=121762&r2=121763&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Tue Dec 14 02:05:40 2010
@@ -671,13 +671,14 @@
// Compute the type of the function that we would expect the conversion
// function to have, if it were to match the name given.
// FIXME: Calling convention!
- FunctionType::ExtInfo ConvProtoInfo = ConvProto->getExtInfo();
+ FunctionProtoType::ExtProtoInfo EPI = ConvProto->getExtProtoInfo();
+ EPI.ExtInfo = EPI.ExtInfo.withCallingConv(CC_Default);
+ EPI.HasExceptionSpec = false;
+ EPI.HasAnyExceptionSpec = false;
+ EPI.NumExceptions = 0;
QualType ExpectedType
= R.getSema().Context.getFunctionType(R.getLookupName().getCXXNameType(),
- 0, 0, ConvProto->isVariadic(),
- ConvProto->getTypeQuals(),
- false, false, 0, 0,
- ConvProtoInfo.withCallingConv(CC_Default));
+ 0, 0, EPI);
// Perform template argument deduction against the type that we would
// expect the function to have.
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=121763&r1=121762&r2=121763&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Tue Dec 14 02:05:40 2010
@@ -1995,19 +1995,20 @@
// Rebuild the function type
+ FunctionProtoType::ExtProtoInfo EPI = Proto->getExtProtoInfo();
+ EPI.HasExceptionSpec = Proto->hasExceptionSpec();
+ EPI.HasAnyExceptionSpec = Proto->hasAnyExceptionSpec();
+ EPI.NumExceptions = Exceptions.size();
+ EPI.Exceptions = Exceptions.data();
+ EPI.ExtInfo = Proto->getExtInfo();
+
const FunctionProtoType *NewProto
= New->getType()->getAs<FunctionProtoType>();
assert(NewProto && "Template instantiation without function prototype?");
New->setType(SemaRef.Context.getFunctionType(NewProto->getResultType(),
NewProto->arg_type_begin(),
NewProto->getNumArgs(),
- NewProto->isVariadic(),
- NewProto->getTypeQuals(),
- Proto->hasExceptionSpec(),
- Proto->hasAnyExceptionSpec(),
- Exceptions.size(),
- Exceptions.data(),
- Proto->getExtInfo()));
+ EPI));
}
SemaRef.InstantiateAttrs(TemplateArgs, Tmpl, New);
Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=121763&r1=121762&r2=121763&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Tue Dec 14 02:05:40 2010
@@ -829,7 +829,7 @@
unsigned NumParamTypes,
bool Variadic, unsigned Quals,
SourceLocation Loc, DeclarationName Entity,
- const FunctionType::ExtInfo &Info) {
+ FunctionType::ExtInfo Info) {
if (T->isArrayType() || T->isFunctionType()) {
Diag(Loc, diag::err_func_returning_array_function)
<< T->isFunctionType() << T;
@@ -850,8 +850,12 @@
if (Invalid)
return QualType();
- return Context.getFunctionType(T, ParamTypes, NumParamTypes, Variadic,
- Quals, false, false, 0, 0, Info);
+ FunctionProtoType::ExtProtoInfo EPI;
+ EPI.Variadic = Variadic;
+ EPI.TypeQuals = Quals;
+ EPI.ExtInfo = Info;
+
+ return Context.getFunctionType(T, ParamTypes, NumParamTypes, EPI);
}
/// \brief Build a member pointer type \c T Class::*.
@@ -1265,6 +1269,10 @@
break;
}
+ FunctionProtoType::ExtProtoInfo EPI;
+ EPI.Variadic = FTI.isVariadic;
+ EPI.TypeQuals = FTI.TypeQuals;
+
// Otherwise, we have a function with an argument list that is
// potentially variadic.
llvm::SmallVector<QualType, 16> ArgTys;
@@ -1316,22 +1324,23 @@
}
llvm::SmallVector<QualType, 4> Exceptions;
- Exceptions.reserve(FTI.NumExceptions);
- for (unsigned ei = 0, ee = FTI.NumExceptions; ei != ee; ++ei) {
- // FIXME: Preserve type source info.
- QualType ET = GetTypeFromParser(FTI.Exceptions[ei].Ty);
- // Check that the type is valid for an exception spec, and drop it if
- // not.
- if (!CheckSpecifiedExceptionType(ET, FTI.Exceptions[ei].Range))
- Exceptions.push_back(ET);
+ if (FTI.hasExceptionSpec) {
+ EPI.HasExceptionSpec = FTI.hasExceptionSpec;
+ EPI.HasAnyExceptionSpec = FTI.hasAnyExceptionSpec;
+ EPI.NumExceptions = FTI.NumExceptions;
+ Exceptions.reserve(FTI.NumExceptions);
+ for (unsigned ei = 0, ee = FTI.NumExceptions; ei != ee; ++ei) {
+ // FIXME: Preserve type source info.
+ QualType ET = GetTypeFromParser(FTI.Exceptions[ei].Ty);
+ // Check that the type is valid for an exception spec, and
+ // drop it if not.
+ if (!CheckSpecifiedExceptionType(ET, FTI.Exceptions[ei].Range))
+ Exceptions.push_back(ET);
+ }
+ EPI.Exceptions = Exceptions.data();
}
- T = Context.getFunctionType(T, ArgTys.data(), ArgTys.size(),
- FTI.isVariadic, FTI.TypeQuals,
- FTI.hasExceptionSpec,
- FTI.hasAnyExceptionSpec,
- Exceptions.size(), Exceptions.data(),
- FunctionType::ExtInfo());
+ T = Context.getFunctionType(T, ArgTys.data(), ArgTys.size(), EPI);
}
// For GCC compatibility, we allow attributes that apply only to
@@ -1437,9 +1446,11 @@
<< FreeFunction;
// Strip the cv-quals from the type.
+ FunctionProtoType::ExtProtoInfo EPI = FnTy->getExtProtoInfo();
+ EPI.TypeQuals = 0;
+
T = Context.getFunctionType(FnTy->getResultType(), FnTy->arg_type_begin(),
- FnTy->getNumArgs(), FnTy->isVariadic(), 0,
- false, false, 0, 0, FunctionType::ExtInfo());
+ FnTy->getNumArgs(), EPI);
}
}
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=121763&r1=121762&r2=121763&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Tue Dec 14 02:05:40 2010
@@ -2842,28 +2842,29 @@
case TYPE_FUNCTION_PROTO: {
QualType ResultType = GetType(Record[0]);
- bool NoReturn = Record[1];
- unsigned RegParm = Record[2];
- CallingConv CallConv = (CallingConv)Record[3];
+
+ FunctionProtoType::ExtProtoInfo EPI;
+ EPI.ExtInfo = FunctionType::ExtInfo(/*noreturn*/ Record[1],
+ /*regparm*/ Record[2],
+ static_cast<CallingConv>(Record[3]));
+
unsigned Idx = 4;
unsigned NumParams = Record[Idx++];
llvm::SmallVector<QualType, 16> ParamTypes;
for (unsigned I = 0; I != NumParams; ++I)
ParamTypes.push_back(GetType(Record[Idx++]));
- bool isVariadic = Record[Idx++];
- unsigned Quals = Record[Idx++];
- bool hasExceptionSpec = Record[Idx++];
- bool hasAnyExceptionSpec = Record[Idx++];
- unsigned NumExceptions = Record[Idx++];
+
+ EPI.Variadic = Record[Idx++];
+ EPI.TypeQuals = Record[Idx++];
+ EPI.HasExceptionSpec = Record[Idx++];
+ EPI.HasAnyExceptionSpec = Record[Idx++];
+ EPI.NumExceptions = Record[Idx++];
llvm::SmallVector<QualType, 2> Exceptions;
- for (unsigned I = 0; I != NumExceptions; ++I)
+ for (unsigned I = 0; I != EPI.NumExceptions; ++I)
Exceptions.push_back(GetType(Record[Idx++]));
+ EPI.Exceptions = Exceptions.data();
return Context->getFunctionType(ResultType, ParamTypes.data(), NumParams,
- isVariadic, Quals, hasExceptionSpec,
- hasAnyExceptionSpec, NumExceptions,
- Exceptions.data(),
- FunctionType::ExtInfo(NoReturn, RegParm,
- CallConv));
+ EPI);
}
case TYPE_UNRESOLVED_USING:
More information about the cfe-commits
mailing list