[clang-tools-extra] Refactor clang doc comment structure (PR #142273)
Paul Kirth via cfe-commits
cfe-commits at lists.llvm.org
Sun Jun 1 10:25:08 PDT 2025
================
@@ -26,6 +26,66 @@
namespace clang {
namespace doc {
+CommentKind stringToCommentKind(llvm::StringRef KindStr) {
+ if (KindStr == "FullComment")
+ return CommentKind::CK_FullComment;
----------------
ilovepi wrote:
IDK if the huge set of conditionals is great. There are a lot of options here, even in C++17 (though 20 or 23 would add more). The simplest is to have a const table of string literals with some static asserts about the enum value range and the size of the table (e.g. the number of elements in the enum matches the array bounds.
It may be worth seeing how tablegen handles this, since I think it generates a large number of such conversions. There are also data structures in ADT that could help. I know we have a suffix tree, and a number of map types.
That said StringMap seems preferable over the number of string comparisons happening here, so if we can't do something clever w/ constexpr or templates (even then I wouldn't want anything *too* complicated), lets make this a const initialized StringMap, and just do the lookup.
https://github.com/llvm/llvm-project/pull/142273
More information about the cfe-commits
mailing list