[llvm] a677afd - [TableGen] Use std::size (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 26 10:47:28 PST 2022
Author: Kazu Hirata
Date: 2022-11-26T10:47:22-08:00
New Revision: a677afd3c132dd024fdf81c1bb0b256176895112
URL: https://github.com/llvm/llvm-project/commit/a677afd3c132dd024fdf81c1bb0b256176895112
DIFF: https://github.com/llvm/llvm-project/commit/a677afd3c132dd024fdf81c1bb0b256176895112.diff
LOG: [TableGen] Use std::size (NFC)
std::size, introduced in C++17, allows us to directly obtain the
number of elements of an array.
Added:
Modified:
llvm/utils/TableGen/OptParserEmitter.cpp
Removed:
################################################################################
diff --git a/llvm/utils/TableGen/OptParserEmitter.cpp b/llvm/utils/TableGen/OptParserEmitter.cpp
index 182cd0076090a..cbc63ea201402 100644
--- a/llvm/utils/TableGen/OptParserEmitter.cpp
+++ b/llvm/utils/TableGen/OptParserEmitter.cpp
@@ -448,12 +448,10 @@ void EmitOptParser(RecordKeeper &Records, raw_ostream &OS) {
OS << MarshallingInfo::ValueTablesDecl << "{";
for (auto ValueTableName : ValueTableNames)
- OS << "{" << ValueTableName << ", sizeof(" << ValueTableName
- << ") / sizeof(SimpleEnumValue)"
- << "},\n";
+ OS << "{" << ValueTableName << ", std::size(" << ValueTableName << ")},\n";
OS << "};\n";
OS << "static const unsigned SimpleEnumValueTablesSize = "
- "sizeof(SimpleEnumValueTables) / sizeof(SimpleEnumValueTable);\n";
+ "std::size(SimpleEnumValueTables);\n";
OS << "#endif // SIMPLE_ENUM_VALUE_TABLE\n";
OS << "\n";
More information about the llvm-commits
mailing list