================
@@ -57,26 +57,19 @@ using namespace clang;
 #define ABSTRACT_STMT(STMT)
 #include "clang/AST/StmtNodes.inc"
 
-static struct StmtClassNameTable {
+struct StmtClassNameTable {
   const char *Name;
   unsigned Counter;
   unsigned Size;
-} StmtClassInfo[Stmt::lastStmtConstant+1];
+};
 
 static StmtClassNameTable &getStmtInfoTableEntry(Stmt::StmtClass E) {
-  static bool Initialized = false;
-  if (Initialized)
-    return StmtClassInfo[E];
-
-  // Initialize the table on the first use.
-  Initialized = true;
+  static StmtClassNameTable stmtClassInfo[Stmt::lastStmtConstant + 1] = {
 #define ABSTRACT_STMT(STMT)
-#define STMT(CLASS, PARENT) \
-  StmtClassInfo[(unsigned)Stmt::CLASS##Class].Name = #CLASS;    \
-  StmtClassInfo[(unsigned)Stmt::CLASS##Class].Size = sizeof(CLASS);
+#define STMT(CLASS, PARENT) {#CLASS, 0, sizeof(CLASS)},
----------------
jalopezg-git wrote:

Intialization seems to assume that the order in which `STMT(...)` appears in 
`clang/AST/StmtNodes.inc` follows the same order as `Stmt::CLASS##Class`.

I think this must hold, but in case in does not, unfortunately per [Aggregate 
initialization, Designated 
initializers](https://en.cppreference.com/w/cpp/language/aggregate_initialization.html),
 C++ (as opposed to C) does not support out-of-order designated initializers.

https://github.com/llvm/llvm-project/pull/181367
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to