[clang-tools-extra] [pseudo] lib Grammar.cpp (PR #74984)

εΎζŒζ’ Xu Chiheng via cfe-commits cfe-commits at lists.llvm.org
Sun Dec 31 13:09:30 PST 2023


https://github.com/xu-chiheng updated https://github.com/llvm/llvm-project/pull/74984

>From bba8cd890cb7edcff3852ac6bf225e358d2aaac2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E6=8C=81=E6=81=92=20Xu=20Chiheng?=
 <chiheng.xu at gmail.com>
Date: Sun, 10 Dec 2023 15:31:36 +0800
Subject: [PATCH] 1

---
 clang-tools-extra/pseudo/lib/grammar/Grammar.cpp | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/clang-tools-extra/pseudo/lib/grammar/Grammar.cpp b/clang-tools-extra/pseudo/lib/grammar/Grammar.cpp
index 3e9c5c3c7a6c42..ec6e8915a2c7d7 100644
--- a/clang-tools-extra/pseudo/lib/grammar/Grammar.cpp
+++ b/clang-tools-extra/pseudo/lib/grammar/Grammar.cpp
@@ -172,9 +172,10 @@ std::vector<llvm::DenseSet<SymbolID>> followSets(const Grammar &G) {
   return FollowSets;
 }
 
+static auto TerminalNames = new std::string[NumTerminals];
+
 static llvm::ArrayRef<std::string> getTerminalNames() {
-  static const auto &TerminalNames = []() {
-    auto TerminalNames = new std::string[NumTerminals];
+  static const auto &TerminalNames1 = []() {
 #define PUNCTUATOR(Tok, Spelling) TerminalNames[tok::Tok] = Spelling;
 #define KEYWORD(Keyword, Condition)                                            \
   TerminalNames[tok::kw_##Keyword] = llvm::StringRef(#Keyword).upper();
@@ -182,7 +183,7 @@ static llvm::ArrayRef<std::string> getTerminalNames() {
 #include "clang/Basic/TokenKinds.def"
     return llvm::ArrayRef(TerminalNames, NumTerminals);
   }();
-  return TerminalNames;
+  return TerminalNames1;
 }
 GrammarTable::GrammarTable() : Terminals(getTerminalNames()) {}
 



More information about the cfe-commits mailing list