[cfe-commits] r161686 - in /cfe/trunk: include/clang/AST/Stmt.h lib/AST/Stmt.cpp lib/Sema/SemaStmt.cpp

Chad Rosier mcrosier at apple.com
Fri Aug 10 12:13:14 PDT 2012


Author: mcrosier
Date: Fri Aug 10 14:13:14 2012
New Revision: 161686

URL: http://llvm.org/viewvc/llvm-project?rev=161686&view=rev
Log:
[ms-inline asm] Add clobbers to AST representation.

Modified:
    cfe/trunk/include/clang/AST/Stmt.h
    cfe/trunk/lib/AST/Stmt.cpp
    cfe/trunk/lib/Sema/SemaStmt.cpp

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=161686&r1=161685&r2=161686&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Fri Aug 10 14:13:14 2012
@@ -1628,16 +1628,18 @@
 
   unsigned NumAsmToks;
   unsigned NumLineEnds;
+  unsigned NumClobbers;
 
   Token *AsmToks;
   unsigned *LineEnds;
   Stmt **Exprs;
+  std::string *Clobbers;
 
 public:
   MSAsmStmt(ASTContext &C, SourceLocation asmloc, bool issimple,
             bool isvolatile, ArrayRef<Token> asmtoks,
             ArrayRef<unsigned> lineends, StringRef asmstr,
-            SourceLocation endloc);
+            ArrayRef<std::string> clobbers, SourceLocation endloc);
 
   SourceLocation getAsmLoc() const { return AsmLoc; }
   void setAsmLoc(SourceLocation L) { AsmLoc = L; }
@@ -1662,6 +1664,9 @@
 
   //===--- Other ---===//
 
+  unsigned getNumClobbers() const { return NumClobbers; }
+  StringRef getClobber(unsigned i) { return Clobbers[i]; }
+
   SourceRange getSourceRange() const LLVM_READONLY {
     return SourceRange(AsmLoc, EndLoc);
   }

Modified: cfe/trunk/lib/AST/Stmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Stmt.cpp?rev=161686&r1=161685&r2=161686&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Stmt.cpp (original)
+++ cfe/trunk/lib/AST/Stmt.cpp Fri Aug 10 14:13:14 2012
@@ -586,10 +586,11 @@
 MSAsmStmt::MSAsmStmt(ASTContext &C, SourceLocation asmloc,
                      bool issimple, bool isvolatile, ArrayRef<Token> asmtoks,
                      ArrayRef<unsigned> lineends, StringRef asmstr,
-                     SourceLocation endloc)
+                     ArrayRef<std::string> clobbers, SourceLocation endloc)
   : Stmt(MSAsmStmtClass), AsmLoc(asmloc), EndLoc(endloc),
     AsmStr(asmstr.str()), IsSimple(issimple), IsVolatile(isvolatile),
-    NumAsmToks(asmtoks.size()), NumLineEnds(lineends.size()) {
+    NumAsmToks(asmtoks.size()), NumLineEnds(lineends.size()),
+    NumClobbers(clobbers.size()) {
 
   AsmToks = new (C) Token[NumAsmToks];
   for (unsigned i = 0, e = NumAsmToks; i != e; ++i)
@@ -598,6 +599,10 @@
   LineEnds = new (C) unsigned[NumLineEnds];
   for (unsigned i = 0, e = NumLineEnds; i != e; ++i)
     LineEnds[i] = lineends[i];
+
+  Clobbers = new (C) std::string[NumClobbers];
+  for (unsigned i = 0, e = NumClobbers; i != e; ++i)
+    Clobbers[i] = clobbers[i];
 }
 
 ObjCForCollectionStmt::ObjCForCollectionStmt(Stmt *Elem, Expr *Collect,

Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=161686&r1=161685&r2=161686&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Fri Aug 10 14:13:14 2012
@@ -2883,6 +2883,7 @@
                                 SourceLocation EndLoc) {
   // MS-style inline assembly is not fully supported, so emit a warning.
   Diag(AsmLoc, diag::warn_unsupported_msasm);
+  SmallVector<std::string,4> Clobbers;
 
   // Empty asm statements don't need to instantiate the AsmParser, etc.
   if (AsmToks.empty()) {
@@ -2890,7 +2891,7 @@
     MSAsmStmt *NS =
       new (Context) MSAsmStmt(Context, AsmLoc, /* IsSimple */ true,
                               /* IsVolatile */ true, AsmToks, LineEnds,
-                              AsmString, EndLoc);
+                              AsmString, Clobbers, EndLoc);
     return Owned(NS);
   }
 
@@ -2937,7 +2938,7 @@
 
   MSAsmStmt *NS =
     new (Context) MSAsmStmt(Context, AsmLoc, IsSimple, /* IsVolatile */ true,
-                            AsmToks, LineEnds, AsmString, EndLoc);
+                            AsmToks, LineEnds, AsmString, Clobbers, EndLoc);
 
   return Owned(NS);
 }





More information about the cfe-commits mailing list