[PATCH] D64087: [clang] Correct source locations for instantiations of out-of-line defaulted special member functions. (PR25683)

2023-11-03 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

This patch appears to introduce a bug in some source ranges.
Reported the regression at https://github.com/llvm/llvm-project/issues/71161.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64087/new/

https://reviews.llvm.org/D64087

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64087: [clang] Correct source locations for instantiations of out-of-line defaulted special member functions. (PR25683)

2023-09-18 Thread Tom Honermann via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG256a0b298c68: [clang] Correct source locations for 
instantiations of function templates. (authored by tahonermann).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64087/new/

https://reviews.llvm.org/D64087

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
  clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
  clang/test/SemaCXX/member-init.cpp
  clang/test/SemaTemplate/virtual-member-functions.cpp

Index: clang/test/SemaTemplate/virtual-member-functions.cpp
===
--- clang/test/SemaTemplate/virtual-member-functions.cpp
+++ clang/test/SemaTemplate/virtual-member-functions.cpp
@@ -7,10 +7,10 @@
 
 namespace PR5557 {
 template  struct A {
-  A(); // expected-note{{instantiation}}
+  A();
   virtual int a(T x);
 };
-template A::A() {}
+template A::A() {} // expected-note{{instantiation}}
 
 template int A::a(T x) { 
   return *x; // expected-error{{requires pointer operand}}
@@ -33,10 +33,10 @@
 namespace PR5557_dtor {
 template  struct A {
   A(); // Don't have an implicit constructor.
-  ~A(); // expected-note{{instantiation}}
+  ~A();
   virtual int a(T x);
 };
-template A::~A() {}
+template A::~A() {} // expected-note{{instantiation}}
 
 template int A::a(T x) { 
   return *x; // expected-error{{requires pointer operand}}
Index: clang/test/SemaCXX/member-init.cpp
===
--- clang/test/SemaCXX/member-init.cpp
+++ clang/test/SemaCXX/member-init.cpp
@@ -164,11 +164,11 @@
 
 namespace explicit_instantiation {
 template struct X {
-  X(); // expected-note {{in instantiation of default member initializer 'explicit_instantiation::X::n' requested here}}
+  X();
   int n = T::error; // expected-error {{type 'float' cannot be used prior to '::' because it has no members}}
 };
 template struct X; // ok
-template X::X() {}
+template X::X() {} // expected-note {{in instantiation of default member initializer 'explicit_instantiation::X::n' requested here}}
 template struct X; // expected-note {{in instantiation of member function 'explicit_instantiation::X::X' requested here}}
 }
 
@@ -197,3 +197,15 @@
 }
 template void foo(int);
 }
+
+namespace GH26057 {
+template
+struct S {
+  S();
+  int dm = T::error; // expected-error {{type 'int' cannot be used prior to '::' because it has no members}}
+};
+template
+S::S() = default; // expected-note {{in instantiation of default member initializer 'GH26057::S::dm' requested here}} \
+ // expected-note {{in evaluation of exception specification for 'GH26057::S::S' needed here}}
+template struct S; // expected-note {{in instantiation of member function 'GH26057::S::S' requested here}}
+}
Index: clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
===
--- clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
+++ clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
@@ -102,14 +102,14 @@
 
 namespace forward_declare_consteval{
 template 
-constexpr int f(T t);  // expected-note {{'f' defined here}}
+constexpr int f(T t);
 
 auto a = ;
 auto b = ; // expected-error {{immediate function 'f' used before it is defined}} \
   // expected-note {{in instantiation of function template specialization}}
 
 template 
-constexpr int f(T t) {
+constexpr int f(T t) { // expected-note {{'f' defined here}}
 return id(t); // expected-note {{'f' is an immediate function because its body contains a call to a consteval function 'id' and that call is not a constant expression}}
 }
 }
Index: clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
===
--- clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
+++ clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
@@ -209,10 +209,10 @@
 
 namespace p2085_2 {
 template  struct S6 {
-  // expected-error@+2{{found 'const int &'}}
-  // expected-error@+1{{found 'const float &'}}
   bool operator==(T const &) const;
 };
+// expected-error@+2{{found 'const int &'}}
+// expected-error@+1{{found 'const float &'}}
 template  bool S6::operator==(T const &) const = default;
 
 template struct S6; // expected-note{{S6::operator==' requested}}
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4990,8 +4990,10 @@
   // unimported module.
   Function->setVisibleDespiteOwningModule();
 
-  // Copy the inner loc start from the pattern.
+  // Copy the source locations from the pattern.
+  

[PATCH] D64087: [clang] Correct source locations for instantiations of out-of-line defaulted special member functions. (PR25683)

2023-09-18 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann updated this revision to Diff 556970.
tahonermann added a comment.

Addressed review feedback.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64087/new/

https://reviews.llvm.org/D64087

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
  clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
  clang/test/SemaCXX/member-init.cpp
  clang/test/SemaTemplate/virtual-member-functions.cpp

Index: clang/test/SemaTemplate/virtual-member-functions.cpp
===
--- clang/test/SemaTemplate/virtual-member-functions.cpp
+++ clang/test/SemaTemplate/virtual-member-functions.cpp
@@ -7,10 +7,10 @@
 
 namespace PR5557 {
 template  struct A {
-  A(); // expected-note{{instantiation}}
+  A();
   virtual int a(T x);
 };
-template A::A() {}
+template A::A() {} // expected-note{{instantiation}}
 
 template int A::a(T x) { 
   return *x; // expected-error{{requires pointer operand}}
@@ -33,10 +33,10 @@
 namespace PR5557_dtor {
 template  struct A {
   A(); // Don't have an implicit constructor.
-  ~A(); // expected-note{{instantiation}}
+  ~A();
   virtual int a(T x);
 };
-template A::~A() {}
+template A::~A() {} // expected-note{{instantiation}}
 
 template int A::a(T x) { 
   return *x; // expected-error{{requires pointer operand}}
Index: clang/test/SemaCXX/member-init.cpp
===
--- clang/test/SemaCXX/member-init.cpp
+++ clang/test/SemaCXX/member-init.cpp
@@ -164,11 +164,11 @@
 
 namespace explicit_instantiation {
 template struct X {
-  X(); // expected-note {{in instantiation of default member initializer 'explicit_instantiation::X::n' requested here}}
+  X();
   int n = T::error; // expected-error {{type 'float' cannot be used prior to '::' because it has no members}}
 };
 template struct X; // ok
-template X::X() {}
+template X::X() {} // expected-note {{in instantiation of default member initializer 'explicit_instantiation::X::n' requested here}}
 template struct X; // expected-note {{in instantiation of member function 'explicit_instantiation::X::X' requested here}}
 }
 
@@ -197,3 +197,15 @@
 }
 template void foo(int);
 }
+
+namespace GH26057 {
+template
+struct S {
+  S();
+  int dm = T::error; // expected-error {{type 'int' cannot be used prior to '::' because it has no members}}
+};
+template
+S::S() = default; // expected-note {{in instantiation of default member initializer 'GH26057::S::dm' requested here}} \
+ // expected-note {{in evaluation of exception specification for 'GH26057::S::S' needed here}}
+template struct S; // expected-note {{in instantiation of member function 'GH26057::S::S' requested here}}
+}
Index: clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
===
--- clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
+++ clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
@@ -102,14 +102,14 @@
 
 namespace forward_declare_consteval{
 template 
-constexpr int f(T t);  // expected-note {{'f' defined here}}
+constexpr int f(T t);
 
 auto a = ;
 auto b = ; // expected-error {{immediate function 'f' used before it is defined}} \
   // expected-note {{in instantiation of function template specialization}}
 
 template 
-constexpr int f(T t) {
+constexpr int f(T t) { // expected-note {{'f' defined here}}
 return id(t); // expected-note {{'f' is an immediate function because its body contains a call to a consteval function 'id' and that call is not a constant expression}}
 }
 }
Index: clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
===
--- clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
+++ clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
@@ -209,10 +209,10 @@
 
 namespace p2085_2 {
 template  struct S6 {
-  // expected-error@+2{{found 'const int &'}}
-  // expected-error@+1{{found 'const float &'}}
   bool operator==(T const &) const;
 };
+// expected-error@+2{{found 'const int &'}}
+// expected-error@+1{{found 'const float &'}}
 template  bool S6::operator==(T const &) const = default;
 
 template struct S6; // expected-note{{S6::operator==' requested}}
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4990,8 +4990,10 @@
   // unimported module.
   Function->setVisibleDespiteOwningModule();
 
-  // Copy the inner loc start from the pattern.
+  // Copy the source locations from the pattern.
+  Function->setLocation(PatternDecl->getLocation());
   Function->setInnerLocStart(PatternDecl->getInnerLocStart());
+  Function->setRangeEnd(PatternDecl->getEndLoc());
 
   

[PATCH] D64087: [clang] Correct source locations for instantiations of out-of-line defaulted special member functions. (PR25683)

2023-09-18 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin accepted this revision.
cor3ntin added a comment.

1 nit but still LGTM




Comment at: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp:4993
 
-  // Copy the inner loc start from the pattern.
+  // Copy source locations from the pattern.
+  Function->setLocation(PatternDecl->getLocation());




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64087/new/

https://reviews.llvm.org/D64087

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64087: [clang] Correct source locations for instantiations of out-of-line defaulted special member functions. (PR25683)

2023-09-18 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann added a comment.

@cor3ntin, any concerns or suggestions per my recent updates? I'll plan to land 
this in the next couple of days otherwise.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64087/new/

https://reviews.llvm.org/D64087

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64087: [clang] Correct source locations for instantiations of out-of-line defaulted special member functions. (PR25683)

2023-09-12 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann updated this revision to Diff 556604.
tahonermann added a comment.

Moved the added release note to the correct section.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64087/new/

https://reviews.llvm.org/D64087

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
  clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
  clang/test/SemaCXX/member-init.cpp
  clang/test/SemaTemplate/virtual-member-functions.cpp

Index: clang/test/SemaTemplate/virtual-member-functions.cpp
===
--- clang/test/SemaTemplate/virtual-member-functions.cpp
+++ clang/test/SemaTemplate/virtual-member-functions.cpp
@@ -7,10 +7,10 @@
 
 namespace PR5557 {
 template  struct A {
-  A(); // expected-note{{instantiation}}
+  A();
   virtual int a(T x);
 };
-template A::A() {}
+template A::A() {} // expected-note{{instantiation}}
 
 template int A::a(T x) { 
   return *x; // expected-error{{requires pointer operand}}
@@ -33,10 +33,10 @@
 namespace PR5557_dtor {
 template  struct A {
   A(); // Don't have an implicit constructor.
-  ~A(); // expected-note{{instantiation}}
+  ~A();
   virtual int a(T x);
 };
-template A::~A() {}
+template A::~A() {} // expected-note{{instantiation}}
 
 template int A::a(T x) { 
   return *x; // expected-error{{requires pointer operand}}
Index: clang/test/SemaCXX/member-init.cpp
===
--- clang/test/SemaCXX/member-init.cpp
+++ clang/test/SemaCXX/member-init.cpp
@@ -164,11 +164,11 @@
 
 namespace explicit_instantiation {
 template struct X {
-  X(); // expected-note {{in instantiation of default member initializer 'explicit_instantiation::X::n' requested here}}
+  X();
   int n = T::error; // expected-error {{type 'float' cannot be used prior to '::' because it has no members}}
 };
 template struct X; // ok
-template X::X() {}
+template X::X() {} // expected-note {{in instantiation of default member initializer 'explicit_instantiation::X::n' requested here}}
 template struct X; // expected-note {{in instantiation of member function 'explicit_instantiation::X::X' requested here}}
 }
 
@@ -197,3 +197,15 @@
 }
 template void foo(int);
 }
+
+namespace GH26057 {
+template
+struct S {
+  S();
+  int dm = T::error; // expected-error {{type 'int' cannot be used prior to '::' because it has no members}}
+};
+template
+S::S() = default; // expected-note {{in instantiation of default member initializer 'GH26057::S::dm' requested here}} \
+ // expected-note {{in evaluation of exception specification for 'GH26057::S::S' needed here}}
+template struct S; // expected-note {{in instantiation of member function 'GH26057::S::S' requested here}}
+}
Index: clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
===
--- clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
+++ clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
@@ -102,14 +102,14 @@
 
 namespace forward_declare_consteval{
 template 
-constexpr int f(T t);  // expected-note {{'f' defined here}}
+constexpr int f(T t);
 
 auto a = ;
 auto b = ; // expected-error {{immediate function 'f' used before it is defined}} \
   // expected-note {{in instantiation of function template specialization}}
 
 template 
-constexpr int f(T t) {
+constexpr int f(T t) { // expected-note {{'f' defined here}}
 return id(t); // expected-note {{'f' is an immediate function because its body contains a call to a consteval function 'id' and that call is not a constant expression}}
 }
 }
Index: clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
===
--- clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
+++ clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
@@ -209,10 +209,10 @@
 
 namespace p2085_2 {
 template  struct S6 {
-  // expected-error@+2{{found 'const int &'}}
-  // expected-error@+1{{found 'const float &'}}
   bool operator==(T const &) const;
 };
+// expected-error@+2{{found 'const int &'}}
+// expected-error@+1{{found 'const float &'}}
 template  bool S6::operator==(T const &) const = default;
 
 template struct S6; // expected-note{{S6::operator==' requested}}
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4990,8 +4990,10 @@
   // unimported module.
   Function->setVisibleDespiteOwningModule();
 
-  // Copy the inner loc start from the pattern.
+  // Copy source locations from the pattern.
+  Function->setLocation(PatternDecl->getLocation());
   Function->setInnerLocStart(PatternDecl->getInnerLocStart());
+  

[PATCH] D64087: [clang] Correct source locations for instantiations of out-of-line defaulted special member functions. (PR25683)

2023-09-12 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann added a comment.

@Endill, thank you for the reminder about this old patch!

@cor3ntin, I added an additional test and updated a few other recently 
(relative to the original patch!) added tests. Would you be so kind as to give 
this another quick review?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64087/new/

https://reviews.llvm.org/D64087

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64087: [clang] Correct source locations for instantiations of out-of-line defaulted special member functions. (PR25683)

2023-09-12 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann updated this revision to Diff 556592.
tahonermann edited the summary of this revision.
tahonermann added a comment.

Rebased patch uploaded. This retains the same code change, but includes 
additional test updates for tests added since the first patch was submitted, as 
well as an additional patch to exercise a test case from 
https://github.com/llvm/llvm-project/issues/26057.

The changes made effectively complete changes originally made in commit 
12dcbf3eaa6d2c8b9ee814ddb8bf23bef644bfaf (Fixed implicit instantiations source 
range.) 



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64087/new/

https://reviews.llvm.org/D64087

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
  clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
  clang/test/SemaCXX/member-init.cpp
  clang/test/SemaTemplate/virtual-member-functions.cpp

Index: clang/test/SemaTemplate/virtual-member-functions.cpp
===
--- clang/test/SemaTemplate/virtual-member-functions.cpp
+++ clang/test/SemaTemplate/virtual-member-functions.cpp
@@ -7,10 +7,10 @@
 
 namespace PR5557 {
 template  struct A {
-  A(); // expected-note{{instantiation}}
+  A();
   virtual int a(T x);
 };
-template A::A() {}
+template A::A() {} // expected-note{{instantiation}}
 
 template int A::a(T x) { 
   return *x; // expected-error{{requires pointer operand}}
@@ -33,10 +33,10 @@
 namespace PR5557_dtor {
 template  struct A {
   A(); // Don't have an implicit constructor.
-  ~A(); // expected-note{{instantiation}}
+  ~A();
   virtual int a(T x);
 };
-template A::~A() {}
+template A::~A() {} // expected-note{{instantiation}}
 
 template int A::a(T x) { 
   return *x; // expected-error{{requires pointer operand}}
Index: clang/test/SemaCXX/member-init.cpp
===
--- clang/test/SemaCXX/member-init.cpp
+++ clang/test/SemaCXX/member-init.cpp
@@ -164,11 +164,11 @@
 
 namespace explicit_instantiation {
 template struct X {
-  X(); // expected-note {{in instantiation of default member initializer 'explicit_instantiation::X::n' requested here}}
+  X();
   int n = T::error; // expected-error {{type 'float' cannot be used prior to '::' because it has no members}}
 };
 template struct X; // ok
-template X::X() {}
+template X::X() {} // expected-note {{in instantiation of default member initializer 'explicit_instantiation::X::n' requested here}}
 template struct X; // expected-note {{in instantiation of member function 'explicit_instantiation::X::X' requested here}}
 }
 
@@ -197,3 +197,15 @@
 }
 template void foo(int);
 }
+
+namespace GH26057 {
+template
+struct S {
+  S();
+  int dm = T::error; // expected-error {{type 'int' cannot be used prior to '::' because it has no members}}
+};
+template
+S::S() = default; // expected-note {{in instantiation of default member initializer 'GH26057::S::dm' requested here}} \
+ // expected-note {{in evaluation of exception specification for 'GH26057::S::S' needed here}}
+template struct S; // expected-note {{in instantiation of member function 'GH26057::S::S' requested here}}
+}
Index: clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
===
--- clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
+++ clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
@@ -102,14 +102,14 @@
 
 namespace forward_declare_consteval{
 template 
-constexpr int f(T t);  // expected-note {{'f' defined here}}
+constexpr int f(T t);
 
 auto a = ;
 auto b = ; // expected-error {{immediate function 'f' used before it is defined}} \
   // expected-note {{in instantiation of function template specialization}}
 
 template 
-constexpr int f(T t) {
+constexpr int f(T t) { // expected-note {{'f' defined here}}
 return id(t); // expected-note {{'f' is an immediate function because its body contains a call to a consteval function 'id' and that call is not a constant expression}}
 }
 }
Index: clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
===
--- clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
+++ clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
@@ -209,10 +209,10 @@
 
 namespace p2085_2 {
 template  struct S6 {
-  // expected-error@+2{{found 'const int &'}}
-  // expected-error@+1{{found 'const float &'}}
   bool operator==(T const &) const;
 };
+// expected-error@+2{{found 'const int &'}}
+// expected-error@+1{{found 'const float &'}}
 template  bool S6::operator==(T const &) const = default;
 
 template struct S6; // expected-note{{S6::operator==' requested}}
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp

[PATCH] D64087: [clang] Correct source locations for instantiations of out-of-line defaulted special member functions. (PR25683)

2023-09-11 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin accepted this revision.
cor3ntin added a comment.
This revision is now accepted and ready to land.

LGTM (assuming rebase goes well)
@tahonermann ping folks in the future, and apologies for taking... 4 years!


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64087/new/

https://reviews.llvm.org/D64087

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64087: [clang] Correct source locations for instantiations of out-of-line defaulted special member functions. (PR25683)

2023-09-11 Thread Vlad Serebrennikov via Phabricator via cfe-commits
Endill added a comment.

@tahonermann Do you mind rebasing this on top of trunk if it's necessary?
Might be a good idea to resubmit this as PR.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64087/new/

https://reviews.llvm.org/D64087

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64087: [clang] Correct source locations for instantiations of out-of-line defaulted special member functions. (PR25683)

2019-07-02 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann added a comment.

See PR25683 (https://bugs.llvm.org/show_bug.cgi?id=25683) for more details.  
The patch posted here differs slightly from what is posted in the PR; 
`getLocation()` is called instead of `getBeginLoc()` since the latter may 
return a customized begin location.

I believe the impact to the two tests is a desirable change; the instantiation 
note seems like it should be correlated with the definition, not the 
declaration.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64087/new/

https://reviews.llvm.org/D64087



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64087: [clang] Correct source locations for instantiations of out-of-line defaulted special member functions. (PR25683)

2019-07-02 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann created this revision.
tahonermann added a reviewer: rsmith.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fixes PR25683 (https://bugs.llvm.org/show_bug.cgi?id=25683)

This change completes adjustments of source locations for FunctionDecl
definitions corresponding to function template instantiations.  Prior
changes made back in 2011 (

  "Fixed implicit instantiations source range."
  
https://github.com/llvm/llvm-project/commit/12dcbf3eaa6d2c8b9ee814ddb8bf23bef644bfaf

) updated the "inner start location" when instantiating a definition,
but for out-of-line definitions of defaulted special member functions
(functions without defined bodies), this resulted in the
"inner start location" matching the location of the out-of-line
defaulted definition, but left the end location matching the end of
the in-class declaration.  With this change, the declaration location,
"inner start location", and end location are now all adjusted to match
the FunctionDecl for the template pattern.


Repository:
  rC Clang

https://reviews.llvm.org/D64087

Files:
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/SemaCXX/member-init.cpp
  clang/test/SemaTemplate/virtual-member-functions.cpp


Index: clang/test/SemaTemplate/virtual-member-functions.cpp
===
--- clang/test/SemaTemplate/virtual-member-functions.cpp
+++ clang/test/SemaTemplate/virtual-member-functions.cpp
@@ -7,10 +7,10 @@
 
 namespace PR5557 {
 template  struct A {
-  A(); // expected-note{{instantiation}}
+  A();
   virtual int a(T x);
 };
-template A::A() {}
+template A::A() {} // expected-note{{instantiation}}
 
 template int A::a(T x) { 
   return *x; // expected-error{{requires pointer operand}}
@@ -33,10 +33,10 @@
 namespace PR5557_dtor {
 template  struct A {
   A(); // Don't have an implicit constructor.
-  ~A(); // expected-note{{instantiation}}
+  ~A();
   virtual int a(T x);
 };
-template A::~A() {}
+template A::~A() {} // expected-note{{instantiation}}
 
 template int A::a(T x) { 
   return *x; // expected-error{{requires pointer operand}}
Index: clang/test/SemaCXX/member-init.cpp
===
--- clang/test/SemaCXX/member-init.cpp
+++ clang/test/SemaCXX/member-init.cpp
@@ -164,11 +164,11 @@
 
 namespace explicit_instantiation {
 template struct X {
-  X(); // expected-note {{in instantiation of default member initializer 
'explicit_instantiation::X::n' requested here}}
+  X();
   int n = T::error; // expected-error {{type 'float' cannot be used prior to 
'::' because it has no members}}
 };
 template struct X; // ok
-template X::X() {}
+template X::X() {} // expected-note {{in instantiation of 
default member initializer 'explicit_instantiation::X::n' requested 
here}}
 template struct X; // expected-note {{in instantiation of member 
function 'explicit_instantiation::X::X' requested here}}
 }
 
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4234,8 +4234,10 @@
   // unimported module.
   Function->setVisibleDespiteOwningModule();
 
-  // Copy the inner loc start from the pattern.
+  // Copy source locations from the pattern.
+  Function->setLocation(PatternDecl->getLocation());
   Function->setInnerLocStart(PatternDecl->getInnerLocStart());
+  Function->setRangeEnd(PatternDecl->getEndLoc());
 
   EnterExpressionEvaluationContext EvalContext(
   *this, Sema::ExpressionEvaluationContext::PotentiallyEvaluated);


Index: clang/test/SemaTemplate/virtual-member-functions.cpp
===
--- clang/test/SemaTemplate/virtual-member-functions.cpp
+++ clang/test/SemaTemplate/virtual-member-functions.cpp
@@ -7,10 +7,10 @@
 
 namespace PR5557 {
 template  struct A {
-  A(); // expected-note{{instantiation}}
+  A();
   virtual int a(T x);
 };
-template A::A() {}
+template A::A() {} // expected-note{{instantiation}}
 
 template int A::a(T x) { 
   return *x; // expected-error{{requires pointer operand}}
@@ -33,10 +33,10 @@
 namespace PR5557_dtor {
 template  struct A {
   A(); // Don't have an implicit constructor.
-  ~A(); // expected-note{{instantiation}}
+  ~A();
   virtual int a(T x);
 };
-template A::~A() {}
+template A::~A() {} // expected-note{{instantiation}}
 
 template int A::a(T x) { 
   return *x; // expected-error{{requires pointer operand}}
Index: clang/test/SemaCXX/member-init.cpp
===
--- clang/test/SemaCXX/member-init.cpp
+++ clang/test/SemaCXX/member-init.cpp
@@ -164,11 +164,11 @@
 
 namespace explicit_instantiation {
 template struct X {
-  X(); // expected-note {{in instantiation of default member initializer 'explicit_instantiation::X::n' requested here}}
+  X();
   int n = T::error;