aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/Lex/LexerTest.cpp
diff options
context:
space:
mode:
authorErich Keane <erich.keane@intel.com>2017-06-15 18:34:47 +0000
committerErich Keane <erich.keane@intel.com>2017-06-15 18:34:47 +0000
commitcb7af85b902eafedd180adde6c614ff9dfa09905 (patch)
tree35d027cd3d9afba8e601314a4a4f6b30639264a8 /clang/unittests/Lex/LexerTest.cpp
parentb4733ca8c5e5dedfaa1ed60163a05a13c05440b5 (diff)
downloadllvm-cb7af85b902eafedd180adde6c614ff9dfa09905.zip
llvm-cb7af85b902eafedd180adde6c614ff9dfa09905.tar.gz
llvm-cb7af85b902eafedd180adde6c614ff9dfa09905.tar.bz2
LexerTest memory leak fix-
A new LexerTest unittest introduced a memory leak. This patch uses a unique_ptr with a custom deleter to ensure it is properly deleted. llvm-svn: 305491
Diffstat (limited to 'clang/unittests/Lex/LexerTest.cpp')
-rw-r--r--clang/unittests/Lex/LexerTest.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/clang/unittests/Lex/LexerTest.cpp b/clang/unittests/Lex/LexerTest.cpp
index 4bb3553..a887c22 100644
--- a/clang/unittests/Lex/LexerTest.cpp
+++ b/clang/unittests/Lex/LexerTest.cpp
@@ -402,7 +402,9 @@ TEST_F(LexerTest, DontOverallocateStringifyArgs) {
ArgTokens.push_back(tok);
}
- MacroArgs *MA = MacroArgs::create(MI, ArgTokens, false, *PP);
+ auto MacroArgsDeleter = [&PP](MacroArgs *M) { M->destroy(*PP); };
+ std::unique_ptr<MacroArgs, decltype(MacroArgsDeleter)> MA(
+ MacroArgs::create(MI, ArgTokens, false, *PP), MacroArgsDeleter);
Token Result = MA->getStringifiedArgument(0, *PP, {}, {});
EXPECT_EQ(tok::string_literal, Result.getKind());
EXPECT_STREQ("\"\\\"StrArg\\\"\"", Result.getLiteralData());