@@ -6128,20 +6128,21 @@ static bool isKeywordInCPlusPlus(const Sema &S, const IdentifierInfo *II) {
61286128 // or not. Note, this treats all keywords as being enabled, regardless of the
61296129 // setting of other language options. It intentionally disables the modules
61306130 // keywords because those are conditional keywords, so may be safe to use.
6131- static std::array<uintptr_t, countCPlusPlusKeywords()> Keywords = {};
6132- if (!Keywords[0]) {
6131+ static auto Keywords = [&S] {
6132+ std::array<uintptr_t, countCPlusPlusKeywords()> Ret;
61336133 unsigned Idx = 0;
61346134#define MODULES_KEYWORD(NAME)
61356135#define KEYWORD(NAME, FLAGS) \
6136- Keywords [Idx++] = reinterpret_cast<uint64_t>( \
6136+ Ret [Idx++] = reinterpret_cast<uint64_t>( \
61376137 &S.getPreprocessor().getIdentifierTable().get(#NAME));
61386138#define CXX_KEYWORD_OPERATOR(NAME, TOK) \
6139- Keywords [Idx++] = reinterpret_cast<uint64_t>( \
6139+ Ret [Idx++] = reinterpret_cast<uint64_t>( \
61406140 &S.getPreprocessor().getIdentifierTable().get(#NAME));
61416141#include "clang/Basic/TokenKinds.def"
6142- assert(Idx == Keywords.size() && "expected to fill every member!");
6143- llvm::sort(Keywords);
6144- }
6142+ assert(Idx == Ret.size() && "expected to fill every member!");
6143+ llvm::sort(Ret);
6144+ return Ret;
6145+ }();
61456146
61466147 return llvm::binary_search(Keywords, reinterpret_cast<uintptr_t>(II));
61476148}
0 commit comments