[cfe-commits] r161373 - in /cfe/trunk: include/clang/AST/Stmt.h include/clang/Sema/Sema.h lib/AST/Stmt.cpp lib/Parse/ParseStmt.cpp lib/Sema/SemaStmt.cpp lib/Sema/TreeTransform.h
Chad Rosier
mcrosier at apple.com
Mon Aug 6 17:29:06 PDT 2012
Author: mcrosier
Date: Mon Aug 6 19:29:06 2012
New Revision: 161373
URL: http://llvm.org/viewvc/llvm-project?rev=161373&view=rev
Log:
[ms-inline asm] Stmt destructors are never called, so allocate the AsmToks using
the ASTContext BumpPtr. Also use the preferred llvm::ArrayRef interface.
Modified:
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/Stmt.cpp
cfe/trunk/lib/Parse/ParseStmt.cpp
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/lib/Sema/TreeTransform.h
Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=161373&r1=161372&r2=161373&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Mon Aug 6 19:29:06 2012
@@ -1621,17 +1621,19 @@
///
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; }
@@ -1639,7 +1641,8 @@
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; }
Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=161373&r1=161372&r2=161373&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Mon Aug 6 19:29:06 2012
@@ -2543,7 +2543,7 @@
bool MSAsm = false);
StmtResult ActOnMSAsmStmt(SourceLocation AsmLoc,
- SmallVectorImpl<Token> &AsmToks,
+ ArrayRef<Token> AsmToks,
std::string &AsmString,
SourceLocation EndLoc);
Modified: cfe/trunk/lib/AST/Stmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Stmt.cpp?rev=161373&r1=161372&r2=161373&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Stmt.cpp (original)
+++ cfe/trunk/lib/AST/Stmt.cpp Mon Aug 6 19:29:06 2012
@@ -584,13 +584,14 @@
}
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,
Modified: cfe/trunk/lib/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=161373&r1=161372&r2=161373&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseStmt.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmt.cpp Mon Aug 6 19:29:06 2012
@@ -1818,7 +1818,8 @@
// 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.
Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=161373&r1=161372&r2=161373&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Mon Aug 6 19:29:06 2012
@@ -2748,7 +2748,7 @@
}
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.
Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=161373&r1=161372&r2=161373&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Mon Aug 6 19:29:06 2012
@@ -1185,7 +1185,7 @@
/// 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);
@@ -5610,9 +5610,11 @@
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());
}
More information about the cfe-commits
mailing list