[cfe-commits] r118066 - in /cfe/trunk: include/clang/AST/ExprCXX.h lib/AST/ExprCXX.cpp test/CodeGenCXX/template-dependent-bind-temporary.cpp
Fariborz Jahanian
fjahanian at apple.com
Tue Nov 2 14:05:53 PDT 2010
Author: fjahanian
Date: Tue Nov 2 16:05:53 2010
New Revision: 118066
URL: http://llvm.org/viewvc/llvm-project?rev=118066&view=rev
Log:
Fixes an assertion violation when bind to temporary
expression is a dependent expression.
// rdar: // 8620524 and PR7851
Added:
cfe/trunk/test/CodeGenCXX/template-dependent-bind-temporary.cpp
Modified:
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/lib/AST/ExprCXX.cpp
Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=118066&r1=118065&r2=118066&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Tue Nov 2 16:05:53 2010
@@ -672,8 +672,9 @@
Stmt *SubExpr;
- CXXBindTemporaryExpr(CXXTemporary *temp, Expr* subexpr)
- : Expr(CXXBindTemporaryExprClass, subexpr->getType(), false, false),
+ CXXBindTemporaryExpr(CXXTemporary *temp, Expr* subexpr,
+ bool TD=false, bool VD=false)
+ : Expr(CXXBindTemporaryExprClass, subexpr->getType(), TD, VD),
Temp(temp), SubExpr(subexpr) { }
public:
Modified: cfe/trunk/lib/AST/ExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCXX.cpp?rev=118066&r1=118065&r2=118066&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprCXX.cpp (original)
+++ cfe/trunk/lib/AST/ExprCXX.cpp Tue Nov 2 16:05:53 2010
@@ -534,7 +534,9 @@
assert(SubExpr->getType()->isRecordType() &&
"Expression bound to a temporary must have record type!");
- return new (C) CXXBindTemporaryExpr(Temp, SubExpr);
+ return new (C) CXXBindTemporaryExpr(Temp, SubExpr,
+ SubExpr->isTypeDependent(),
+ SubExpr->isValueDependent());
}
CXXTemporaryObjectExpr::CXXTemporaryObjectExpr(ASTContext &C,
Added: cfe/trunk/test/CodeGenCXX/template-dependent-bind-temporary.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/template-dependent-bind-temporary.cpp?rev=118066&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/template-dependent-bind-temporary.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/template-dependent-bind-temporary.cpp Tue Nov 2 16:05:53 2010
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+// rdar: //8620524
+// PR7851
+struct string {
+ string (const string& );
+ string ();
+ ~string();
+};
+
+string operator + (char ch, const string&);
+
+template <class T>
+void IntToString(T a)
+{
+ string result;
+ T digit;
+ char((digit < 10 ? '0' : 'a') + digit) + result;
+}
+
+int main() {
+// CHECK: define linkonce_odr void @_Z11IntToStringIcEvT_(
+ IntToString('a');
+}
+
More information about the cfe-commits
mailing list