diff options
author | Chad Rosier <mcrosier@apple.com> | 2012-08-10 19:13:14 +0000 |
---|---|---|
committer | Chad Rosier <mcrosier@apple.com> | 2012-08-10 19:13:14 +0000 |
commit | 4399ea9d473365224d9e4db0cd94aab849eb59b7 (patch) | |
tree | abb9c64ea22cdb4e7157efd71907dc39e4b9b072 | |
parent | 6bd3291605a3034b858c8aeecc6990fa4f979f6c (diff) |
[ms-inline asm] Add clobbers to AST representation.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161686 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/AST/Stmt.h | 7 | ||||
-rw-r--r-- | lib/AST/Stmt.cpp | 9 | ||||
-rw-r--r-- | lib/Sema/SemaStmt.cpp | 5 |
3 files changed, 16 insertions, 5 deletions
diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h index f119637af9..8d4bd1f583 100644 --- a/include/clang/AST/Stmt.h +++ b/include/clang/AST/Stmt.h @@ -1628,16 +1628,18 @@ class MSAsmStmt : public Stmt { 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 @@ public: //===--- Other ---===// + unsigned getNumClobbers() const { return NumClobbers; } + StringRef getClobber(unsigned i) { return Clobbers[i]; } + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(AsmLoc, EndLoc); } diff --git a/lib/AST/Stmt.cpp b/lib/AST/Stmt.cpp index f676711d7c..9bf9980004 100644 --- a/lib/AST/Stmt.cpp +++ b/lib/AST/Stmt.cpp @@ -586,10 +586,11 @@ AsmStmt::AsmStmt(ASTContext &C, SourceLocation asmloc, bool issimple, 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 @@ MSAsmStmt::MSAsmStmt(ASTContext &C, SourceLocation asmloc, 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, diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index 56ac7c5d46..716f4df526 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -2883,6 +2883,7 @@ StmtResult Sema::ActOnMSAsmStmt(SourceLocation AsmLoc, 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 @@ StmtResult Sema::ActOnMSAsmStmt(SourceLocation AsmLoc, 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 @@ StmtResult Sema::ActOnMSAsmStmt(SourceLocation AsmLoc, MSAsmStmt *NS = new (Context) MSAsmStmt(Context, AsmLoc, IsSimple, /* IsVolatile */ true, - AsmToks, LineEnds, AsmString, EndLoc); + AsmToks, LineEnds, AsmString, Clobbers, EndLoc); return Owned(NS); } |