This is an archive of the discontinued LLVM Phabricator instance.

OpenCL: Use length modifier for warning on vector printf arguments
ClosedPublic

Authored by arsenm on Jan 29 2019, 9:15 AM.

Details

Summary

Re-enable format string warnings on printf.

The warnings are still incomplete. Apparently it is undefined to use a
vector specifier without a length modifier, which is not currently
warned on. Additionally, type warnings appear to not be working with
the hh modifier, and aren't warning on all of the special restrictions
from c99 printf.

Diff Detail

Event Timeline

arsenm created this revision.Jan 29 2019, 9:15 AM
rjmccall added inline comments.Jan 29 2019, 10:07 AM
include/clang/AST/FormatString.h
70

I think giving this a weird name like AsShortLong might help make it clearer to readers below that it's a non-standard modifier.

lib/AST/FormatString.cpp
728

Your comment here doesn't match the code: you're accepting if this is a FP vector, but otherwise you're falling through. The comment sounds like this check should be if (CS.isDoubleArg()) return !VectorNumElts.isInvalid();.

773

Can you just break the FP args out of the switch below and add this check there?

lib/Sema/SemaExpr.cpp
755 ↗(On Diff #184101)

Can you just do this as a separate patch without the printf checking? We're going to want to merge this to the release branch.

arsenm updated this revision to Diff 184147.Jan 29 2019, 11:59 AM
arsenm marked 2 inline comments as done.
arsenm retitled this revision from OpenCL: Don't promote vector args to printf to OpenCL: Use length modifier for warning on vector printf arguments.
arsenm edited the summary of this revision. (Show Details)

Split revert into separate patch

rjmccall accepted this revision.Jan 29 2019, 12:25 PM

LGTM, thanks!

This revision is now accepted and ready to land.Jan 29 2019, 12:25 PM
arsenm closed this revision.Jan 29 2019, 12:50 PM

r352540