]> granicus.if.org Git - clang/commitdiff
[Sema] Fix PR38987: keep end location of a direct initializer list
authorVedant Kumar <vsk@apple.com>
Mon, 19 Nov 2018 20:10:21 +0000 (20:10 +0000)
committerVedant Kumar <vsk@apple.com>
Mon, 19 Nov 2018 20:10:21 +0000 (20:10 +0000)
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.

Patch by Orivej Desh!

Differential Revision: https://reviews.llvm.org/D53231

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@347261 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 80431a63b83edb0185e2ca1506c53df424c6373d..3184be803860bc86b30dc3553b045e7a9462cbb4 100644 (file)
@@ -6186,7 +6186,10 @@ PerformConstructorInitialization(Sema &S,
     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 58772a063915d28375d69dea8ffc31f59937fd0b..53f2f57e6754503e790c3b214c7b0b973fb628f9 100644 (file)
@@ -52,6 +52,13 @@ void construct() {
   // CHECK: CXXConstructExpr {{0x[0-9a-fA-F]+}} <col:9, col:13> 'D' 'void (int){{( __attribute__\(\(thiscall\)\))?}}'\r
 }\r
 \r
+namespace PR38987 {\r
+struct A { A(); };\r
+template <class T> void f() { T{}; }\r
+template void f<A>();\r
+// CHECK: CXXTemporaryObjectExpr {{.*}} <col:31, col:33> 'PR38987::A':'PR38987::A'\r
+}\r
+\r
 void abort() __attribute__((noreturn));\r
 \r
 namespace std {\r