aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AST/Stmt.cpp3
-rw-r--r--AST/StmtPrinter.cpp7
-rw-r--r--AST/StmtSerialization.cpp4
-rw-r--r--Parse/ParseStmt.cpp4
-rw-r--r--Sema/Sema.h1
-rw-r--r--Sema/SemaStmt.cpp4
-rw-r--r--include/clang/AST/Stmt.h5
-rw-r--r--include/clang/Parse/Action.h1
8 files changed, 23 insertions, 6 deletions
diff --git a/AST/Stmt.cpp b/AST/Stmt.cpp
index 9a4d4347b6..6663d6f88b 100644
--- a/AST/Stmt.cpp
+++ b/AST/Stmt.cpp
@@ -112,6 +112,7 @@ bool Stmt::hasImplicitControlFlow() const {
}
AsmStmt::AsmStmt(SourceLocation asmloc,
+ bool isvolatile,
unsigned numoutputs,
unsigned numinputs,
std::string *names,
@@ -122,7 +123,7 @@ AsmStmt::AsmStmt(SourceLocation asmloc,
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]);
diff --git a/AST/StmtPrinter.cpp b/AST/StmtPrinter.cpp
index cc6ffda86d..c68257ec33 100644
--- a/AST/StmtPrinter.cpp
+++ b/AST/StmtPrinter.cpp
@@ -326,7 +326,12 @@ void StmtPrinter::VisitReturnStmt(ReturnStmt *Node) {
void StmtPrinter::VisitAsmStmt(AsmStmt *Node) {
- Indent() << "asm (";
+ Indent() << "asm ";
+
+ if (Node->isVolatile())
+ OS << "volatile ";
+
+ OS << "(";
VisitStringLiteral(Node->getAsmString());
// Outputs
diff --git a/AST/StmtSerialization.cpp b/AST/StmtSerialization.cpp
index 46f8559c6c..3134f8859c 100644
--- a/AST/StmtSerialization.cpp
+++ b/AST/StmtSerialization.cpp
@@ -201,6 +201,7 @@ void AsmStmt::EmitImpl(Serializer& S) const {
getAsmString()->EmitImpl(S);
S.Emit(RParenLoc);
+ S.EmitBool(IsVolatile);
S.EmitInt(NumOutputs);
S.EmitInt(NumInputs);
@@ -225,7 +226,8 @@ AsmStmt* AsmStmt::CreateImpl(Deserializer& D) {
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);
diff --git a/Parse/ParseStmt.cpp b/Parse/ParseStmt.cpp
index 5a5217131b..5184ebcd08 100644
--- a/Parse/ParseStmt.cpp
+++ b/Parse/ParseStmt.cpp
@@ -934,7 +934,7 @@ Parser::StmtResult Parser::ParseAsmStatement() {
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 @@ Parser::StmtResult Parser::ParseAsmStatement() {
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],
diff --git a/Sema/Sema.h b/Sema/Sema.h
index f747cefcb2..16d4cabb7e 100644
--- a/Sema/Sema.h
+++ b/Sema/Sema.h
@@ -347,6 +347,7 @@ public:
ExprTy *RetValExp);
virtual StmtResult ActOnAsmStmt(SourceLocation AsmLoc,
+ bool IsVolatile,
unsigned NumOutputs,
unsigned NumInputs,
std::string *Names,
diff --git a/Sema/SemaStmt.cpp b/Sema/SemaStmt.cpp
index 00685c2824..d99356edc1 100644
--- a/Sema/SemaStmt.cpp
+++ b/Sema/SemaStmt.cpp
@@ -645,6 +645,7 @@ Sema::ActOnReturnStmt(SourceLocation ReturnLoc, ExprTy *rex) {
}
Sema::StmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc,
+ bool IsVolatile,
unsigned NumOutputs,
unsigned NumInputs,
std::string *Names,
@@ -655,7 +656,7 @@ Sema::StmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc,
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 @@ Sema::StmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc,
}
return new AsmStmt(AsmLoc,
+ IsVolatile,
NumOutputs,
NumInputs,
Names,
diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h
index 7516705a07..7e6f39dd77 100644
--- a/include/clang/AST/Stmt.h
+++ b/include/clang/AST/Stmt.h
@@ -707,6 +707,8 @@ class AsmStmt : public Stmt {
SourceLocation AsmLoc, RParenLoc;
StringLiteral *AsmStr;
+ bool IsVolatile;
+
unsigned NumOutputs;
unsigned NumInputs;
@@ -717,6 +719,7 @@ class AsmStmt : public Stmt {
llvm::SmallVector<StringLiteral*, 4> Clobbers;
public:
AsmStmt(SourceLocation asmloc,
+ bool isvolatile,
unsigned numoutputs,
unsigned numinputs,
std::string *names,
@@ -727,6 +730,8 @@ public:
StringLiteral **clobbers,
SourceLocation rparenloc);
+ bool isVolatile() const { return IsVolatile; }
+
unsigned getNumOutputs() const { return NumOutputs; }
const std::string &getOutputName(unsigned i) const
{ return Names[i]; }
diff --git a/include/clang/Parse/Action.h b/include/clang/Parse/Action.h
index 9f599c422d..5f6a1469e3 100644
--- a/include/clang/Parse/Action.h
+++ b/include/clang/Parse/Action.h
@@ -287,6 +287,7 @@ public:
return 0;
}
virtual StmtResult ActOnAsmStmt(SourceLocation AsmLoc,
+ bool IsVolatile,
unsigned NumOutputs,
unsigned NumInputs,
std::string *Names,