///
class MSAsmStmt : public Stmt {
SourceLocation AsmLoc, EndLoc;
- SmallVector<Token, 4> AsmToks;
std::string AsmStr;
bool IsSimple;
bool IsVolatile;
+ unsigned NumAsmToks;
+
+ Token *AsmToks;
Stmt **Exprs;
public:
MSAsmStmt(ASTContext &C, SourceLocation asmloc,
- SmallVectorImpl<Token> &asmtoks, std::string &asmstr,
+ ArrayRef<Token> asmtoks, std::string &asmstr,
SourceLocation endloc);
SourceLocation getAsmLoc() const { return AsmLoc; }
SourceLocation getEndLoc() const { return EndLoc; }
void setEndLoc(SourceLocation L) { EndLoc = L; }
- SmallVectorImpl<Token> &getAsmToks() { return AsmToks; }
+ unsigned getNumAsmToks() { return NumAsmToks; }
+ Token *getAsmToks() { return AsmToks; }
bool isVolatile() const { return IsVolatile; }
void setVolatile(bool V) { IsVolatile = V; }
bool MSAsm = false);
StmtResult ActOnMSAsmStmt(SourceLocation AsmLoc,
- SmallVectorImpl<Token> &AsmToks,
+ ArrayRef<Token> AsmToks,
std::string &AsmString,
SourceLocation EndLoc);
}
MSAsmStmt::MSAsmStmt(ASTContext &C, SourceLocation asmloc,
- SmallVectorImpl<Token> &asmtoks,
+ ArrayRef<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]);
+ AsmStr(asmstr), IsSimple(true), IsVolatile(true), NumAsmToks(asmtoks.size()) {
+
+ AsmToks = new (C) Token[NumAsmToks];
+ for (unsigned i = 0, e = NumAsmToks; i != e; ++i)
+ AsmToks[i] = asmtoks[i];
}
ObjCForCollectionStmt::ObjCForCollectionStmt(Stmt *Elem, Expr *Collect,
// FIXME: We should be passing source locations for better diagnostics.
std::string AsmString = Asm.c_str();
- return Actions.ActOnMSAsmStmt(AsmLoc, AsmToks, AsmString, EndLoc);
+ return Actions.ActOnMSAsmStmt(AsmLoc, llvm::makeArrayRef(AsmToks), AsmString,
+ EndLoc);
}
/// ParseAsmStatement - Parse a GNU extended asm statement.
}
StmtResult Sema::ActOnMSAsmStmt(SourceLocation AsmLoc,
- SmallVectorImpl<Token> &AsmToks,
+ ArrayRef<Token> AsmToks,
std::string &AsmString,
SourceLocation EndLoc) {
// MS-style inline assembly is not fully supported, so emit a warning.
/// 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,
+ ArrayRef<Token> AsmToks,
std::string &AsmString,
SourceLocation EndLoc) {
return getSema().ActOnMSAsmStmt(AsmLoc, AsmToks, AsmString, EndLoc);
template<typename Derived>
StmtResult
TreeTransform<Derived>::TransformMSAsmStmt(MSAsmStmt *S) {
+ ArrayRef<Token> AsmToks =
+ llvm::makeArrayRef(S->getAsmToks(), S->getNumAsmToks());
// No need to transform the asm string literal.
return getDerived().RebuildMSAsmStmt(S->getAsmLoc(),
- S->getAsmToks(),
+ AsmToks,
*S->getAsmString(),
S->getEndLoc());
}