[PATCH] D53231: [Sema] Fix PR38987: keep end location of a direct initializer list

Phabricator via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 19 12:14:57 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rC347261: [Sema] Fix PR38987: keep end location of a direct initializer list (authored by vedantk, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D53231?vs=169526&id=174667#toc

Repository:
  rC Clang

https://reviews.llvm.org/D53231

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


Index: lib/Sema/SemaInit.cpp
===================================================================
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -6186,7 +6186,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 {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53231.174667.patch
Type: text/x-patch
Size: 1269 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181119/4b43e7d7/attachment.bin>


More information about the cfe-commits mailing list