diff options
author | Chad Rosier <mcrosier@apple.com> | 2012-08-06 20:03:45 +0000 |
---|---|---|
committer | Chad Rosier <mcrosier@apple.com> | 2012-08-06 20:03:45 +0000 |
commit | 8f726de55412870ef70e788b852c6cc50873e15b (patch) | |
tree | 329890730d3048e4c6de8eb79ae2de053c83fe46 | |
parent | cc83f26c48dfdc99ea5fbc3c28c9c9653bd71e8c (diff) |
[ms-inline asm] Pass Tokens to Sema and store them in the AST. No functional
change intended. No test case as there's no real way to test at this time.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161342 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/AST/Stmt.h | 7 | ||||
-rw-r--r-- | include/clang/Sema/Sema.h | 1 | ||||
-rw-r--r-- | lib/AST/Stmt.cpp | 10 | ||||
-rw-r--r-- | lib/Parse/ParseStmt.cpp | 7 | ||||
-rw-r--r-- | lib/Sema/SemaStmt.cpp | 3 | ||||
-rw-r--r-- | lib/Sema/TreeTransform.h | 4 |
6 files changed, 21 insertions, 11 deletions
diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h index 2ac503aa61..45e0892ce3 100644 --- a/include/clang/AST/Stmt.h +++ b/include/clang/AST/Stmt.h @@ -20,6 +20,7 @@ #include "clang/AST/StmtIterator.h" #include "clang/AST/DeclGroup.h" #include "clang/AST/Attr.h" +#include "clang/Lex/Token.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/raw_ostream.h" @@ -1620,6 +1621,7 @@ public: /// class MSAsmStmt : public Stmt { SourceLocation AsmLoc, EndLoc; + SmallVector<Token, 4> AsmToks; std::string AsmStr; bool IsSimple; @@ -1628,7 +1630,8 @@ class MSAsmStmt : public Stmt { Stmt **Exprs; public: - MSAsmStmt(ASTContext &C, SourceLocation asmloc, std::string &asmstr, + MSAsmStmt(ASTContext &C, SourceLocation asmloc, + SmallVectorImpl<Token> &asmtoks, std::string &asmstr, SourceLocation endloc); SourceLocation getAsmLoc() const { return AsmLoc; } @@ -1636,6 +1639,8 @@ public: SourceLocation getEndLoc() const { return EndLoc; } void setEndLoc(SourceLocation L) { EndLoc = L; } + SmallVectorImpl<Token> &getAsmToks() { return AsmToks; } + bool isVolatile() const { return IsVolatile; } void setVolatile(bool V) { IsVolatile = V; } bool isSimple() const { return IsSimple; } diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index 80e4692c06..179359869a 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -2543,6 +2543,7 @@ public: bool MSAsm = false); StmtResult ActOnMSAsmStmt(SourceLocation AsmLoc, + SmallVectorImpl<Token> &AsmToks, std::string &AsmString, SourceLocation EndLoc); diff --git a/lib/AST/Stmt.cpp b/lib/AST/Stmt.cpp index ff6374c2d8..763f8bd33a 100644 --- a/lib/AST/Stmt.cpp +++ b/lib/AST/Stmt.cpp @@ -583,10 +583,14 @@ AsmStmt::AsmStmt(ASTContext &C, SourceLocation asmloc, bool issimple, std::copy(clobbers, clobbers + NumClobbers, Clobbers); } -MSAsmStmt::MSAsmStmt(ASTContext &C, SourceLocation asmloc, std::string &asmstr, - SourceLocation endloc) - : Stmt(MSAsmStmtClass), AsmLoc(asmloc), EndLoc(endloc), AsmStr(asmstr), +MSAsmStmt::MSAsmStmt(ASTContext &C, SourceLocation asmloc, + SmallVectorImpl<Token> &asmtoks, + std::string &asmstr, SourceLocation endloc) + : Stmt(MSAsmStmtClass), AsmLoc(asmloc), EndLoc(endloc), + AsmToks(asmtoks.size()), AsmStr(asmstr), IsSimple(true), IsVolatile(true) { + for (unsigned i = 0, e = asmtoks.size(); i != e; ++i) + AsmToks.push_back(asmtoks[i]); } ObjCForCollectionStmt::ObjCForCollectionStmt(Stmt *Elem, Expr *Collect, diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp index e13ce6b407..69f28ecd6d 100644 --- a/lib/Parse/ParseStmt.cpp +++ b/lib/Parse/ParseStmt.cpp @@ -1816,12 +1816,9 @@ StmtResult Parser::ParseMicrosoftAsmStatement(SourceLocation AsmLoc) { } } - // FIXME: We should be passing the tokens and source locations, rather than - // (or possibly in addition to the) AsmString. Sema is going to interact with - // MC to determine Constraints, Clobbers, etc., which would be simplest to - // do with the tokens. + // FIXME: We should be passing source locations for better diagnostics. std::string AsmString = Asm.c_str(); - return Actions.ActOnMSAsmStmt(AsmLoc, AsmString, EndLoc); + return Actions.ActOnMSAsmStmt(AsmLoc, AsmToks, AsmString, EndLoc); } /// ParseAsmStatement - Parse a GNU extended asm statement. diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index 4612930d45..718a7e6b53 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -2748,13 +2748,14 @@ StmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc, bool IsSimple, } StmtResult Sema::ActOnMSAsmStmt(SourceLocation AsmLoc, + SmallVectorImpl<Token> &AsmToks, std::string &AsmString, SourceLocation EndLoc) { // MS-style inline assembly is not fully supported, so emit a warning. Diag(AsmLoc, diag::warn_unsupported_msasm); MSAsmStmt *NS = - new (Context) MSAsmStmt(Context, AsmLoc, AsmString, EndLoc); + new (Context) MSAsmStmt(Context, AsmLoc, AsmToks, AsmString, EndLoc); return Owned(NS); } diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h index 0dd9d9c191..71af263642 100644 --- a/lib/Sema/TreeTransform.h +++ b/lib/Sema/TreeTransform.h @@ -1185,9 +1185,10 @@ public: /// By default, performs semantic analysis to build the new statement. /// Subclasses may override this routine to provide different behavior. StmtResult RebuildMSAsmStmt(SourceLocation AsmLoc, + SmallVectorImpl<Token> &AsmToks, std::string &AsmString, SourceLocation EndLoc) { - return getSema().ActOnMSAsmStmt(AsmLoc, AsmString, EndLoc); + return getSema().ActOnMSAsmStmt(AsmLoc, AsmToks, AsmString, EndLoc); } /// \brief Build a new Objective-C \@try statement. @@ -5611,6 +5612,7 @@ StmtResult TreeTransform<Derived>::TransformMSAsmStmt(MSAsmStmt *S) { // No need to transform the asm string literal. return getDerived().RebuildMSAsmStmt(S->getAsmLoc(), + S->getAsmToks(), *S->getAsmString(), S->getEndLoc()); } |