aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-rc
diff options
context:
space:
mode:
authorserge-sans-paille <sguelton@mozilla.com>2022-12-12 17:02:15 +0100
committerserge-sans-paille <sguelton@mozilla.com>2022-12-23 10:31:47 +0100
commit719d98dfa841c522d8d452f0685e503538415a53 (patch)
tree6f5a3cd17dfb2f7d5c0ac34b552b693065b9b31b /llvm/tools/llvm-rc
parenta4e3457fb752d675c58fb14a3d8ed03fe218b6b0 (diff)
downloadllvm-719d98dfa841c522d8d452f0685e503538415a53.zip
llvm-719d98dfa841c522d8d452f0685e503538415a53.tar.gz
llvm-719d98dfa841c522d8d452f0685e503538415a53.tar.bz2
[clang] Use a StringRef instead of a raw char pointer to store builtin and call information
This avoids recomputing string length that is already known at compile time. It has a slight impact on preprocessing / compile time, see https://llvm-compile-time-tracker.com/compare.php?from=3f36d2d579d8b0e8824d9dd99bfa79f456858f88&to=e49640c507ddc6615b5e503144301c8e41f8f434&stat=instructions:u Differential Revision: https://reviews.llvm.org/D139881
Diffstat (limited to 'llvm/tools/llvm-rc')
-rw-r--r--llvm/tools/llvm-rc/llvm-rc.cpp28
1 files changed, 17 insertions, 11 deletions
diff --git a/llvm/tools/llvm-rc/llvm-rc.cpp b/llvm/tools/llvm-rc/llvm-rc.cpp
index 00fb9c1..ff21213 100644
--- a/llvm/tools/llvm-rc/llvm-rc.cpp
+++ b/llvm/tools/llvm-rc/llvm-rc.cpp
@@ -55,11 +55,13 @@ enum ID {
#undef OPTION
};
-#define PREFIX(NAME, VALUE) const char *const NAME[] = VALUE;
+namespace rc_opt {
+#define PREFIX(NAME, VALUE) \
+ static constexpr std::initializer_list<StringLiteral> NAME = VALUE;
#include "Opts.inc"
#undef PREFIX
-static constexpr opt::OptTable::Info InfoTable[] = {
+static constexpr std::initializer_list<opt::OptTable::Info> InfoTable = {
#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
HELPTEXT, METAVAR, VALUES) \
{ \
@@ -70,10 +72,11 @@ static constexpr opt::OptTable::Info InfoTable[] = {
#include "Opts.inc"
#undef OPTION
};
+} // namespace rc_opt
class RcOptTable : public opt::OptTable {
public:
- RcOptTable() : OptTable(InfoTable, /* IgnoreCase = */ true) {}
+ RcOptTable() : OptTable(rc_opt::InfoTable, /* IgnoreCase = */ true) {}
};
enum Windres_ID {
@@ -85,25 +88,28 @@ enum Windres_ID {
#undef OPTION
};
-#define PREFIX(NAME, VALUE) const char *const WINDRES_##NAME[] = VALUE;
+namespace windres_opt {
+#define PREFIX(NAME, VALUE) \
+ static constexpr std::initializer_list<StringLiteral> NAME = VALUE;
#include "WindresOpts.inc"
#undef PREFIX
-static constexpr opt::OptTable::Info WindresInfoTable[] = {
+static constexpr std::initializer_list<opt::OptTable::Info> InfoTable = {
#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
HELPTEXT, METAVAR, VALUES) \
- { \
- WINDRES_##PREFIX, NAME, HELPTEXT, \
- METAVAR, WINDRES_##ID, opt::Option::KIND##Class, \
- PARAM, FLAGS, WINDRES_##GROUP, \
- WINDRES_##ALIAS, ALIASARGS, VALUES},
+ {PREFIX, NAME, HELPTEXT, \
+ METAVAR, WINDRES_##ID, opt::Option::KIND##Class, \
+ PARAM, FLAGS, WINDRES_##GROUP, \
+ WINDRES_##ALIAS, ALIASARGS, VALUES},
#include "WindresOpts.inc"
#undef OPTION
};
+} // namespace windres_opt
class WindresOptTable : public opt::OptTable {
public:
- WindresOptTable() : OptTable(WindresInfoTable, /* IgnoreCase = */ false) {}
+ WindresOptTable()
+ : OptTable(windres_opt::InfoTable, /* IgnoreCase = */ false) {}
};
static ExitOnError ExitOnErr;