[cfe-commits] r133913 - in /cfe/trunk: lib/Sema/TreeTransform.h test/CodeGenCXX/new.cpp
Douglas Gregor
dgregor at apple.com
Mon Jun 27 09:55:54 PDT 2011
Author: dgregor
Date: Mon Jun 27 11:55:54 2011
New Revision: 133913
URL: http://llvm.org/viewvc/llvm-project?rev=133913&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/test/CodeGenCXX/new.cpp
Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=133913&r1=133912&r2=133913&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Mon Jun 27 11:55:54 2011
@@ -6937,9 +6937,13 @@
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>
Modified: cfe/trunk/test/CodeGenCXX/new.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/new.cpp?rev=133913&r1=133912&r2=133913&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/new.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/new.cpp Mon Jun 27 11:55:54 2011
@@ -209,3 +209,16 @@
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>();
+}
More information about the cfe-commits
mailing list