[clang] Revert "[AST][NFC] Use struct as string table for AttrDoc" (PR #246984)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Nov 29 07:19:43 PST 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Alexis Engelke (aengelke)
<details>
<summary>Changes</summary>
Old MSVC doesn't support this type of assignment in constexpr constructor.
Reverts llvm/llvm-project#<!-- -->246953
---
Full diff: https://github.com/llvm/llvm-project/pull/246984.diff
2 Files Affected:
- (modified) clang/lib/AST/AttrDocTable.cpp (+6-9)
- (modified) clang/utils/TableGen/ClangAttrEmitter.cpp (+2-2)
``````````diff
diff --git a/clang/lib/AST/AttrDocTable.cpp b/clang/lib/AST/AttrDocTable.cpp
index 58015773688a87..56a143b9ed29be 100644
--- a/clang/lib/AST/AttrDocTable.cpp
+++ b/clang/lib/AST/AttrDocTable.cpp
@@ -13,18 +13,15 @@
#include "clang/AST/Attr.h"
#include "llvm/ADT/StringRef.h"
-llvm::StringRef clang::Attr::getDocumentation(clang::attr::Kind K) {
- static constexpr struct {
-#define ATTR_DOC_STR(ATTR, STR) char ATTR[sizeof(STR)] = STR;
#include "AttrDocTable.inc"
- } StrTab;
- static constexpr uint32_t Offsets[] = {
-#define ATTR(NAME) offsetof(decltype(StrTab), NAME),
+static const llvm::StringRef AttrDoc[] = {
+#define ATTR(NAME) AttrDoc_##NAME,
#include "clang/Basic/AttrList.inc"
- };
+};
- if (K < (int)std::size(Offsets))
- return llvm::StringRef((const char *)&StrTab + Offsets[K]);
+llvm::StringRef clang::Attr::getDocumentation(clang::attr::Kind K) {
+ if (K < (int)std::size(AttrDoc))
+ return AttrDoc[K];
return "";
}
diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp
index 54f1a1f1cc65a7..060c7a403f2b17 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -5496,8 +5496,8 @@ void EmitClangAttrDocTable(const RecordKeeper &Records, raw_ostream &OS) {
// (Currently there's only one such attr, revisit if this becomes common).
StringRef Text =
Docs.front()->getValueAsOptionalString("Content").value_or("");
- OS << "\nATTR_DOC_STR(" << A->getName() << ", "
- << "R\"reST(" << Text.trim() << ")reST\")\n";
+ OS << "\nstatic const char AttrDoc_" << A->getName() << "[] = "
+ << "R\"reST(" << Text.trim() << ")reST\";\n";
}
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/246984
More information about the cfe-commits
mailing list