Actually rebuild function types properly when adjusting the function

type of an instantiation.

llvm-svn: 163848
This commit is contained in:
Douglas Gregor 2012-09-13 22:01:49 +00:00
parent ca24ed473b
commit 1af8ad49fd
1 changed files with 13 additions and 4 deletions

View File

@ -1017,10 +1017,19 @@ Decl *TemplateDeclInstantiator::VisitCXXRecordDecl(CXXRecordDecl *D) {
static QualType adjustFunctionTypeForInstantiation(ASTContext &Context,
FunctionDecl *D,
TypeSourceInfo *TInfo) {
const FunctionType *OrigFunc = D->getType()->castAs<FunctionType>();
const FunctionType *NewFunc = TInfo->getType()->castAs<FunctionType>();
return QualType(Context.adjustFunctionType(NewFunc, OrigFunc->getExtInfo()),
0);
const FunctionProtoType *OrigFunc
= D->getType()->castAs<FunctionProtoType>();
const FunctionProtoType *NewFunc
= TInfo->getType()->castAs<FunctionProtoType>();
if (OrigFunc->getExtInfo() == NewFunc->getExtInfo())
return TInfo->getType();
FunctionProtoType::ExtProtoInfo NewEPI = NewFunc->getExtProtoInfo();
NewEPI.ExtInfo = OrigFunc->getExtInfo();
return Context.getFunctionType(NewFunc->getResultType(),
NewFunc->arg_type_begin(),
NewFunc->getNumArgs(),
NewEPI);
}
/// Normal class members are of more specific types and therefore