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 | 99fc38191b9f466fb7d44c1fddf49e766f2de565 (patch) | |
tree | ef9efe9bf1ef91d54d44b6d613a354d396d1a10a | |
parent | 754cedf23fa4451f98b2d529a9b954acd14a4738 (diff) | |
download | bcm5719-llvm-99fc38191b9f466fb7d44c1fddf49e766f2de565.tar.gz bcm5719-llvm-99fc38191b9f466fb7d44c1fddf49e766f2de565.zip |
[ms-inline asm] Stmt destructors are never called, so allocate the AsmToks using
the ASTContext BumpPtr. Also use the preferred llvm::ArrayRef interface.
llvm-svn: 161373
-rw-r--r-- | clang/include/clang/AST/Stmt.h | 9 | ||||
-rw-r--r-- | clang/include/clang/Sema/Sema.h | 2 | ||||
-rw-r--r-- | clang/lib/AST/Stmt.cpp | 11 | ||||
-rw-r--r-- | clang/lib/Parse/ParseStmt.cpp | 3 | ||||
-rw-r--r-- | clang/lib/Sema/SemaStmt.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Sema/TreeTransform.h | 6 |
6 files changed, 20 insertions, 13 deletions
diff --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h index 45e0892ce3a..8dbcf5dd5e4 100644 --- a/clang/include/clang/AST/Stmt.h +++ b/clang/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/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index f332bbeae9f..1eec97bd9f8 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/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/clang/lib/AST/Stmt.cpp b/clang/lib/AST/Stmt.cpp index 763f8bd33a3..5e7a13e09d9 100644 --- a/clang/lib/AST/Stmt.cpp +++ b/clang/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/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp index 69f28ecd6db..56e87e49044 100644 --- a/clang/lib/Parse/ParseStmt.cpp +++ b/clang/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/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp index 718a7e6b538..5df1a50655c 100644 --- a/clang/lib/Sema/SemaStmt.cpp +++ b/clang/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/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index 71af2636427..76cd51f3e8c 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/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()); } |