From: Mike Stump Date: Mon, 4 Jan 2010 22:37:17 +0000 (+0000) Subject: Remember if the AsmStmt came from Microsoft-style inline assembly code. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3b11fd3b52e7b88233c602407c151d07cb093e75;p=clang Remember if the AsmStmt came from Microsoft-style inline assembly code. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92526 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h index 33edadc3a5..614723234d 100644 --- a/include/clang/AST/Stmt.h +++ b/include/clang/AST/Stmt.h @@ -1116,6 +1116,7 @@ class AsmStmt : public Stmt { bool IsSimple; bool IsVolatile; + bool MSAsm; unsigned NumOutputs; unsigned NumInputs; @@ -1126,7 +1127,7 @@ class AsmStmt : public Stmt { llvm::SmallVector Clobbers; public: - AsmStmt(SourceLocation asmloc, bool issimple, bool isvolatile, + AsmStmt(SourceLocation asmloc, bool issimple, bool isvolatile, bool msasm, unsigned numoutputs, unsigned numinputs, std::string *names, StringLiteral **constraints, Expr **exprs, StringLiteral *asmstr, unsigned numclobbers, @@ -1144,6 +1145,8 @@ public: void setVolatile(bool V) { IsVolatile = V; } bool isSimple() const { return IsSimple; } void setSimple(bool V) { IsSimple = false; } + bool isMSAsm() const { return MSAsm; } + void setMSAsm(bool V) { MSAsm = V; } //===--- Asm String Analysis ---===// diff --git a/include/clang/Parse/Action.h b/include/clang/Parse/Action.h index 4cbc21ad01..591ec47a68 100644 --- a/include/clang/Parse/Action.h +++ b/include/clang/Parse/Action.h @@ -866,7 +866,8 @@ public: MultiExprArg Exprs, ExprArg AsmString, MultiExprArg Clobbers, - SourceLocation RParenLoc) { + SourceLocation RParenLoc, + bool MSAsm = false) { return StmtEmpty(); } diff --git a/lib/AST/Stmt.cpp b/lib/AST/Stmt.cpp index 7c7aeb8d3e..104e336189 100644 --- a/lib/AST/Stmt.cpp +++ b/lib/AST/Stmt.cpp @@ -337,12 +337,12 @@ unsigned AsmStmt::AnalyzeAsmString(llvm::SmallVectorImpl&Pieces, //===----------------------------------------------------------------------===// AsmStmt::AsmStmt(SourceLocation asmloc, bool issimple, bool isvolatile, - unsigned numoutputs, unsigned numinputs, + bool msasm, unsigned numoutputs, unsigned numinputs, std::string *names, StringLiteral **constraints, Expr **exprs, StringLiteral *asmstr, unsigned numclobbers, StringLiteral **clobbers, SourceLocation rparenloc) : Stmt(AsmStmtClass), AsmLoc(asmloc), RParenLoc(rparenloc), AsmStr(asmstr) - , IsSimple(issimple), IsVolatile(isvolatile) + , IsSimple(issimple), IsVolatile(isvolatile), MSAsm(msasm) , NumOutputs(numoutputs), NumInputs(numinputs) { for (unsigned i = 0, e = numinputs + numoutputs; i != e; i++) { Names.push_back(names[i]); diff --git a/lib/Frontend/PCHReaderStmt.cpp b/lib/Frontend/PCHReaderStmt.cpp index ba82d26010..c108f549ab 100644 --- a/lib/Frontend/PCHReaderStmt.cpp +++ b/lib/Frontend/PCHReaderStmt.cpp @@ -304,6 +304,7 @@ unsigned PCHStmtReader::VisitAsmStmt(AsmStmt *S) { S->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); S->setVolatile(Record[Idx++]); S->setSimple(Record[Idx++]); + S->setMSAsm(Record[Idx++]); unsigned StackIdx = StmtStack.size() - (NumOutputs*2 + NumInputs*2 + NumClobbers + 1); diff --git a/lib/Frontend/PCHWriterStmt.cpp b/lib/Frontend/PCHWriterStmt.cpp index abf4eaa0f8..4be9b817ed 100644 --- a/lib/Frontend/PCHWriterStmt.cpp +++ b/lib/Frontend/PCHWriterStmt.cpp @@ -277,6 +277,7 @@ void PCHStmtWriter::VisitAsmStmt(AsmStmt *S) { Writer.AddSourceLocation(S->getRParenLoc(), Record); Record.push_back(S->isVolatile()); Record.push_back(S->isSimple()); + Record.push_back(S->isMSAsm()); Writer.WriteSubStmt(S->getAsmString()); // Outputs diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp index 9085b8713d..277cc91d37 100644 --- a/lib/Parse/ParseStmt.cpp +++ b/lib/Parse/ParseStmt.cpp @@ -1182,7 +1182,7 @@ Parser::OwningStmtResult Parser::FuzzyParseMicrosoftAsmStatement() { return Actions.ActOnAsmStmt(Tok.getLocation(), true, true, 0, 0, Names.data(), move_arg(Constraints), move_arg(Exprs), move(AsmString), move_arg(Clobbers), - Tok.getLocation()); + Tok.getLocation(), true); } /// ParseAsmStatement - Parse a GNU extended asm statement. diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h index 110a626835..df25025d77 100644 --- a/lib/Sema/Sema.h +++ b/lib/Sema/Sema.h @@ -1383,7 +1383,8 @@ public: MultiExprArg Exprs, ExprArg AsmString, MultiExprArg Clobbers, - SourceLocation RParenLoc); + SourceLocation RParenLoc, + bool MSAsm = false); virtual OwningStmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc, SourceLocation RParen, diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index b8928c36e7..7855a7f609 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -1157,7 +1157,8 @@ Sema::OwningStmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc, MultiExprArg exprs, ExprArg asmString, MultiExprArg clobbers, - SourceLocation RParenLoc) { + SourceLocation RParenLoc, + bool MSAsm) { unsigned NumClobbers = clobbers.size(); StringLiteral **Constraints = reinterpret_cast(constraints.get()); @@ -1261,9 +1262,9 @@ Sema::OwningStmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc, asmString.release(); clobbers.release(); AsmStmt *NS = - new (Context) AsmStmt(AsmLoc, IsSimple, IsVolatile, NumOutputs, NumInputs, - Names, Constraints, Exprs, AsmString, NumClobbers, - Clobbers, RParenLoc); + new (Context) AsmStmt(AsmLoc, IsSimple, IsVolatile, MSAsm, NumOutputs, + NumInputs, Names, Constraints, Exprs, AsmString, + NumClobbers, Clobbers, RParenLoc); // Validate the asm string, ensuring it makes sense given the operands we // have. llvm::SmallVector Pieces;