You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
mozcpp: parse a string literal followed by a PRI*/SCN* format macro #1266
The C++ grammar only accepts an identifier before a string literal in a concatenated_string, so PRIi32 "%" parses but "%" PRIi32 produces an ERROR node:
nsPrintfCString("%" PRIi32, lifetime.mTag);
This is one of the most common patterns in mozilla-central: the <inttypes.h> format macros (PRIu32, PRIx64, PRId64, ...) are used after a string literal throughout MOZ_LOG, nsPrintfCString, printf_stderr, SprintfLiteral and similar calls. test_fn_id_strings in src/c_langs_macros/mod.rs covers exactly this case and has been #[ignore]d since #1141.
Replacing predefined macros with $ characters (c_macro::replace) doesn't help: "%" $$$$$$ fails the same way. And it's only applied when preprocessor results are available anyway.
Allowing any identifier after a string literal would be ambiguous with things like extern "C" MOZ_EXPORT void f();. A narrower fix in tree-sitter-mozcpp is to accept the <inttypes.h> format macros (PRI*/SCN*) as members of a concatenated_string, and then un-ignore test_fn_id_strings.
Activity