Commit Graph

5 Commits

Author SHA1 Message Date
Jordan Rose 598ec0992d Format strings: a character literal should be printed with %c, not %d.
The type of a character literal is 'int' in C, but if the user writes a
character /as/ a literal, we should assume they meant it to be a
character and not a numeric value, and thus offer %c as a correction
rather than %d.

There's a special case for multi-character literals (like 'MooV'), which
have implementation-defined value and usually cannot be printed with %c.
These still use %d as the suggestion.

In C++, the type of a character literal is 'char', and so this problem
doesn't exist.

<rdar://problem/12282316>

llvm-svn: 169398
2012-12-05 18:44:40 +00:00
Jordan Rose 6aaa87e0d2 Format strings: the correct conversion for 'char' is %c, not %d or %hhd.
We tried to account for 'uint8_t' by saying that /typedefs/ of 'char'
should be corrected as %hhd rather than %c, but the condition was wrong.

llvm-svn: 169397
2012-12-05 18:44:37 +00:00
Jordan Rose 614e72bec7 Make suggestions for mismatched enum arguments to printf/scanf.
llvm-svn: 157962
2012-06-04 22:49:02 +00:00
Jordan Rose 95341bf4d4 Add a test for '%@' suggestion for classes.
llvm-svn: 157718
2012-05-30 22:41:32 +00:00
Jordan Rose 68f6d3b1a6 Suggest '%@' for Objective-C objects in ObjC format strings.
llvm-svn: 157716
2012-05-30 21:53:13 +00:00