================ @@ -230,6 +241,37 @@ FormatStringConverter::FormatStringConverter(ASTContext *ContextIn, finalizeFormatText(); } +std::optional<StringRef> +FormatStringConverter::formatStringContainsUnreplaceableMacro( + const StringLiteral *FormatExpr, SourceManager &SM, Preprocessor &PP) { + for (auto I = FormatExpr->tokloc_begin(), E = FormatExpr->tokloc_end(); + I != E; ++I) { + const SourceLocation &TokenLoc = *I; + if (TokenLoc.isMacroID()) { + const StringRef MacroName = + Lexer::getImmediateMacroName(TokenLoc, SM, PP.getLangOpts()); + + // glibc uses __PRI64_PREFIX and __PRIPTR_PREFIX to define the prefixes + // for types that change size so we must look for multiple prefixes. + if (!MacroName.starts_with("PRI") && !MacroName.starts_with("__PRI")) + return MacroName; + + const SourceLocation TokenSpellingLoc = SM.getSpellingLoc(TokenLoc); ---------------- PiotrZSL wrote:
add checking here if location is valid. https://github.com/llvm/llvm-project/pull/97911 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits