/// MSAsmStmt - This represents a MS inline-assembly statement extension.
///
class MSAsmStmt : public Stmt {
- SourceLocation AsmLoc, EndLoc;
+ SourceLocation AsmLoc, LBraceLoc, EndLoc;
std::string AsmStr;
bool IsSimple;
StringRef *Clobbers;
public:
- MSAsmStmt(ASTContext &C, SourceLocation asmloc, bool issimple,
- bool isvolatile, ArrayRef<Token> asmtoks, StringRef asmstr,
- ArrayRef<StringRef> clobbers, SourceLocation endloc);
+ MSAsmStmt(ASTContext &C, SourceLocation asmloc, SourceLocation lbraceloc,
+ bool issimple, bool isvolatile, ArrayRef<Token> asmtoks,
+ StringRef asmstr, ArrayRef<StringRef> clobbers,
+ SourceLocation endloc);
SourceLocation getAsmLoc() const { return AsmLoc; }
void setAsmLoc(SourceLocation L) { AsmLoc = L; }
+ SourceLocation getLBraceLoc() const { return LBraceLoc; }
+ void setLBraceLoc(SourceLocation L) { LBraceLoc = L; }
SourceLocation getEndLoc() const { return EndLoc; }
void setEndLoc(SourceLocation L) { EndLoc = L; }
+ bool hasBraces() const { return LBraceLoc.isValid(); }
+
unsigned getNumAsmToks() { return NumAsmToks; }
Token *getAsmToks() { return AsmToks; }
bool MSAsm = false);
StmtResult ActOnMSAsmStmt(SourceLocation AsmLoc,
+ SourceLocation LBraceLoc,
ArrayRef<Token> AsmToks,
SourceLocation EndLoc);
std::copy(clobbers, clobbers + NumClobbers, Clobbers);
}
-MSAsmStmt::MSAsmStmt(ASTContext &C, SourceLocation asmloc,
+MSAsmStmt::MSAsmStmt(ASTContext &C,
+ SourceLocation asmloc, SourceLocation lbraceloc,
bool issimple, bool isvolatile, ArrayRef<Token> asmtoks,
StringRef asmstr, ArrayRef<StringRef> clobbers,
SourceLocation endloc)
- : Stmt(MSAsmStmtClass), AsmLoc(asmloc), EndLoc(endloc),
+ : Stmt(MSAsmStmtClass), AsmLoc(asmloc), LBraceLoc(lbraceloc), EndLoc(endloc),
AsmStr(asmstr.str()), IsSimple(issimple), IsVolatile(isvolatile),
NumAsmToks(asmtoks.size()), NumClobbers(clobbers.size()) {
void StmtPrinter::VisitMSAsmStmt(MSAsmStmt *Node) {
// FIXME: Implement MS style inline asm statement printer.
- Indent() << "asm ()";
+ Indent() << "__asm ";
+ if (Node->hasBraces())
+ OS << "{\n";
+ OS << *(Node->getAsmString()) << "\n";
+ if (Node->hasBraces())
+ Indent() << "}\n";
}
void StmtPrinter::VisitObjCAtTryStmt(ObjCAtTryStmt *Node) {
}
// FIXME: We should be passing source locations for better diagnostics.
- return Actions.ActOnMSAsmStmt(AsmLoc, llvm::makeArrayRef(AsmToks), EndLoc);
+ return Actions.ActOnMSAsmStmt(AsmLoc, LBraceLoc,
+ llvm::makeArrayRef(AsmToks), EndLoc);
}
/// ParseAsmStatement - Parse a GNU extended asm statement.
}
StmtResult Sema::ActOnMSAsmStmt(SourceLocation AsmLoc,
+ SourceLocation LBraceLoc,
ArrayRef<Token> AsmToks,
SourceLocation EndLoc) {
// MS-style inline assembly is not fully supported, so emit a warning.
if (AsmToks.empty()) {
StringRef AsmString;
MSAsmStmt *NS =
- new (Context) MSAsmStmt(Context, AsmLoc, /* IsSimple */ true,
- /* IsVolatile */ true, AsmToks, AsmString,
- Clobbers, EndLoc);
+ new (Context) MSAsmStmt(Context, AsmLoc, LBraceLoc,
+ /* IsSimple */ true, /* IsVolatile */ true,
+ AsmToks, AsmString, Clobbers, EndLoc);
return Owned(NS);
}
// patchMSAsmStrings doesn't correctly patch non-simple asm statements.
if (!IsSimple) {
MSAsmStmt *NS =
- new (Context) MSAsmStmt(Context, AsmLoc, /* IsSimple */ true,
- /* IsVolatile */ true, AsmToks, AsmString,
- Clobbers, EndLoc);
+ new (Context) MSAsmStmt(Context, AsmLoc, LBraceLoc,
+ /* IsSimple */ true, /* IsVolatile */ true,
+ AsmToks, AsmString, Clobbers, EndLoc);
return Owned(NS);
}
}
MSAsmStmt *NS =
- new (Context) MSAsmStmt(Context, AsmLoc, IsSimple, /* IsVolatile */ true,
+ new (Context) MSAsmStmt(Context, AsmLoc, LBraceLoc,
+ IsSimple, /* IsVolatile */ true,
AsmToks, AsmString, Clobbers, EndLoc);
return Owned(NS);
/// By default, performs semantic analysis to build the new statement.
/// Subclasses may override this routine to provide different behavior.
StmtResult RebuildMSAsmStmt(SourceLocation AsmLoc,
+ SourceLocation LBraceLoc,
ArrayRef<Token> AsmToks,
SourceLocation EndLoc) {
- return getSema().ActOnMSAsmStmt(AsmLoc, AsmToks, EndLoc);
+ return getSema().ActOnMSAsmStmt(AsmLoc, LBraceLoc, AsmToks, EndLoc);
}
/// \brief Build a new Objective-C \@try statement.
ArrayRef<Token> AsmToks =
llvm::makeArrayRef(S->getAsmToks(), S->getNumAsmToks());
- return getDerived().RebuildMSAsmStmt(S->getAsmLoc(), AsmToks, S->getEndLoc());
+ return getDerived().RebuildMSAsmStmt(S->getAsmLoc(), S->getLBraceLoc(),
+ AsmToks, S->getEndLoc());
}
template<typename Derived>