[llvm-branch-commits] [cfe-branch] r118540 - in /cfe/branches/Apple/whitney: include/clang/Sema/Sema.h lib/Parse/ParseStmt.cpp lib/Sema/SemaExprCXX.cpp test/CodeGenCXX/asm.cpp test/SemaCXX/asm.cpp
Daniel Dunbar
daniel at zuster.org
Tue Nov 9 09:30:37 PST 2010
Author: ddunbar
Date: Tue Nov 9 11:30:37 2010
New Revision: 118540
URL: http://llvm.org/viewvc/llvm-project?rev=118540&view=rev
Log:
Merge r118001:
--
Author: Argyrios Kyrtzidis <akyrtzi at gmail.com>
Date: Tue Nov 2 02:33:08 2010 +0000
Properly handle temporaries that are created in a AsmStmt.
Previously the temporaries would get destroyed before the asm call.
Added:
cfe/branches/Apple/whitney/test/CodeGenCXX/asm.cpp
Removed:
cfe/branches/Apple/whitney/test/SemaCXX/asm.cpp
Modified:
cfe/branches/Apple/whitney/include/clang/Sema/Sema.h
cfe/branches/Apple/whitney/lib/Parse/ParseStmt.cpp
cfe/branches/Apple/whitney/lib/Sema/SemaExprCXX.cpp
Modified: cfe/branches/Apple/whitney/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/include/clang/Sema/Sema.h?rev=118540&r1=118539&r2=118540&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/include/clang/Sema/Sema.h (original)
+++ cfe/branches/Apple/whitney/include/clang/Sema/Sema.h Tue Nov 9 11:30:37 2010
@@ -2342,10 +2342,12 @@
/// non-empty, will create a new CXXExprWithTemporaries expression.
/// Otherwise, just returs the passed in expression.
Expr *MaybeCreateCXXExprWithTemporaries(Expr *SubExpr);
+ Stmt *MaybeCreateCXXStmtWithTemporaries(Stmt *SubStmt);
ExprResult MaybeCreateCXXExprWithTemporaries(ExprResult SubExpr);
FullExpr CreateFullExpr(Expr *SubExpr);
ExprResult ActOnFinishFullExpr(Expr *Expr);
+ StmtResult ActOnFinishFullStmt(Stmt *Stmt);
// Marks SS invalid if it represents an incomplete type.
bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC);
Modified: cfe/branches/Apple/whitney/lib/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/lib/Parse/ParseStmt.cpp?rev=118540&r1=118539&r2=118540&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/lib/Parse/ParseStmt.cpp (original)
+++ cfe/branches/Apple/whitney/lib/Parse/ParseStmt.cpp Tue Nov 9 11:30:37 2010
@@ -188,6 +188,7 @@
<< Attr.Range;
bool msAsm = false;
Res = ParseAsmStatement(msAsm);
+ Res = Actions.ActOnFinishFullStmt(Res.get());
if (msAsm) return move(Res);
SemiError = "asm";
break;
@@ -1458,7 +1459,6 @@
SkipUntil(tok::r_paren);
return true;
}
- Res = Actions.MakeFullExpr(Res.get()).release();
Exprs.push_back(Res.release());
// Eat the comma and continue parsing if it exists.
if (Tok.isNot(tok::comma)) return false;
Modified: cfe/branches/Apple/whitney/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/lib/Sema/SemaExprCXX.cpp?rev=118540&r1=118539&r2=118540&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/branches/Apple/whitney/lib/Sema/SemaExprCXX.cpp Tue Nov 9 11:30:37 2010
@@ -3016,6 +3016,26 @@
return E;
}
+Stmt *Sema::MaybeCreateCXXStmtWithTemporaries(Stmt *SubStmt) {
+ assert(SubStmt && "sub statement can't be null!");
+
+ unsigned FirstTemporary = ExprEvalContexts.back().NumTemporaries;
+ assert(ExprTemporaries.size() >= FirstTemporary);
+ if (ExprTemporaries.size() == FirstTemporary)
+ return SubStmt;
+
+ // FIXME: In order to attach the temporaries, wrap the statement into
+ // a StmtExpr; currently this is only used for asm statements.
+ // This is hacky, either create a new CXXStmtWithTemporaries statement or
+ // a new AsmStmtWithTemporaries.
+ CompoundStmt *CompStmt = new (Context) CompoundStmt(Context, &SubStmt, 1,
+ SourceLocation(),
+ SourceLocation());
+ Expr *E = new (Context) StmtExpr(CompStmt, Context.VoidTy, SourceLocation(),
+ SourceLocation());
+ return MaybeCreateCXXExprWithTemporaries(E);
+}
+
ExprResult
Sema::ActOnStartCXXMemberReference(Scope *S, Expr *Base, SourceLocation OpLoc,
tok::TokenKind OpKind, ParsedType &ObjectType,
@@ -3398,3 +3418,9 @@
CheckImplicitConversions(FullExpr);
return MaybeCreateCXXExprWithTemporaries(FullExpr);
}
+
+StmtResult Sema::ActOnFinishFullStmt(Stmt *FullStmt) {
+ if (!FullStmt) return StmtError();
+
+ return MaybeCreateCXXStmtWithTemporaries(FullStmt);
+}
Added: cfe/branches/Apple/whitney/test/CodeGenCXX/asm.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/test/CodeGenCXX/asm.cpp?rev=118540&view=auto
==============================================================================
--- cfe/branches/Apple/whitney/test/CodeGenCXX/asm.cpp (added)
+++ cfe/branches/Apple/whitney/test/CodeGenCXX/asm.cpp Tue Nov 9 11:30:37 2010
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+
+struct A
+{
+ ~A();
+};
+int foo(A);
+
+void bar(A &a)
+{
+ // CHECK: call void asm
+ asm("" : : "r"(foo(a)) ); // rdar://8540491
+ // CHECK: call void @_ZN1AD1Ev
+}
Removed: cfe/branches/Apple/whitney/test/SemaCXX/asm.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/test/SemaCXX/asm.cpp?rev=118539&view=auto
==============================================================================
--- cfe/branches/Apple/whitney/test/SemaCXX/asm.cpp (original)
+++ cfe/branches/Apple/whitney/test/SemaCXX/asm.cpp (removed)
@@ -1,13 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-
-struct A
-{
- ~A();
-};
-int foo(A);
-
-void bar()
-{
- A a;
- asm("" : : "r"(foo(a)) ); // rdar://8540491
-}
More information about the llvm-branch-commits
mailing list