]> granicus.if.org Git - clang/commitdiff
Keep track of whether the asm is volatile or not.
authorAnders Carlsson <andersca@mac.com>
Fri, 23 Nov 2007 23:12:25 +0000 (23:12 +0000)
committerAnders Carlsson <andersca@mac.com>
Fri, 23 Nov 2007 23:12:25 +0000 (23:12 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44297 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 9a4d4347b608212afdf85a3175be607fcf7ed20e..6663d6f88b0dbfe1cdc7bc6be730c97d0102b9ac 100644 (file)
@@ -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]);
index cc6ffda86da3598e60d3ada9abfbd79b646541e9..c68257ec3365272e5a1b0397def96776aa9f795c 100644 (file)
@@ -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
index 46f8559c6c118e602f7199409a12cb19c7be9f91..3134f8859c478a6abb7644bb0347756566750be9 100644 (file)
@@ -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);  
 
index 5a5217131b80630751184cd1b4c03b19d4dfcb48..5184ebcd08f51e3173cba947c0edb30b5ae9c455 100644 (file)
@@ -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],
index f747cefcb23c0c24cca5691d0260365774c70aee..16d4cabb7eb4e156924a1aa9c74f9209d01db948 100644 (file)
@@ -347,6 +347,7 @@ public:
                                      ExprTy *RetValExp);
   
   virtual StmtResult ActOnAsmStmt(SourceLocation AsmLoc,
+                                  bool IsVolatile,
                                   unsigned NumOutputs,
                                   unsigned NumInputs,
                                   std::string *Names,
index 00685c2824585b8c74c9c9038120439bb45c5206..d99356edc1926f4f1bf09bc48ab1f504526f0ac3 100644 (file)
@@ -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,
index 7516705a073799dcb17de8c1d9fa0f7b0a42a5af..7e6f39dd7707005441c5826731d4e96b943fc643 100644 (file)
@@ -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]; }
index 9f599c422da448a79b0af04ac9ccc69638fc9c6c..5f6a1469e384e3c8ad22faeac4a2b5314b724822 100644 (file)
@@ -287,6 +287,7 @@ public:
     return 0;
   }
   virtual StmtResult ActOnAsmStmt(SourceLocation AsmLoc,
+                                  bool IsVolatile,
                                   unsigned NumOutputs,
                                   unsigned NumInputs,
                                   std::string *Names,