From d5b5a8fae59b609c5e26c63c9e39b8441aa1085d Mon Sep 17 00:00:00 2001 From: Erich Keane Date: Thu, 15 Jun 2017 18:34:47 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305491 91177308-0d34-0410-b5e6-96231b3b80d8 --- unittests/Lex/LexerTest.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/unittests/Lex/LexerTest.cpp b/unittests/Lex/LexerTest.cpp index 4bb355393f..a887c22bd3 100644 --- a/unittests/Lex/LexerTest.cpp +++ b/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 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()); -- 2.40.0