On Sat, May 23, 2020 at 05:01:21AM +0200, Mark Wielaard wrote: > Yes, that is actually better. And much easier to read. And the code > can still be shared between get_c_stdlib_header_for_string_macro_name > and get_stdlib_header_for_name. Changed in the attached patch. > > I also extended the testcase so it covers both identifiers and string > concatenation cases. The identifier hints also work for C++, but I > haven't yet added the string token concatenation detection to the > cp_parser. It looks like it can be done similar as done for the > c_parser, but the parsers are different enough that it seems > better/simpler to do that in a followup patch once we have this patch > in the the c_parser.
The cp_parser keeps a stack of tokens, so it was actually easier to add the same functionality. I kept the patch separate to make review easier. The c_parser patch is almost the same as what I posted earlier, it just uses get_c_stdlib_header_for_string_macro_name explicitly. The cp_parser patch adds get_cpp_stdlib_header_for_string_macro_name and uses that. The testcase for the C++ case is extended like the c_parser one. [PATCH 1/2] Provide diagnostic hints for missing C inttypes.h string [PATCH 2/2] Provide diagnostic hints for missing C++ cinttypes string Cheers, Mark