aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-09-13 22:01:49 +0000
committerDouglas Gregor <dgregor@apple.com>2012-09-13 22:01:49 +0000
commitbed51fef5773f043db2ad13aa2b6d2f8a8bdbdba (patch)
tree72348cac1e05543b0707bc0c805591a7eb63cfc3
parent2bcb984df975c75130f2320c935fae1143c2a5cc (diff)
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
-rw-r--r--lib/Sema/SemaTemplateInstantiateDecl.cpp17
1 files 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<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