[llvm] [TableGen] Detect invalid -D arguments and fail. (PR #102813)
Sergei Barannikov via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 12 09:40:40 PDT 2024
================
@@ -54,9 +74,17 @@ TGLexer::TGLexer(SourceMgr &SM, ArrayRef<std::string> Macros) : SrcMgr(SM) {
PrepIncludeStack.push_back(
std::make_unique<std::vector<PreprocessorControlDesc>>());
- // Put all macros defined in the command line into the DefinedMacros set.
- for (const std::string &MacroName : Macros)
+ // Add all macros defined on the command line to the DefinedMacros set.
+ // Check invalid macro names and print fatal error if we find one.
+ for (const std::string &MacroName : Macros) {
+ const char *Begin = MacroName.c_str();
+ const char *End = lexMacroName(Begin);
----------------
s-barannikov wrote:
https://en.cppreference.com/w/cpp/string/basic_string/data
> The returned array is null-terminated, that is, data() and [c_str()](https://en.cppreference.com/w/cpp/string/basic_string/c_str) perform the same function.
> If [empty()](https://en.cppreference.com/w/cpp/string/basic_string/empty) returns true, the pointer points to a single null character.
> (since C++11)
https://github.com/llvm/llvm-project/pull/102813
More information about the llvm-commits
mailing list