diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index a4b61b9074d91..387e360e0c694 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -719,6 +719,8 @@ Bug Fixes in This Version virtual member functions even if the target required a greater function alignment and/or did not have function pointers which point to function entry points (i.e., uses function descriptor objects instead). +- Fixes a ``clang-17`` regression where ``LLVM_UNREACHABLE_OPTIMIZE=OFF`` + cannot be used with ``Release`` mode builds. (`#68237 `_). Bug Fixes to Compiler Builtins ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp index 8ef728f86c6b8..b5813c6abc2b9 100644 --- a/clang/utils/TableGen/ClangAttrEmitter.cpp +++ b/clang/utils/TableGen/ClangAttrEmitter.cpp @@ -2639,7 +2639,8 @@ static void emitAttributes(RecordKeeper &Records, raw_ostream &OS, OS << ", "; emitFormInitializer(OS, Spellings[0], "0"); } else { - OS << ", (\n"; + OS << ", [&]() {\n"; + OS << " switch (S) {\n"; std::set Uniques; unsigned Idx = 0; for (auto I = Spellings.begin(), E = Spellings.end(); I != E; @@ -2647,15 +2648,19 @@ static void emitAttributes(RecordKeeper &Records, raw_ostream &OS, const FlattenedSpelling &S = *I; const auto &Name = SemanticToSyntacticMap[Idx]; if (Uniques.insert(Name).second) { - OS << " S == " << Name << " ? AttributeCommonInfo::Form"; + OS << " case " << Name << ":\n"; + OS << " return AttributeCommonInfo::Form"; emitFormInitializer(OS, S, Name); - OS << " :\n"; + OS << ";\n"; } } - OS << " (llvm_unreachable(\"Unknown attribute spelling!\"), " - << " AttributeCommonInfo::Form"; + OS << " default:\n"; + OS << " llvm_unreachable(\"Unknown attribute spelling!\");\n" + << " return AttributeCommonInfo::Form"; emitFormInitializer(OS, Spellings[0], "0"); - OS << "))"; + OS << ";\n" + << " }\n" + << " }()"; } OS << ");\n";