orivej created this revision.
orivej added reviewers: rsmith, vsk, aaron.ballman.
Herald added a subscriber: cfe-commits.

If PerformConstructorInitialization of a direct initializer list constructor is 
called while instantiating a template, it has brace locations in its BraceLoc 
arguments but not in the Kind argument.

This reverts the hunk https://reviews.llvm.org/D41921#inline-468844.


Repository:
  rC Clang

https://reviews.llvm.org/D53231

Files:
  lib/Sema/SemaInit.cpp
  test/SemaCXX/sourceranges.cpp


Index: test/SemaCXX/sourceranges.cpp
===================================================================
--- test/SemaCXX/sourceranges.cpp
+++ test/SemaCXX/sourceranges.cpp
@@ -52,6 +52,13 @@
   // CHECK: CXXConstructExpr {{0x[0-9a-fA-F]+}} <col:9, col:13> 'D' 'void 
(int){{( __attribute__\(\(thiscall\)\))?}}'
 }
 
+namespace PR38987 {
+struct A { A(); };
+template <class T> void f() { T{}; }
+template void f<A>();
+// CHECK: CXXTemporaryObjectExpr {{.*}} <col:31, col:33> 
'PR38987::A':'PR38987::A'
+}
+
 void abort() __attribute__((noreturn));
 
 namespace std {
Index: lib/Sema/SemaInit.cpp
===================================================================
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -6180,7 +6180,10 @@
     TypeSourceInfo *TSInfo = Entity.getTypeSourceInfo();
     if (!TSInfo)
       TSInfo = S.Context.getTrivialTypeSourceInfo(Entity.getType(), Loc);
-    SourceRange ParenOrBraceRange = Kind.getParenOrBraceRange();
+    SourceRange ParenOrBraceRange =
+        (Kind.getKind() == InitializationKind::IK_DirectList)
+        ? SourceRange(LBraceLoc, RBraceLoc)
+        : Kind.getParenOrBraceRange();
 
     if (auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(
             Step.Function.FoundDecl.getDecl())) {


Index: test/SemaCXX/sourceranges.cpp
===================================================================
--- test/SemaCXX/sourceranges.cpp
+++ test/SemaCXX/sourceranges.cpp
@@ -52,6 +52,13 @@
   // CHECK: CXXConstructExpr {{0x[0-9a-fA-F]+}} <col:9, col:13> 'D' 'void (int){{( __attribute__\(\(thiscall\)\))?}}'
 }
 
+namespace PR38987 {
+struct A { A(); };
+template <class T> void f() { T{}; }
+template void f<A>();
+// CHECK: CXXTemporaryObjectExpr {{.*}} <col:31, col:33> 'PR38987::A':'PR38987::A'
+}
+
 void abort() __attribute__((noreturn));
 
 namespace std {
Index: lib/Sema/SemaInit.cpp
===================================================================
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -6180,7 +6180,10 @@
     TypeSourceInfo *TSInfo = Entity.getTypeSourceInfo();
     if (!TSInfo)
       TSInfo = S.Context.getTrivialTypeSourceInfo(Entity.getType(), Loc);
-    SourceRange ParenOrBraceRange = Kind.getParenOrBraceRange();
+    SourceRange ParenOrBraceRange =
+        (Kind.getKind() == InitializationKind::IK_DirectList)
+        ? SourceRange(LBraceLoc, RBraceLoc)
+        : Kind.getParenOrBraceRange();
 
     if (auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(
             Step.Function.FoundDecl.getDecl())) {
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to