diff options
| author | Douglas Gregor <dgregor@apple.com> | 2011-06-27 16:55:54 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2011-06-27 16:55:54 +0000 |
| commit | 3bdcff5866f812c7f3425362a0af878faf64d4b3 (patch) | |
| tree | 64c0dc60d41d3d1e9433c716d976497b03756383 /clang | |
| parent | 4cc3f296a9076457b9f35c5a7403e05cf1217d69 (diff) | |
| download | bcm5719-llvm-3bdcff5866f812c7f3425362a0af878faf64d4b3.tar.gz bcm5719-llvm-3bdcff5866f812c7f3425362a0af878faf64d4b3.zip | |
When instantiating a C++ "new" expression, don't fake source locations
for the '(' and ')' around the initializer unless we actually have an
initializer. Fixes PR10197, an issue where we were value-initializing
rather than default-initializing.
llvm-svn: 133913
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Sema/TreeTransform.h | 8 | ||||
| -rw-r--r-- | clang/test/CodeGenCXX/new.cpp | 13 |
2 files changed, 19 insertions, 2 deletions
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index 0d923d113a2..edbf1fb4590 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -6937,9 +6937,13 @@ TreeTransform<Derived>::TransformCXXNewExpr(CXXNewExpr *E) { AllocType, AllocTypeInfo, ArraySize.get(), - /*FIXME:*/E->getLocStart(), + /*FIXME:*/E->hasInitializer() + ? E->getLocStart() + : SourceLocation(), move_arg(ConstructorArgs), - E->getLocEnd()); + /*FIXME:*/E->hasInitializer() + ? E->getLocEnd() + : SourceLocation()); } template<typename Derived> diff --git a/clang/test/CodeGenCXX/new.cpp b/clang/test/CodeGenCXX/new.cpp index d14a5e251ce..bd307f10867 100644 --- a/clang/test/CodeGenCXX/new.cpp +++ b/clang/test/CodeGenCXX/new.cpp @@ -209,3 +209,16 @@ namespace test15 { new (p) A[n]; } } + +namespace PR10197 { + // CHECK: define weak_odr void @_ZN7PR101971fIiEEvv() + template<typename T> + void f() { + // CHECK: [[CALL:%.*]] = call noalias i8* @_Znwm + // CHECK-NEXT: [[CASTED:%.*]] = bitcast i8* [[CALL]] to + new T; + // CHECK-NEXT: ret void + } + + template void f<int>(); +} |

