From bed51fef5773f043db2ad13aa2b6d2f8a8bdbdba Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Thu, 13 Sep 2012 22:01:49 +0000 Subject: [PATCH] Actually rebuild function types properly when adjusting the function type of an instantiation. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163848 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaTemplateInstantiateDecl.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index 858aabf8a8..21ddd47363 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -1017,10 +1017,19 @@ Decl *TemplateDeclInstantiator::VisitCXXRecordDecl(CXXRecordDecl *D) { static QualType adjustFunctionTypeForInstantiation(ASTContext &Context, FunctionDecl *D, TypeSourceInfo *TInfo) { - const FunctionType *OrigFunc = D->getType()->castAs(); - const FunctionType *NewFunc = TInfo->getType()->castAs(); - return QualType(Context.adjustFunctionType(NewFunc, OrigFunc->getExtInfo()), - 0); + const FunctionProtoType *OrigFunc + = D->getType()->castAs(); + const FunctionProtoType *NewFunc + = TInfo->getType()->castAs(); + 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 -- 2.50.1