r198995 - Use the appropriate SourceLocation for the template backtrace when doing

Nick Lewycky nicholas at mxc.ca
Fri Jan 10 18:37:13 PST 2014


Author: nicholas
Date: Fri Jan 10 20:37:12 2014
New Revision: 198995

URL: http://llvm.org/viewvc/llvm-project?rev=198995&view=rev
Log:
Use the appropriate SourceLocation for the template backtrace when doing
template argument deduction.

Modified:
    cfe/trunk/lib/Sema/SemaLookup.cpp
    cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
    cfe/trunk/test/SemaCXX/cxx98-compat.cpp
    cfe/trunk/test/SemaCXX/implicit-member-functions.cpp
    cfe/trunk/test/SemaCXX/typo-correction.cpp
    cfe/trunk/test/SemaTemplate/instantiate-exception-spec.cpp
    cfe/trunk/test/SemaTemplate/instantiate-function-params.cpp
    cfe/trunk/test/SemaTemplate/instantiation-backtrace.cpp
    cfe/trunk/test/SemaTemplate/instantiation-depth-subst-2.cpp
    cfe/trunk/test/SemaTemplate/instantiation-depth-subst.cpp
    cfe/trunk/test/SemaTemplate/instantiation-order.cpp
    cfe/trunk/test/SemaTemplate/operator-template.cpp

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=198995&r1=198994&r2=198995&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Fri Jan 10 20:37:12 2014
@@ -2546,7 +2546,7 @@ Sema::SpecialMemberOverloadResult *Sema:
   // Now we perform lookup on the name we computed earlier and do overload
   // resolution. Lookup is only performed directly into the class since there
   // will always be a (possibly implicit) declaration to shadow any others.
