[llvm-branch-commits] [cfe-branch] r196057 - Merging r196050:
Bill Wendling
isanbard at gmail.com
Sun Dec 1 18:05:28 PST 2013
Author: void
Date: Sun Dec 1 20:05:28 2013
New Revision: 196057
URL: http://llvm.org/viewvc/llvm-project?rev=196057&view=rev
Log:
Merging r196050:
------------------------------------------------------------------------
r196050 | rafael | 2013-12-01 08:54:29 -0800 (Sun, 01 Dec 2013) | 5 lines
Handle CC and NoReturn when instantiating members of class templates.
Before we were considering them only when instantiating templates.
This fixes pr18033.
------------------------------------------------------------------------
Modified:
cfe/branches/release_34/ (props changed)
cfe/branches/release_34/include/clang/Sema/Sema.h
cfe/branches/release_34/lib/Sema/SemaTemplate.cpp
cfe/branches/release_34/lib/Sema/SemaTemplateDeduction.cpp
cfe/branches/release_34/test/SemaCXX/decl-microsoft-call-conv.cpp
Propchange: cfe/branches/release_34/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Dec 1 20:05:28 2013
@@ -1,4 +1,4 @@
/cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:195126,195128,195135-195136,195146,195149,195154,195158,195163,195168,195174,195268,195283,195303,195326,195329,195367,195384,195409,195420,195422,195501,195547,195556,195558,195587,195620,195669,195687,195693,195710,195713,195716,195760,195768,195777,195789,195792,195804,195827,195843-195844,195877,195887-195888,195897,195903,195905-195906,195932,195936-195943,195970,195983
+/cfe/trunk:195126,195128,195135-195136,195146,195149,195154,195158,195163,195168,195174,195268,195283,195303,195326,195329,195367,195384,195409,195420,195422,195501,195547,195556,195558,195587,195620,195669,195687,195693,195710,195713,195716,195760,195768,195777,195789,195792,195804,195827,195843-195844,195877,195887-195888,195897,195903,195905-195906,195932,195936-195943,195970,195983,196050
/cfe/trunk/test:170344
/cfe/trunk/test/SemaTemplate:126920
Modified: cfe/branches/release_34/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_34/include/clang/Sema/Sema.h?rev=196057&r1=196056&r2=196057&view=diff
==============================================================================
--- cfe/branches/release_34/include/clang/Sema/Sema.h (original)
+++ cfe/branches/release_34/include/clang/Sema/Sema.h Sun Dec 1 20:05:28 2013
@@ -5776,6 +5776,8 @@ public:
// C++ Template Argument Deduction (C++ [temp.deduct])
//===--------------------------------------------------------------------===//
+ QualType adjustCCAndNoReturn(QualType ArgFunctionType, QualType FunctionType);
+
/// \brief Describes the result of template argument deduction.
///
/// The TemplateDeductionResult enumeration describes the result of
Modified: cfe/branches/release_34/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_34/lib/Sema/SemaTemplate.cpp?rev=196057&r1=196056&r2=196057&view=diff
==============================================================================
--- cfe/branches/release_34/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/branches/release_34/lib/Sema/SemaTemplate.cpp Sun Dec 1 20:05:28 2013
@@ -7441,7 +7441,8 @@ DeclResult Sema::ActOnExplicitInstantiat
NamedDecl *Prev = *P;
if (!HasExplicitTemplateArgs) {
if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Prev)) {
- if (Context.hasSameUnqualifiedType(Method->getType(), R)) {
+ QualType Adjusted = adjustCCAndNoReturn(R, Method->getType());
+ if (Context.hasSameUnqualifiedType(Method->getType(), Adjusted)) {
Matches.clear();
Matches.addDecl(Method, P.getAccess());
Modified: cfe/branches/release_34/lib/Sema/SemaTemplateDeduction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_34/lib/Sema/SemaTemplateDeduction.cpp?rev=196057&r1=196056&r2=196057&view=diff
==============================================================================
--- cfe/branches/release_34/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/branches/release_34/lib/Sema/SemaTemplateDeduction.cpp Sun Dec 1 20:05:28 2013
@@ -3501,6 +3501,28 @@ Sema::TemplateDeductionResult Sema::Dedu
Specialization, Info, &OriginalCallArgs);
}
+QualType Sema::adjustCCAndNoReturn(QualType ArgFunctionType,
+ QualType FunctionType) {
+ if (ArgFunctionType.isNull())
+ return ArgFunctionType;
+
+ const FunctionProtoType *FunctionTypeP =
+ FunctionType->castAs<FunctionProtoType>();
+ CallingConv CC = FunctionTypeP->getCallConv();
+ bool NoReturn = FunctionTypeP->getNoReturnAttr();
+ const FunctionProtoType *ArgFunctionTypeP =
+ ArgFunctionType->getAs<FunctionProtoType>();
+ if (ArgFunctionTypeP->getCallConv() == CC &&
+ ArgFunctionTypeP->getNoReturnAttr() == NoReturn)
+ return ArgFunctionType;
+
+ FunctionType::ExtInfo EI = ArgFunctionTypeP->getExtInfo().withCallingConv(CC);
+ EI = EI.withNoReturn(NoReturn);
+ ArgFunctionTypeP =
+ cast<FunctionProtoType>(Context.adjustFunctionType(ArgFunctionTypeP, EI));
+ return QualType(ArgFunctionTypeP, 0);
+}
+
/// \brief Deduce template arguments when taking the address of a function
/// template (C++ [temp.deduct.funcaddr]) or matching a specialization to
/// a template.
@@ -3538,23 +3560,8 @@ Sema::DeduceTemplateArguments(FunctionTe
TemplateParameterList *TemplateParams
= FunctionTemplate->getTemplateParameters();
QualType FunctionType = Function->getType();
- if (!InOverloadResolution && !ArgFunctionType.isNull()) {
- const FunctionProtoType *FunctionTypeP =
- FunctionType->castAs<FunctionProtoType>();
- CallingConv CC = FunctionTypeP->getCallConv();
- bool NoReturn = FunctionTypeP->getNoReturnAttr();
- const FunctionProtoType *ArgFunctionTypeP =
- ArgFunctionType->getAs<FunctionProtoType>();
- if (ArgFunctionTypeP->getCallConv() != CC ||
- ArgFunctionTypeP->getNoReturnAttr() != NoReturn) {
- FunctionType::ExtInfo EI =
- ArgFunctionTypeP->getExtInfo().withCallingConv(CC);
- EI = EI.withNoReturn(NoReturn);
- ArgFunctionTypeP = cast<FunctionProtoType>(
- Context.adjustFunctionType(ArgFunctionTypeP, EI));
- ArgFunctionType = QualType(ArgFunctionTypeP, 0);
- }
- }
+ if (!InOverloadResolution)
+ ArgFunctionType = adjustCCAndNoReturn(ArgFunctionType, FunctionType);
// Substitute any explicit template arguments.
LocalInstantiationScope InstScope(*this);
Modified: cfe/branches/release_34/test/SemaCXX/decl-microsoft-call-conv.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_34/test/SemaCXX/decl-microsoft-call-conv.cpp?rev=196057&r1=196056&r2=196057&view=diff
==============================================================================
--- cfe/branches/release_34/test/SemaCXX/decl-microsoft-call-conv.cpp (original)
+++ cfe/branches/release_34/test/SemaCXX/decl-microsoft-call-conv.cpp Sun Dec 1 20:05:28 2013
@@ -183,3 +183,11 @@ namespace test4 {
};
extern template void foo::bar(const void *);
}
+
+namespace test5 {
+ template <class T>
+ class valarray {
+ void bar();
+ };
+ extern template void valarray<int>::bar();
+}
More information about the llvm-branch-commits
mailing list