aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Stellard <tstellar@redhat.com>2018-11-28 19:50:01 +0000
committerTom Stellard <tstellar@redhat.com>2018-11-28 19:50:01 +0000
commitb948f5fe98da2c9eb3afc082adbca5dbd95ecb8f (patch)
treee5da8dafeed2ed2b7fa52e32c5ecadb0625351cb
parente4023f8c634cb857649ef80786adf1dcc9f2005a (diff)
downloadllvm-b948f5fe98da2c9eb3afc082adbca5dbd95ecb8f.tar.gz
Merging r347261:
------------------------------------------------------------------------ r347261 | vedantk | 2018-11-19 12:10:21 -0800 (Mon, 19 Nov 2018) | 11 lines [Sema] Fix PR38987: keep end location of a direct initializer list 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 ------------------------------------------------------------------------ llvm-svn: 347797
-rw-r--r--clang/lib/Sema/SemaInit.cpp5
-rw-r--r--clang/test/SemaCXX/sourceranges.cpp7
2 files changed, 11 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 5070996d50e0..4f9239cb4258 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -6092,7 +6092,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())) {
diff --git a/clang/test/SemaCXX/sourceranges.cpp b/clang/test/SemaCXX/sourceranges.cpp
index 58772a063915..53f2f57e6754 100644
--- a/clang/test/SemaCXX/sourceranges.cpp
+++ b/clang/test/SemaCXX/sourceranges.cpp
@@ -52,6 +52,13 @@ void construct() {
// 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 {