/// 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);
<< Attr.Range;
bool msAsm = false;
Res = ParseAsmStatement(msAsm);
+ Res = Actions.ActOnFinishFullStmt(Res.get());
if (msAsm) return move(Res);
SemiError = "asm";
break;
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;
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,
CheckImplicitConversions(FullExpr);
return MaybeCreateCXXExprWithTemporaries(FullExpr);
}
+
+StmtResult Sema::ActOnFinishFullStmt(Stmt *FullStmt) {
+ if (!FullStmt) return StmtError();
+
+ return MaybeCreateCXXStmtWithTemporaries(FullStmt);
+}
--- /dev/null
+// 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
+}