[cfe-commits] r62464 - in /cfe/trunk: Driver/PrintParserCallbacks.cpp include/clang/Parse/Action.h lib/Parse/ParseStmt.cpp lib/Sema/Sema.h lib/Sema/SemaStmt.cpp
Sebastian Redl
sebastian.redl at getdesigned.at
Sun Jan 18 08:53:19 PST 2009
Author: cornedbee
Date: Sun Jan 18 10:53:17 2009
New Revision: 62464
URL: http://llvm.org/viewvc/llvm-project?rev=62464&view=rev
Log:
Convert asm statement action to smart pointers.
Modified:
cfe/trunk/Driver/PrintParserCallbacks.cpp
cfe/trunk/include/clang/Parse/Action.h
cfe/trunk/lib/Parse/ParseStmt.cpp
cfe/trunk/lib/Sema/Sema.h
cfe/trunk/lib/Sema/SemaStmt.cpp
Modified: cfe/trunk/Driver/PrintParserCallbacks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/PrintParserCallbacks.cpp?rev=62464&r1=62463&r2=62464&view=diff
==============================================================================
--- cfe/trunk/Driver/PrintParserCallbacks.cpp (original)
+++ cfe/trunk/Driver/PrintParserCallbacks.cpp Sun Jan 18 10:53:17 2009
@@ -365,22 +365,21 @@
llvm::cout << __FUNCTION__ << "\n";
return StmtEmpty();
}
- virtual StmtResult ActOnAsmStmt(SourceLocation AsmLoc,
- bool IsSimple,
- bool IsVolatile,
- unsigned NumOutputs,
- unsigned NumInputs,
- std::string *Names,
- ExprTy **Constraints,
- ExprTy **Exprs,
- ExprTy *AsmString,
- unsigned NumClobbers,
- ExprTy **Clobbers,
- SourceLocation RParenLoc) {
+ virtual OwningStmtResult ActOnAsmStmt(SourceLocation AsmLoc,
+ bool IsSimple,
+ bool IsVolatile,
+ unsigned NumOutputs,
+ unsigned NumInputs,
+ std::string *Names,
+ MultiExprArg Constraints,
+ MultiExprArg Exprs,
+ ExprArg AsmString,
+ MultiExprArg Clobbers,
+ SourceLocation RParenLoc) {
llvm::cout << __FUNCTION__ << "\n";
- return 0;
+ return StmtEmpty();
}
-
+
// Objective-c statements
virtual StmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc,
SourceLocation RParen, StmtTy *Parm,
Modified: cfe/trunk/include/clang/Parse/Action.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Action.h?rev=62464&r1=62463&r2=62464&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Action.h (original)
+++ cfe/trunk/include/clang/Parse/Action.h Sun Jan 18 10:53:17 2009
@@ -459,21 +459,20 @@
ExprArg RetValExp) {
return StmtEmpty();
}
- virtual StmtResult ActOnAsmStmt(SourceLocation AsmLoc,
- bool IsSimple,
- bool IsVolatile,
- unsigned NumOutputs,
- unsigned NumInputs,
- std::string *Names,
- ExprTy **Constraints,
- ExprTy **Exprs,
- ExprTy *AsmString,
- unsigned NumClobbers,
- ExprTy **Clobbers,
- SourceLocation RParenLoc) {
- return 0;
+ virtual OwningStmtResult ActOnAsmStmt(SourceLocation AsmLoc,
+ bool IsSimple,
+ bool IsVolatile,
+ unsigned NumOutputs,
+ unsigned NumInputs,
+ std::string *Names,
+ MultiExprArg Constraints,
+ MultiExprArg Exprs,
+ ExprArg AsmString,
+ MultiExprArg Clobbers,
+ SourceLocation RParenLoc) {
+ return StmtEmpty();
}
-
+
// Objective-c statements
virtual StmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc,
SourceLocation RParen, StmtTy *Parm,
Modified: cfe/trunk/lib/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=62464&r1=62463&r2=62464&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseStmt.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmt.cpp Sun Jan 18 10:53:17 2009
@@ -1155,12 +1155,11 @@
RParenLoc = MatchRHSPunctuation(tok::r_paren, Loc);
}
- return Owned(Actions.ActOnAsmStmt(AsmLoc, isSimple, isVolatile,
- NumOutputs, NumInputs,
- &Names[0], Constraints.take(),
- Exprs.take(), AsmString.release(),
- Clobbers.size(), Clobbers.take(),
- RParenLoc));
+ return Actions.ActOnAsmStmt(AsmLoc, isSimple, isVolatile,
+ NumOutputs, NumInputs, &Names[0],
+ move_convert(Constraints), move_convert(Exprs),
+ move_convert(AsmString), move_convert(Clobbers),
+ RParenLoc);
}
/// ParseAsmOperands - Parse the asm-operands production as used by
Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=62464&r1=62463&r2=62464&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Sun Jan 18 10:53:17 2009
@@ -901,18 +901,17 @@
OwningStmtResult ActOnBlockReturnStmt(SourceLocation ReturnLoc,
Expr *RetValExp);
- virtual StmtResult ActOnAsmStmt(SourceLocation AsmLoc,
- bool IsSimple,
- bool IsVolatile,
- unsigned NumOutputs,
- unsigned NumInputs,
- std::string *Names,
- ExprTy **Constraints,
- ExprTy **Exprs,
- ExprTy *AsmString,
- unsigned NumClobbers,
- ExprTy **Clobbers,
- SourceLocation RParenLoc);
+ virtual OwningStmtResult ActOnAsmStmt(SourceLocation AsmLoc,
+ bool IsSimple,
+ bool IsVolatile,
+ unsigned NumOutputs,
+ unsigned NumInputs,
+ std::string *Names,
+ MultiExprArg Constraints,
+ MultiExprArg Exprs,
+ ExprArg AsmString,
+ MultiExprArg Clobbers,
+ SourceLocation RParenLoc);
virtual StmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc,
SourceLocation RParen, StmtTy *Parm,
Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=62464&r1=62463&r2=62464&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Sun Jan 18 10:53:17 2009
@@ -831,112 +831,108 @@
return Owned(new ReturnStmt(ReturnLoc, RetValExp));
}
-Sema::StmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc,
- bool IsSimple,
- bool IsVolatile,
- unsigned NumOutputs,
- unsigned NumInputs,
- std::string *Names,
- ExprTy **constraints,
- ExprTy **exprs,
- ExprTy *asmString,
- unsigned NumClobbers,
- ExprTy **clobbers,
- SourceLocation RParenLoc) {
- StringLiteral **Constraints = reinterpret_cast<StringLiteral**>(constraints);
- Expr **Exprs = reinterpret_cast<Expr **>(exprs);
- StringLiteral *AsmString = cast<StringLiteral>((Expr *)asmString);
- StringLiteral **Clobbers = reinterpret_cast<StringLiteral**>(clobbers);
-
+Sema::OwningStmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc,
+ bool IsSimple,
+ bool IsVolatile,
+ unsigned NumOutputs,
+ unsigned NumInputs,
+ std::string *Names,
+ MultiExprArg constraints,
+ MultiExprArg exprs,
+ ExprArg asmString,
+ MultiExprArg clobbers,
+ SourceLocation RParenLoc) {
+ unsigned NumClobbers = clobbers.size();
+ StringLiteral **Constraints =
+ reinterpret_cast<StringLiteral**>(constraints.get());
+ Expr **Exprs = reinterpret_cast<Expr **>(exprs.get());
+ StringLiteral *AsmString = cast<StringLiteral>((Expr *)asmString.get());
+ StringLiteral **Clobbers = reinterpret_cast<StringLiteral**>(clobbers.get());
+
// The parser verifies that there is a string literal here.
if (AsmString->isWide())
- // FIXME: We currently leak memory here.
- return Diag(AsmString->getLocStart(), diag::err_asm_wide_character)
- << AsmString->getSourceRange();
-
-
+ return StmtError(Diag(AsmString->getLocStart(),diag::err_asm_wide_character)
+ << AsmString->getSourceRange());
+
+
for (unsigned i = 0; i != NumOutputs; i++) {
StringLiteral *Literal = Constraints[i];
if (Literal->isWide())
- // FIXME: We currently leak memory here.
- return Diag(Literal->getLocStart(), diag::err_asm_wide_character)
- << Literal->getSourceRange();
-
+ return StmtError(Diag(Literal->getLocStart(),diag::err_asm_wide_character)
+ << Literal->getSourceRange());
+
std::string OutputConstraint(Literal->getStrData(),
Literal->getByteLength());
-
+
TargetInfo::ConstraintInfo info;
if (!Context.Target.validateOutputConstraint(OutputConstraint.c_str(),info))
- // FIXME: We currently leak memory here.
- return Diag(Literal->getLocStart(),
- diag::err_asm_invalid_output_constraint) << OutputConstraint;
-
+ return StmtError(Diag(Literal->getLocStart(),
+ diag::err_asm_invalid_output_constraint) << OutputConstraint);
+
// Check that the output exprs are valid lvalues.
ParenExpr *OutputExpr = cast<ParenExpr>(Exprs[i]);
Expr::isLvalueResult Result = OutputExpr->isLvalue(Context);
if (Result != Expr::LV_Valid) {
- // FIXME: We currently leak memory here.
- return Diag(OutputExpr->getSubExpr()->getLocStart(),
+ return StmtError(Diag(OutputExpr->getSubExpr()->getLocStart(),
diag::err_asm_invalid_lvalue_in_output)
- << OutputExpr->getSubExpr()->getSourceRange();
+ << OutputExpr->getSubExpr()->getSourceRange());
}
}
-
+
for (unsigned i = NumOutputs, e = NumOutputs + NumInputs; i != e; i++) {
StringLiteral *Literal = Constraints[i];
if (Literal->isWide())
- // FIXME: We currently leak memory here.
- return Diag(Literal->getLocStart(), diag::err_asm_wide_character)
- << Literal->getSourceRange();
-
- std::string InputConstraint(Literal->getStrData(),
+ return StmtError(Diag(Literal->getLocStart(),diag::err_asm_wide_character)
+ << Literal->getSourceRange());
+
+ std::string InputConstraint(Literal->getStrData(),
Literal->getByteLength());
-
+
TargetInfo::ConstraintInfo info;
if (!Context.Target.validateInputConstraint(InputConstraint.c_str(),
&Names[0],
&Names[0] + NumOutputs, info)) {
- // FIXME: We currently leak memory here.
- return Diag(Literal->getLocStart(),
- diag::err_asm_invalid_input_constraint) << InputConstraint;
+ return StmtError(Diag(Literal->getLocStart(),
+ diag::err_asm_invalid_input_constraint) << InputConstraint);
}
-
+
// Check that the input exprs aren't of type void.
ParenExpr *InputExpr = cast<ParenExpr>(Exprs[i]);
if (InputExpr->getType()->isVoidType()) {
-
- // FIXME: We currently leak memory here.
- return Diag(InputExpr->getSubExpr()->getLocStart(),
+
+ return StmtError(Diag(InputExpr->getSubExpr()->getLocStart(),
diag::err_asm_invalid_type_in_input)
<< InputExpr->getType() << InputConstraint
- << InputExpr->getSubExpr()->getSourceRange();
+ << InputExpr->getSubExpr()->getSourceRange());
}
-
+
if (info & TargetInfo::CI_AllowsRegister)
DefaultFunctionArrayConversion(Exprs[i]);
}
-
+
// Check that the clobbers are valid.
for (unsigned i = 0; i != NumClobbers; i++) {
StringLiteral *Literal = Clobbers[i];
if (Literal->isWide())
- // FIXME: We currently leak memory here.
- return Diag(Literal->getLocStart(), diag::err_asm_wide_character)
- << Literal->getSourceRange();
-
- llvm::SmallString<16> Clobber(Literal->getStrData(),
- Literal->getStrData() +
+ return StmtError(Diag(Literal->getLocStart(),diag::err_asm_wide_character)
+ << Literal->getSourceRange());
+
+ llvm::SmallString<16> Clobber(Literal->getStrData(),
+ Literal->getStrData() +
Literal->getByteLength());
-
+
if (!Context.Target.isValidGCCRegisterName(Clobber.c_str()))
- // FIXME: We currently leak memory here.
- return Diag(Literal->getLocStart(),
- diag::err_asm_unknown_register_name) << Clobber.c_str();
+ return StmtError(Diag(Literal->getLocStart(),
+ diag::err_asm_unknown_register_name) << Clobber.c_str());
}
-
- return new AsmStmt(AsmLoc, IsSimple, IsVolatile, NumOutputs, NumInputs,
- Names, Constraints, Exprs, AsmString, NumClobbers,
- Clobbers, RParenLoc);
+
+ constraints.release();
+ exprs.release();
+ asmString.release();
+ clobbers.release();
+ return Owned(new AsmStmt(AsmLoc, IsSimple, IsVolatile, NumOutputs, NumInputs,
+ Names, Constraints, Exprs, AsmString, NumClobbers,
+ Clobbers, RParenLoc));
}
Action::StmtResult
More information about the cfe-commits
mailing list