[cfe-commits] r44297 - in /cfe/trunk: AST/Stmt.cpp AST/StmtPrinter.cpp AST/StmtSerialization.cpp Parse/ParseStmt.cpp Sema/Sema.h Sema/SemaStmt.cpp include/clang/AST/Stmt.h include/clang/Parse/Action.h
Anders Carlsson
andersca at mac.com
Fri Nov 23 15:12:26 PST 2007
Author: andersca
Date: Fri Nov 23 17:12:25 2007
New Revision: 44297
URL: http://llvm.org/viewvc/llvm-project?rev=44297&view=rev
Log:
Keep track of whether the asm is volatile or not.
Modified:
cfe/trunk/AST/Stmt.cpp
cfe/trunk/AST/StmtPrinter.cpp
cfe/trunk/AST/StmtSerialization.cpp
cfe/trunk/Parse/ParseStmt.cpp
cfe/trunk/Sema/Sema.h
cfe/trunk/Sema/SemaStmt.cpp
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/include/clang/Parse/Action.h
Modified: cfe/trunk/AST/Stmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/Stmt.cpp?rev=44297&r1=44296&r2=44297&view=diff
==============================================================================
--- cfe/trunk/AST/Stmt.cpp (original)
+++ cfe/trunk/AST/Stmt.cpp Fri Nov 23 17:12:25 2007
@@ -112,6 +112,7 @@
}
AsmStmt::AsmStmt(SourceLocation asmloc,
+ bool isvolatile,
unsigned numoutputs,
unsigned numinputs,
std::string *names,
@@ -122,7 +123,7 @@
StringLiteral **clobbers,
SourceLocation rparenloc)
: Stmt(AsmStmtClass), AsmLoc(asmloc), RParenLoc(rparenloc), AsmStr(asmstr)
- , NumOutputs(numoutputs), NumInputs(numinputs)
+ , IsVolatile(isvolatile), NumOutputs(numoutputs), NumInputs(numinputs)
{
for (unsigned i = 0, e = numinputs + numoutputs; i != e; i++) {
Names.push_back(names[i]);
Modified: cfe/trunk/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/StmtPrinter.cpp?rev=44297&r1=44296&r2=44297&view=diff
==============================================================================
--- cfe/trunk/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/AST/StmtPrinter.cpp Fri Nov 23 17:12:25 2007
@@ -326,7 +326,12 @@
void StmtPrinter::VisitAsmStmt(AsmStmt *Node) {
- Indent() << "asm (";
+ Indent() << "asm ";
+
+ if (Node->isVolatile())
+ OS << "volatile ";
+
+ OS << "(";
VisitStringLiteral(Node->getAsmString());
// Outputs
Modified: cfe/trunk/AST/StmtSerialization.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/StmtSerialization.cpp?rev=44297&r1=44296&r2=44297&view=diff
==============================================================================
--- cfe/trunk/AST/StmtSerialization.cpp (original)
+++ cfe/trunk/AST/StmtSerialization.cpp Fri Nov 23 17:12:25 2007
@@ -201,6 +201,7 @@
getAsmString()->EmitImpl(S);
S.Emit(RParenLoc);
+ S.EmitBool(IsVolatile);
S.EmitInt(NumOutputs);
S.EmitInt(NumInputs);
@@ -225,7 +226,8 @@
StringLiteral *AsmStr = StringLiteral::CreateImpl(D);
SourceLocation PLoc = SourceLocation::ReadVal(D);
- AsmStmt *Stmt = new AsmStmt(ALoc, 0, 0, 0, 0, 0,
+ bool IsVolatile = D.ReadBool();
+ AsmStmt *Stmt = new AsmStmt(ALoc, IsVolatile, 0, 0, 0, 0, 0,
AsmStr,
0, 0, PLoc);
Modified: cfe/trunk/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/ParseStmt.cpp?rev=44297&r1=44296&r2=44297&view=diff
==============================================================================
--- cfe/trunk/Parse/ParseStmt.cpp (original)
+++ cfe/trunk/Parse/ParseStmt.cpp Fri Nov 23 17:12:25 2007
@@ -934,7 +934,7 @@
Diag(Loc, diag::w_asm_qualifier_ignored, "restrict");
// Remember if this was a volatile asm.
- //bool isVolatile = DS.TypeQualifiers & DeclSpec::TQ_volatile;
+ bool isVolatile = DS.getTypeQualifiers() & DeclSpec::TQ_volatile;
if (Tok.isNot(tok::l_paren)) {
Diag(Tok, diag::err_expected_lparen_after, "asm");
@@ -986,7 +986,7 @@
SourceLocation RParenLoc = MatchRHSPunctuation(tok::r_paren, Loc);
- return Actions.ActOnAsmStmt(AsmLoc, NumOutputs, NumInputs,
+ return Actions.ActOnAsmStmt(AsmLoc, isVolatile, NumOutputs, NumInputs,
&Names[0], &Constraints[0], &Exprs[0],
AsmString.Val,
Clobbers.size(), &Clobbers[0],
Modified: cfe/trunk/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/Sema.h?rev=44297&r1=44296&r2=44297&view=diff
==============================================================================
--- cfe/trunk/Sema/Sema.h (original)
+++ cfe/trunk/Sema/Sema.h Fri Nov 23 17:12:25 2007
@@ -347,6 +347,7 @@
ExprTy *RetValExp);
virtual StmtResult ActOnAsmStmt(SourceLocation AsmLoc,
+ bool IsVolatile,
unsigned NumOutputs,
unsigned NumInputs,
std::string *Names,
Modified: cfe/trunk/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaStmt.cpp?rev=44297&r1=44296&r2=44297&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/Sema/SemaStmt.cpp Fri Nov 23 17:12:25 2007
@@ -645,6 +645,7 @@
}
Sema::StmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc,
+ bool IsVolatile,
unsigned NumOutputs,
unsigned NumInputs,
std::string *Names,
@@ -655,7 +656,7 @@
ExprTy **Clobbers,
SourceLocation RParenLoc) {
Expr *E = (Expr *)AsmString;
-
+
// Check that the output exprs are valid lvalues.
for (unsigned i = 0; i < NumOutputs; i++) {
Expr *OutputExpr = (Expr *)Exprs[i];
@@ -691,6 +692,7 @@
}
return new AsmStmt(AsmLoc,
+ IsVolatile,
NumOutputs,
NumInputs,
Names,
Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=44297&r1=44296&r2=44297&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Fri Nov 23 17:12:25 2007
@@ -707,6 +707,8 @@
SourceLocation AsmLoc, RParenLoc;
StringLiteral *AsmStr;
+ bool IsVolatile;
+
unsigned NumOutputs;
unsigned NumInputs;
@@ -717,6 +719,7 @@
llvm::SmallVector<StringLiteral*, 4> Clobbers;
public:
AsmStmt(SourceLocation asmloc,
+ bool isvolatile,
unsigned numoutputs,
unsigned numinputs,
std::string *names,
@@ -727,6 +730,8 @@
StringLiteral **clobbers,
SourceLocation rparenloc);
+ bool isVolatile() const { return IsVolatile; }
+
unsigned getNumOutputs() const { return NumOutputs; }
const std::string &getOutputName(unsigned i) const
{ return Names[i]; }
Modified: cfe/trunk/include/clang/Parse/Action.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Action.h?rev=44297&r1=44296&r2=44297&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Action.h (original)
+++ cfe/trunk/include/clang/Parse/Action.h Fri Nov 23 17:12:25 2007
@@ -287,6 +287,7 @@
return 0;
}
virtual StmtResult ActOnAsmStmt(SourceLocation AsmLoc,
+ bool IsVolatile,
unsigned NumOutputs,
unsigned NumInputs,
std::string *Names,
More information about the cfe-commits
mailing list