[clang] [NFC][clang] replace a C-array with std::array (PR #158047)
Nathan Gauër via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 11 04:59:32 PDT 2025
https://github.com/Keenuts updated https://github.com/llvm/llvm-project/pull/158047
>From e42d05ca3c20817d9869f3e4cc3b98087b285175 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nathan=20Gau=C3=ABr?= <brioche at google.com>
Date: Thu, 11 Sep 2025 13:46:04 +0200
Subject: [PATCH 1/2] [NFC][clang] replace a C-array with std::array
Follow up to #157841, replacing the C-array with std::array
so iterators can be used.
---
clang/utils/TableGen/ClangAttrEmitter.cpp | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp
index 2e2f32a7a1cb1..cc558722ed6e9 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -5163,7 +5163,7 @@ enum class SpellingKind : size_t {
static const size_t NumSpellingKinds = (size_t)SpellingKind::NumSpellingKinds;
class SpellingList {
- std::vector<std::string> Spellings[NumSpellingKinds];
+ std::array<std::vector<std::string>, NumSpellingKinds> Spellings;
public:
ArrayRef<std::string> operator[](SpellingKind K) const {
@@ -5211,11 +5211,7 @@ class SpellingList {
}
bool hasSpelling() const {
- for (size_t Kind = 0; Kind < NumSpellingKinds; ++Kind) {
- if (Spellings[Kind].size() > 0)
- return true;
- }
- return false;
+ return llvm::any_of(Spellings, [](const auto &L) { return L.size() != 0; });
}
};
>From b839ed73f38a7a5c441c7dc20af3657be3216372 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nathan=20Gau=C3=ABr?= <github at keenuts.net>
Date: Thu, 11 Sep 2025 13:59:23 +0200
Subject: [PATCH 2/2] Update clang/utils/TableGen/ClangAttrEmitter.cpp
Co-authored-by: Nikolas Klauser <nikolasklauser at berlin.de>
---
clang/utils/TableGen/ClangAttrEmitter.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp
index cc558722ed6e9..50a3ba261b8f2 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -5211,7 +5211,7 @@ class SpellingList {
}
bool hasSpelling() const {
- return llvm::any_of(Spellings, [](const auto &L) { return L.size() != 0; });
+ return llvm::any_of(Spellings, [](const auto &L) { return !L.empty(); });
}
};
More information about the cfe-commits
mailing list