[clang-tools-extra] 47ec8b5 - [pseudo] Fix leaks after D126731
Fangrui Song via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 3 18:43:21 PDT 2022
Author: Fangrui Song
Date: 2022-06-03T18:43:16-07:00
New Revision: 47ec8b557416682a10970d07f536f9cd303d2c0c
URL: https://github.com/llvm/llvm-project/commit/47ec8b557416682a10970d07f536f9cd303d2c0c
DIFF: https://github.com/llvm/llvm-project/commit/47ec8b557416682a10970d07f536f9cd303d2c0c.diff
LOG: [pseudo] Fix leaks after D126731
Array Operator new Cookies help lsan find allocations, while std::array
can't.
Added:
Modified:
clang-tools-extra/pseudo/lib/grammar/Grammar.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/pseudo/lib/grammar/Grammar.cpp b/clang-tools-extra/pseudo/lib/grammar/Grammar.cpp
index d974d807d2547..2be34f8bec683 100644
--- a/clang-tools-extra/pseudo/lib/grammar/Grammar.cpp
+++ b/clang-tools-extra/pseudo/lib/grammar/Grammar.cpp
@@ -168,13 +168,13 @@ std::vector<llvm::DenseSet<SymbolID>> followSets(const Grammar &G) {
static llvm::ArrayRef<std::string> getTerminalNames() {
static const auto &TerminalNames = []() {
- auto &TerminalNames = *new std::array<std::string, NumTerminals>;
+ auto TerminalNames = new std::string[NumTerminals];
#define PUNCTUATOR(Tok, Spelling) TerminalNames[tok::Tok] = Spelling;
#define KEYWORD(Keyword, Condition) \
TerminalNames[tok::kw_##Keyword] = llvm::StringRef(#Keyword).upper();
#define TOK(Tok) TerminalNames[tok::Tok] = llvm::StringRef(#Tok).upper();
#include "clang/Basic/TokenKinds.def"
- return TerminalNames;
+ return llvm::makeArrayRef(TerminalNames, NumTerminals);
}();
return TerminalNames;
}
More information about the cfe-commits
mailing list