[llvm] [TableGen] Detect invalid -D arguments and fail (PR #102813)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 13 10:45:29 PDT 2024
================
@@ -44,6 +44,28 @@ constexpr PreprocessorDir PreprocessorDirs[] = {{tgtok::Ifdef, "ifdef"},
{tgtok::Endif, "endif"},
{tgtok::Define, "define"}};
+// Returns a pointer past the end of a valid macro name at the start of `Str`.
+// Valid macro names match the regular expression [a-zA-Z_][0-9a-zA-Z_]*.
+static const char *lexMacroName(StringRef Str) {
+ assert(!Str.empty());
+
+ const char *Next = Str.begin();
+
+ // Macro names start with [a-zA-Z_].
+ if (*Next != '_' && !isalpha(*Next))
+ return Next;
+
+ // Eat the first character of the name.
+ Next++;
----------------
MaskRay wrote:
coding standard prefers `++Next`
https://github.com/llvm/llvm-project/pull/102813
More information about the llvm-commits
mailing list