-  OverloadCandidateSet OCS((SourceLocation()));
+  OverloadCandidateSet OCS(RD->getLocation());
   DeclContext::lookup_result R = RD->lookup(Name);
   assert(!R.empty() &&
          "lookup for a constructor or assignment operator was empty");

Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=198995&r1=198994&r2=198995&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Fri Jan 10 20:37:12 2014
@@ -2285,8 +2285,8 @@ Sema::DeduceTemplateArguments(ClassTempl
     return Result;
 
   SmallVector<TemplateArgument, 4> DeducedArgs(Deduced.begin(), Deduced.end());
-  InstantiatingTemplate Inst(*this, Partial->getLocation(), Partial,
-                             DeducedArgs, Info);
+  InstantiatingTemplate Inst(*this, Info.getLocation(), Partial, DeducedArgs,
+                             Info);
   if (Inst.isInvalid())
     return TDK_InstantiationDepth;
 
@@ -2449,8 +2449,8 @@ Sema::DeduceTemplateArguments(VarTemplat
     return Result;
 
   SmallVector<TemplateArgument, 4> DeducedArgs(Deduced.begin(), Deduced.end());
-  InstantiatingTemplate Inst(*this, Partial->getLocation(), Partial,
-                             DeducedArgs, Info);
+  InstantiatingTemplate Inst(*this, Info.getLocation(), Partial, DeducedArgs,
+                             Info);
   if (Inst.isInvalid())
     return TDK_InstantiationDepth;
 
@@ -2535,8 +2535,8 @@ Sema::SubstituteExplicitTemplateArgument
   // explicitly-specified template arguments against this function template,
   // and then substitute them into the function parameter types.
   SmallVector<TemplateArgument, 4> DeducedArgs(Deduced.begin(), Deduced.end());
-  InstantiatingTemplate Inst(*this, FunctionTemplate->getLocation(),
-                             FunctionTemplate, DeducedArgs,
+  InstantiatingTemplate Inst(*this, Info.getLocation(), FunctionTemplate,
+                             DeducedArgs,
            ActiveTemplateInstantiation::ExplicitTemplateArgumentSubstitution,
                              Info);
   if (Inst.isInvalid())
@@ -2789,8 +2789,8 @@ Sema::FinishTemplateArgumentDeduction(Fu
   // Enter a new template instantiation context while we instantiate the
   // actual function declaration.
   SmallVector<TemplateArgument, 4> DeducedArgs(Deduced.begin(), Deduced.end());
-  InstantiatingTemplate Inst(*this, FunctionTemplate->getLocation(),
-                             FunctionTemplate, DeducedArgs,
+  InstantiatingTemplate Inst(*this, Info.getLocation(), FunctionTemplate,
+                             DeducedArgs,
               ActiveTemplateInstantiation::DeducedTemplateArgumentSubstitution,
                              Info);
   if (Inst.isInvalid())
@@ -4624,8 +4624,7 @@ Sema::getMoreSpecializedPartialSpecializ
                                             /*RefParamComparisons=*/0);
   if (Better1) {
     SmallVector<TemplateArgument, 4> DeducedArgs(Deduced.begin(),Deduced.end());
-    InstantiatingTemplate Inst(*this, PS2->getLocation(), PS2, DeducedArgs,
-                               Info);
+    InstantiatingTemplate Inst(*this, Loc, PS2, DeducedArgs, Info);
     Better1 = !::FinishTemplateArgumentDeduction(
         *this, PS2, PS1->getTemplateArgs(), Deduced, Info);
   }
@@ -4640,8 +4639,7 @@ Sema::getMoreSpecializedPartialSpecializ
   if (Better2) {
     SmallVector<TemplateArgument, 4> DeducedArgs(Deduced.begin(),
                                                  Deduced.end());
-    InstantiatingTemplate Inst(*this, PS1->getLocation(), PS1, DeducedArgs,
-                               Info);
+    InstantiatingTemplate Inst(*this, Loc, PS1, DeducedArgs, Info);
     Better2 = !::FinishTemplateArgumentDeduction(
         *this, PS1, PS2->getTemplateArgs(), Deduced, Info);
   }
@@ -4685,8 +4683,7 @@ Sema::getMoreSpecializedPartialSpecializ
   if (Better1) {
     SmallVector<TemplateArgument, 4> DeducedArgs(Deduced.begin(),
                                                  Deduced.end());
-    InstantiatingTemplate Inst(*this, PS2->getLocation(), PS2,
-                               DeducedArgs, Info);
+    InstantiatingTemplate Inst(*this, Loc, PS2, DeducedArgs, Info);
     Better1 = !::FinishTemplateArgumentDeduction(*this, PS2,
                                                  PS1->getTemplateArgs(),
                                                  Deduced, Info);
@@ -4702,8 +4699,7 @@ Sema::getMoreSpecializedPartialSpecializ
                                             /*RefParamComparisons=*/0);
   if (Better2) {
     SmallVector<TemplateArgument, 4> DeducedArgs(Deduced.begin(),Deduced.end());
-    InstantiatingTemplate Inst(*this, PS1->getLocation(), PS1,
-                               DeducedArgs, Info);
+    InstantiatingTemplate Inst(*this, Loc, PS1, DeducedArgs, Info);
     Better2 = !::FinishTemplateArgumentDeduction(*this, PS1,
                                                  PS2->getTemplateArgs(),
                                                  Deduced, Info);

Modified: cfe/trunk/test/SemaCXX/cxx98-compat.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx98-compat.cpp?rev=198995&r1=198994&r2=198995&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx98-compat.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx98-compat.cpp Fri Jan 10 20:37:12 2014
@@ -219,11 +219,11 @@ int n = {}; // expected-warning {{scalar
 class PrivateMember {
   struct ImPrivate {};
 };
-template<typename T> typename T::ImPrivate SFINAEAccessControl(T t) { // expected-warning {{substitution failure due to access control is incompatible with C++98}} expected-note {{while substituting deduced template arguments into function template 'SFINAEAccessControl' [with T = PrivateMember]}}
+template<typename T> typename T::ImPrivate SFINAEAccessControl(T t) { // expected-warning {{substitution failure due to access control is incompatible with C++98}}
   return typename T::ImPrivate();
 }
 int SFINAEAccessControl(...) { return 0; }
-int CheckSFINAEAccessControl = SFINAEAccessControl(PrivateMember());
+int CheckSFINAEAccessControl = SFINAEAccessControl(PrivateMember()); // expected-note {{while substituting deduced template arguments into function template 'SFINAEAccessControl' [with T = PrivateMember]}}
 
 template<typename T>
 struct FriendRedefinition {

Modified: cfe/trunk/test/SemaCXX/implicit-member-functions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/implicit-member-functions.cpp?rev=198995&r1=198994&r2=198995&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/implicit-member-functions.cpp (original)
+++ cfe/trunk/test/SemaCXX/implicit-member-functions.cpp Fri Jan 10 20:37:12 2014
@@ -58,13 +58,13 @@ namespace Recursion {
   };
   struct B;
   struct A {
+    // expected-note at -1 {{while substituting deduced template arguments}}
     typedef B type;
     template<typename T,
              typename = typename InvokeCopyConstructor<typename T::type>::type>
     // expected-note at -1 {{in instantiation of template class}}
     A(const T &);
     // expected-note at -1 {{in instantiation of default argument}}
-    // expected-note at -2 {{while substituting deduced template arguments}}
   };
   struct B { // expected-note {{candidate constructor (the implicit move }}
     B(); // expected-note {{candidate constructor not viable}}

Modified: cfe/trunk/test/SemaCXX/typo-correction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/typo-correction.cpp?rev=198995&r1=198994&r2=198995&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/typo-correction.cpp (original)
+++ cfe/trunk/test/SemaCXX/typo-correction.cpp Fri Jan 10 20:37:12 2014
@@ -282,13 +282,13 @@ namespace b6956809_test1 {
 namespace b6956809_test2 {
   template<typename T> struct Err { typename T::error n; };  // expected-error{{type 'void *' cannot be used prior to '::' because it has no members}}
   struct S {
-    template<typename T> typename Err<T>::type method(T);  // expected-note{{in instantiation of template class 'b6956809_test2::Err<void *>' requested here}}  expected-note{{while substituting deduced template arguments into function template 'method' [with T = void *]}}
+    template<typename T> typename Err<T>::type method(T);  // expected-note{{in instantiation of template class 'b6956809_test2::Err<void *>' requested here}}
     template<typename T> int method(T *);
   };
 
   void test() {
     S s;
-    int k = s.methodd((void*)0);  // expected-error{{no member named 'methodd' in 'b6956809_test2::S'; did you mean 'method'?}}
+    int k = s.methodd((void*)0);  // expected-error{{no member named 'methodd' in 'b6956809_test2::S'; did you mean 'method'?}} expected-note{{while substituting deduced template arguments into function template 'method' [with T = void *]}}
   }
 }
 

Modified: cfe/trunk/test/SemaTemplate/instantiate-exception-spec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-exception-spec.cpp?rev=198995&r1=198994&r2=198995&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-exception-spec.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-exception-spec.cpp Fri Jan 10 20:37:12 2014
@@ -1,11 +1,9 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 
-// FIXME: the "note" should be down at the call site!
-template<typename T> void f1(T*) throw(T); // expected-error{{incomplete type 'Incomplete' is not allowed in exception specification}} \
-                         // expected-note{{instantiation of}}
+template<typename T> void f1(T*) throw(T); // expected-error{{incomplete type 'Incomplete' is not allowed in exception specification}}
 struct Incomplete; // expected-note{{forward}}
 
 void test_f1(Incomplete *incomplete_p, int *int_p) {
   f1(int_p);
-  f1(incomplete_p); 
+  f1(incomplete_p); // expected-note{{instantiation of}}
 }

Modified: cfe/trunk/test/SemaTemplate/instantiate-function-params.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-function-params.cpp?rev=198995&r1=198994&r2=198995&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-function-params.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-function-params.cpp Fri Jan 10 20:37:12 2014
@@ -7,12 +7,12 @@ template<typename T1> struct if_ {
 };
 template <class Model, void (Model::*)()> struct wrap_constraints { };
 template <class Model> 
-inline char has_constraints_(Model* ,  // expected-note 2{{while substituting deduced template arguments into function template 'has_constraints_' [with }} \
-                             // expected-note 3{{candidate template ignored}}
+inline char has_constraints_(Model* , // expected-note 3{{candidate template ignored}}
                                wrap_constraints<Model,&Model::constraints>* = 0); // expected-note 2{{in instantiation}}
 
 template <class Model> struct not_satisfied {
-  static const bool value = sizeof( has_constraints_((Model*)0)  == 1); // expected-error 3{{no matching function}}
+  static const bool value = sizeof( has_constraints_((Model*)0)  == 1); // expected-error 3{{no matching function}} \
+  // expected-note 2{{while substituting deduced template arguments into function template 'has_constraints_' [with }}
 };
 template <class ModelFn> struct requirement_;
 template <void(*)()> struct instantiate {

Modified: cfe/trunk/test/SemaTemplate/instantiation-backtrace.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiation-backtrace.cpp?rev=198995&r1=198994&r2=198995&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiation-backtrace.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiation-backtrace.cpp Fri Jan 10 20:37:12 2014
@@ -39,13 +39,13 @@ namespace PR13365 {
   template <class T1, class T2>
     typename ResultTy<T2>::error Deduce( void (T1::*member)(T2) ) {} // \
     // expected-note {{instantiation of template class 'PR13365::ResultTy<int &>'}} \
-    // expected-note {{substituting deduced template arguments into function template 'Deduce' [with T1 = PR13365::Cls, T2 = int &]}} \
     // expected-note {{substitution failure [with T1 = PR13365::Cls, T2 = int &]}}
 
   struct Cls {
     void method(int&);
   };
   void test() {
-    Deduce(&Cls::method); // expected-error {{no matching function}}
+    Deduce(&Cls::method); // expected-error {{no matching function}} \
+                          // expected-note {{substituting deduced template arguments into function template 'Deduce' [with T1 = PR13365::Cls, T2 = int &]}}
   }
 }

Modified: cfe/trunk/test/SemaTemplate/instantiation-depth-subst-2.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiation-depth-subst-2.cpp?rev=198995&r1=198994&r2=198995&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiation-depth-subst-2.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiation-depth-subst-2.cpp Fri Jan 10 20:37:12 2014
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -verify %s -ftemplate-depth 2
 
 template<int N> struct S { };
-template<typename T> S<T() + T()> operator+(T, T); // expected-error {{instantiation exceeded maximum depth}} expected-note 3{{while substituting}}
+template<typename T> S<T() + T()> operator+(T, T); // expected-error {{instantiation exceeded maximum depth}} expected-note 2{{while substituting}}
 S<0> s;
-int k = s + s;
+int k = s + s; // expected-note {{while substituting}}

Modified: cfe/trunk/test/SemaTemplate/instantiation-depth-subst.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiation-depth-subst.cpp?rev=198995&r1=198994&r2=198995&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiation-depth-subst.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiation-depth-subst.cpp Fri Jan 10 20:37:12 2014
@@ -3,7 +3,7 @@
 // PR9793
 template<typename T> auto f(T t) -> decltype(f(t)); // \
 // expected-error {{recursive template instantiation exceeded maximum depth of 2}} \
-// expected-note 3 {{while substituting}}
+// expected-note 2 {{while substituting}}
 
 struct S {};
-int k = f(S{});
+int k = f(S{}); // expected-note {{while substituting}}

Modified: cfe/trunk/test/SemaTemplate/instantiation-order.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiation-order.cpp?rev=198995&r1=198994&r2=198995&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiation-order.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiation-order.cpp Fri Jan 10 20:37:12 2014
@@ -5,11 +5,11 @@
 template <class T> struct A { using X = typename T::X; }; // expected-error {{no members}}
 template <class T> typename T::X f(typename A<T>::X);
 template <class T> void f(...) {}
-template <class T> auto g(typename A<T>::X) -> typename T::X; // expected-note {{here}} expected-note {{substituting}}
+template <class T> auto g(typename A<T>::X) -> typename T::X; // expected-note {{here}}
 template <class T> void g(...) {}
 
 void h()
 {
   f<int>(0); // ok, SFINAE in return type
-  g<int>(0); // not ok, substitution inside A<int> is a hard error
+  g<int>(0); // not ok, substitution inside A<int> is a hard error // expected-note {{substituting}}
 }

Modified: cfe/trunk/test/SemaTemplate/operator-template.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/operator-template.cpp?rev=198995&r1=198994&r2=198995&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/operator-template.cpp (original)
+++ cfe/trunk/test/SemaTemplate/operator-template.cpp Fri Jan 10 20:37:12 2014
@@ -12,7 +12,6 @@ int a0(A<int> x) { return x == 1; }
 template<class X>struct B{typedef X Y;};
 template<class X>bool operator==(B<X>*,typename B<X>::Y); // \
 // expected-error{{overloaded 'operator==' must have at least one parameter of class or enumeration type}} \
-// expected-note{{in instantiation of function template specialization}} \
 // expected-note{{candidate template ignored: substitution failure [with X = int]}}
-int a(B<int> x) { return operator==(&x,1); } // expected-error{{no matching function for call to 'operator=='}}
-
+int a(B<int> x) { return operator==(&x,1); } // expected-error{{no matching function for call to 'operator=='}} \
+// expected-note{{in instantiation of function template specialization}}





More information about the cfe-commits mailing list