diff options
author | Chad Rosier <mcrosier@apple.com> | 2012-08-07 00:29:06 +0000 |
---|---|---|
committer | Chad Rosier <mcrosier@apple.com> | 2012-08-07 00:29:06 +0000 |
commit | 79efe24e125553b7fd4a35ffb3b7a45c4f1e661a (patch) | |
tree | 675ab3b90c2cfc01d8c4b2a69ff8bc8b0d1be98d | |
parent | b3f46ec9a479725f54790b8b49cb1636aa2a15c3 (diff) |
[ms-inline asm] Stmt destructors are never called, so allocate the AsmToks using
the ASTContext BumpPtr. Also use the preferred llvm::ArrayRef interface.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161373 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/AST/Stmt.h | 9 | ||||
-rw-r--r-- | include/clang/Sema/Sema.h | 2 | ||||
-rw-r--r-- | lib/AST/Stmt.cpp | 11 | ||||
-rw-r--r-- | lib/Parse/ParseStmt.cpp | 3 | ||||
-rw-r--r-- | lib/Sema/SemaStmt.cpp | 2 | ||||
-rw-r--r-- | lib/Sema/TreeTransform.h | 6 |
6 files changed, 20 insertions, 13 deletions
diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h index 45e0892ce3..8dbcf5dd5e 100644 --- a/include/clang/AST/Stmt.h +++ b/include/clang/AST/Stmt.h @@ -1621,17 +1621,19 @@ public: /// 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 @@ public: 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; } diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index f332bbeae9..1eec97bd9f 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -2543,7 +2543,7 @@ public: bool MSAsm = false); StmtResult ActOnMSAsmStmt(SourceLocation AsmLoc, - SmallVectorImpl<Token> &AsmToks, + ArrayRef<Token> AsmToks, std::string &AsmString, SourceLocation EndLoc); diff --git a/lib/AST/Stmt.cpp b/lib/AST/Stmt.cpp index 763f8bd33a..5e7a13e09d 100644 --- a/lib/AST/Stmt.cpp +++ b/lib/AST/Stmt.cpp @@ -584,13 +584,14 @@ AsmStmt::AsmStmt(ASTContext &C, SourceLocation asmloc, bool issimple, } 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, diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp index 69f28ecd6d..56e87e4904 100644 --- a/lib/Parse/ParseStmt.cpp +++ b/lib/Parse/ParseStmt.cpp @@ -1818,7 +1818,8 @@ StmtResult Parser::ParseMicrosoftAsmStatement(SourceLocation AsmLoc) { // 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. diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index 718a7e6b53..5df1a50655 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -2748,7 +2748,7 @@ StmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc, bool IsSimple, } 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. diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h index 71af263642..76cd51f3e8 100644 --- a/lib/Sema/TreeTransform.h +++ b/lib/Sema/TreeTransform.h @@ -1185,7 +1185,7 @@ 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, + ArrayRef<Token> AsmToks, std::string &AsmString, SourceLocation EndLoc) { return getSema().ActOnMSAsmStmt(AsmLoc, AsmToks, AsmString, EndLoc); @@ -5610,9 +5610,11 @@ TreeTransform<Derived>::TransformAsmStmt(AsmStmt *S) { 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()); } |