]> granicus.if.org Git - clang/commitdiff
[AST] Use StringRef's convenient copy method. No functionality change.
authorBenjamin Kramer <benny.kra@googlemail.com>
Tue, 4 Aug 2015 10:22:38 +0000 (10:22 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Tue, 4 Aug 2015 10:22:38 +0000 (10:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@243966 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/Stmt.cpp

index 181a3b4666b961e7af28ccf00eb2205fc17aa702..771aeefda74df6b6ac7564c3862e26f7b0bb5466 100644 (file)
@@ -724,12 +724,7 @@ MSAsmStmt::MSAsmStmt(const ASTContext &C, SourceLocation asmloc,
 }
 
 static StringRef copyIntoContext(const ASTContext &C, StringRef str) {
-  if (str.empty())
-    return StringRef();
-  size_t size = str.size();
-  char *buffer = new (C) char[size];
-  memcpy(buffer, str.data(), size);
-  return StringRef(buffer, size);
+  return str.copy(C.getAllocator());
 }
 
 void MSAsmStmt::initialize(const ASTContext &C, StringRef asmstr,