[clang-tools-extra] [clang-tidy] Only expand <inttypes.h> macros in modernize-use-std-format/print (PR #97911)

Julian Schmidt via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 17 09:53:47 PDT 2024


================
@@ -230,6 +241,50 @@ FormatStringConverter::FormatStringConverter(ASTContext *ContextIn,
   finalizeFormatText();
 }
 
+std::optional<StringRef>
+FormatStringConverter::formatStringContainsUnreplaceableMacro(
----------------
5chmidti wrote:

> getting the macro name for the function call and permitting that macro for the format string too

>  such as the same macro being intentionally used in both places

It should be possible to detect this case comparing the `FileID` of the call's location and the format expression's location. If they differ, then they are different arguments -> different macros. Although, I haven't checked that yet.

https://github.com/llvm/llvm-project/pull/97911


More information about the cfe-commits mailing list