summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Stmt.cpp
diff options
context:
space:
mode:
authorChad Rosier <mcrosier@apple.com>2012-08-10 21:06:19 +0000
committerChad Rosier <mcrosier@apple.com>2012-08-10 21:06:19 +0000
commitd6ef704fe4b33b3c62ed25ad6ea0877bf266ee82 (patch)
tree42cba03deebf74b44fb64b164bd9448c1ede0d1e /clang/lib/AST/Stmt.cpp
parent4c923b3b3fd0ac1edebf0603265ca3ba51724937 (diff)
downloadbcm5719-llvm-d6ef704fe4b33b3c62ed25ad6ea0877bf266ee82.tar.gz
bcm5719-llvm-d6ef704fe4b33b3c62ed25ad6ea0877bf266ee82.zip
[ms-inline asm] Fix a memory leak introduced in r161686.
llvm-svn: 161698
Diffstat (limited to 'clang/lib/AST/Stmt.cpp')
-rw-r--r--clang/lib/AST/Stmt.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/clang/lib/AST/Stmt.cpp b/clang/lib/AST/Stmt.cpp
index 9bf9980004f..c9cca556f49 100644
--- a/clang/lib/AST/Stmt.cpp
+++ b/clang/lib/AST/Stmt.cpp
@@ -586,7 +586,7 @@ AsmStmt::AsmStmt(ASTContext &C, SourceLocation asmloc, bool issimple,
MSAsmStmt::MSAsmStmt(ASTContext &C, SourceLocation asmloc,
bool issimple, bool isvolatile, ArrayRef<Token> asmtoks,
ArrayRef<unsigned> lineends, StringRef asmstr,
- ArrayRef<std::string> clobbers, SourceLocation endloc)
+ ArrayRef<StringRef> clobbers, SourceLocation endloc)
: Stmt(MSAsmStmtClass), AsmLoc(asmloc), EndLoc(endloc),
AsmStr(asmstr.str()), IsSimple(issimple), IsVolatile(isvolatile),
NumAsmToks(asmtoks.size()), NumLineEnds(lineends.size()),
@@ -600,9 +600,14 @@ MSAsmStmt::MSAsmStmt(ASTContext &C, SourceLocation asmloc,
for (unsigned i = 0, e = NumLineEnds; i != e; ++i)
LineEnds[i] = lineends[i];
- Clobbers = new (C) std::string[NumClobbers];
- for (unsigned i = 0, e = NumClobbers; i != e; ++i)
- Clobbers[i] = clobbers[i];
+ Clobbers = new (C) StringRef*[NumClobbers];
+ for (unsigned i = 0, e = NumClobbers; i != e; ++i) {
+ // FIXME: Avoid the allocation/copy if at all possible.
+ size_t size = clobbers[i].size();
+ char *dest = new (C) char[size];
+ std::strncpy(dest, clobbers[i].data(), size);
+ Clobbers[i] = new (C) StringRef(dest, size);
+ }
}
ObjCForCollectionStmt::ObjCForCollectionStmt(Stmt *Elem, Expr *Collect,
OpenPOWER on IntegriCloud