[clang-tools-extra] [pseudo] gen Main.cpp (PR #74983)

εΎζŒζ’ Xu Chiheng via cfe-commits cfe-commits at lists.llvm.org
Sat Dec 9 23:28:35 PST 2023


https://github.com/xu-chiheng created https://github.com/llvm/llvm-project/pull/74983

None

>From 02cbefc8112d73b11f835da30db4ed3344db9d48 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:27:25 +0800
Subject: [PATCH] 1

---
 clang-tools-extra/pseudo/gen/Main.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/clang-tools-extra/pseudo/gen/Main.cpp b/clang-tools-extra/pseudo/gen/Main.cpp
index 25cb26563837a6..c9367ca16ed85e 100644
--- a/clang-tools-extra/pseudo/gen/Main.cpp
+++ b/clang-tools-extra/pseudo/gen/Main.cpp
@@ -70,13 +70,13 @@ namespace {
 //   keyword: `INT` becomes `INT`;
 //   terminal: `IDENTIFIER` becomes `IDENTIFIER`;
 std::string mangleSymbol(SymbolID SID, const Grammar &G) {
-  static auto &TokNames = *new std::vector<std::string>{
-#define TOK(X) llvm::StringRef(#X).upper(),
-#define KEYWORD(Keyword, Condition) llvm::StringRef(#Keyword).upper(),
+  static char const * TokNames[] = {
+#define TOK(X) #X ,
+#define KEYWORD(Keyword, Condition) #Keyword ,
 #include "clang/Basic/TokenKinds.def"
       };
   if (isToken(SID))
-    return TokNames[symbolToToken(SID)];
+    return llvm::StringRef(TokNames[symbolToToken(SID)]).upper();
   std::string Name = G.symbolName(SID).str();
   // translation-unit -> translation_unit
   std::replace(Name.begin(), Name.end(), '-', '_');



More information about the cfe-commits mailing list