[PATCH] D139881: [clang] Use a StringRef instead of a raw char pointer to store builtin and call information

Kadir Cetinkaya via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 13 00:45:32 PST 2022


kadircet added inline comments.


================
Comment at: clang-tools-extra/clangd/CompileCommands.cpp:470
     const char *const *Prefixes[DriverID::LastOption] = {nullptr};
-#define PREFIX(NAME, VALUE) static const char *const NAME[] = VALUE;
+#define PREFIX(NAME, VALUE) static constexpr llvm::StringLiteral NAME[] = VALUE;
 #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  \
----------------
this is actually an incorrect change (even builds shouldn't be succeeding). as the values here can also be `nullptr` (which cannot be stored in a StringLiteral) but moreover we later on assign these to `Prefixes` array, which is of type `char*`, hence the conversion should also be failing.

but in general i'd actually expect people to be assigning "nullptr"s to these `char*`s, hence if this was a purely mechanical migration without some extra constraints, it might still blow up at runtime even if it succeeds compiles.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139881/new/

https://reviews.llvm.org/D139881



More information about the cfe-commits mailing list