This is an archive of the discontinued LLVM Phabricator instance.

[Sema] -Wformat: recognize %lb for the printf/scanf family of functions
ClosedPublic

Authored by MaskRay on Apr 19 2023, 8:32 PM.

Details

Summary

Fix https://github.com/llvm/llvm-project/issues/62247

D131057 added bArg and BArg in the AsLongLong label in
FormatSpecifier::hasValidLengthModifier, but missed the AsLong label,
therefore %llb is allowed while %lb (e.g. printf("%lb", (long)10)) has a
spurious warning. Add the missing case labels.

Diff Detail

Event Timeline

MaskRay created this revision.Apr 19 2023, 8:32 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 19 2023, 8:32 PM
MaskRay requested review of this revision.Apr 19 2023, 8:32 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 19 2023, 8:32 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
MaskRay updated this revision to Diff 515205.Apr 19 2023, 8:39 PM

update test/Sema/format-strings-fixit.c

enh accepted this revision.Apr 20 2023, 7:46 AM

thanks!

This revision is now accepted and ready to land.Apr 20 2023, 7:46 AM
aaron.ballman accepted this revision.Apr 20 2023, 8:09 AM

Thanks for the fix! LGTM, but please add a release note for the fix when landing.

MaskRay updated this revision to Diff 515357.Apr 20 2023, 9:32 AM
MaskRay retitled this revision from [Sema] Fix spurious warning for printf("%lb", (long)10) to [Sema] -Wformat: recognize %lb for the ``printf``/``scanf`` family of functions.
MaskRay edited the summary of this revision. (Show Details)

Change the subject to be clearer.
Add a release note.

MaskRay retitled this revision from [Sema] -Wformat: recognize %lb for the ``printf``/``scanf`` family of functions to [Sema] -Wformat: recognize %lb for the printf/scanf family of functions.Apr 20 2023, 9:32 AM
This revision was landed with ongoing or failed builds.Apr 20 2023, 9:34 AM
This revision was automatically updated to reflect the committed changes.