History log of /external/clang/test/Sema/format-strings-fixit.c
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
cdbe1e0d85d7d32452dd1c52758d7bfaa1c0663b 17-Jan-2013 Jordan Rose <jordan_rose@apple.com> Format strings: don't ever convert %+d to %lu.

Presumably, if the printf format has the sign explicitly requested, the user
wants to treat the data as signed.

This is a fix-up for r172739, and also includes several test changes that
didn't make it into that commit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172762 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings-fixit.c
4684778993c667246039b4664acbce59dc99440c 27-Jul-2012 Hans Wennborg <hans@hanshq.net> Make -Wformat walk the typedef chain when looking for size_t, etc.

Clang's -Wformat fix-its currently suggest using "%zu" for values of
type size_t (in C99 or C++11 mode). However, for a type such as
std::vector<T>::size_type, it does not notice that type is actually
typedeffed to size_t, and instead suggests a format for the underlying
type, such as "%lu" or "%u".

This commit makes the format string fix mechanism walk the typedef chain
so that it notices if the type is size_t, even if that isn't "at the
top".

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160886 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings-fixit.c
f85626453123f9691bcef13cff963f556e209c27 09-Mar-2012 Hans Wennborg <hans@hanshq.net> -Wformat-non-iso: warn about positional arguments (pr12017)

This renames the -Wformat-non-standard flag to -Wformat-non-iso,
rewords the current warnings a bit (pointing out that a format string
is not supported by ISO C rather than being "non standard"),
and adds a warning about positional arguments.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152403 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings-fixit.c
be6126a2a784e1446460b8d15c2b26f880c871fc 15-Feb-2012 Hans Wennborg <hans@hanshq.net> Make -Wformat fix-its preserve original conversion specifiers.

This commit makes PrintfSpecifier::fixType() and ScanfSpecifier::fixType()
only fix a conversion specification enough that Clang wouldn't warn about it,
as opposed to always changing it to use the "canonical" conversion specifier.
(PR11975)

This preserves the user's choice of conversion specifier in cases like:

printf("%a", (long double)1);
where we previously suggested "%Lf", we now suggest "%La"

printf("%x", (long)1);
where we previously suggested "%ld", we now suggest "%lx".

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150578 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings-fixit.c
6fcd932dfd6835f70cc00d6f7c6789793f6d7b66 10-Dec-2011 Hans Wennborg <hans@hanshq.net> Check that arguments to a scanf call match the format specifier,
and offer fixits when there is a mismatch.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146326 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings-fixit.c
117348caf0a8f91782e9e32e32a8689576f394d7 09-Dec-2011 Hans Wennborg <hans@hanshq.net> fix format specifier fixit for printf("%ld", "foo");

It should reset the length modifier (unless it's a wchar_t string).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146252 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings-fixit.c
68db6f0541bb9d54ab2ddffec4f7e2c0294e1f85 19-Oct-2011 Hans Wennborg <hans@hanshq.net> Break out ssize_t test from Sema/format-strings-fixit.c

Move to a separate test that sets a specific target triple
so that the type of ssize_t is known.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142481 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings-fixit.c
36e76089b30180ba86598be95bbb0989657fe2fc 18-Oct-2011 Hans Wennborg <hans@hanshq.net> Another attempt at fixing format-strings-fixit.c.

Use "%f" as format string to make sure it doesn't match size_t, etc.
whatever they might be typedeffed to, so that the fixit always applies.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142348 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings-fixit.c
4886e32e1f0bc778a47d23ac88a9c72f2c6305b0 18-Oct-2011 Hans Wennborg <hans@hanshq.net> Disable the ssize_t test in format-strings-fixit.c.

Turns out this part of the test from r142342 wasn't portable.
The errors on the bots look like this:

E:\bb-win7\cmake-clang-i686-msys\build\tools\clang\test\Sema\Output\format-strings-fixit.c.tmp:58:13: error: conversion specifies type 'unsigned int' but the argument has type 'ssize_t' (aka 'long')
printf("%zd", (ssize_t) 42);
~~^ ~~~~~~~~~~~~
%zd

Obviously we can't typedef ssize_t to someting that doesn't have the same size as size_t and expect it to work.

But it's also weird that the format string "%zd" gets interpreted as "unsigned int" when it should clearly be signed.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142345 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings-fixit.c
a7da2155167676a6a5d9fca4de947a9cab2a4908 18-Oct-2011 Hans Wennborg <hans@hanshq.net> Suggest %zu for size_t args to printf.

For PR11152. Make PrintSpecifier::fixType() suggest "%zu" for size_t, etc.
rather than looking at the underlying type and suggesting "%llu" or other
platform-specific length modifiers. Applies to C99 and C++11.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142342 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings-fixit.c
2315318436b3e94d54c220c3b8986e8002394a43 06-Sep-2011 Richard Smith <richard-llvm@metafoo.co.uk> PR10867: Work around a bug in lit. Multiple RUN: lines are joined with &&, so:

RUN: foo
RUN: bar || true

is equivalent to:

RUN: foo && bar || true

which is equivalent to:

RUN: (foo && bar) || true

This resulted in several of the fixit tests not really testing anything.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139132 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings-fixit.c
1ad35bebcc07d34202850f46b5b7be46fda1c5d1 14-Jul-2011 Ted Kremenek <kremenek@apple.com> Revert r135147 and r135075. The consensus was that this wasn't the right thing to do.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135152 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings-fixit.c
826d5b4782d5c4c38c30eaae70a243c33a76edad 14-Jul-2011 Ted Kremenek <kremenek@apple.com> Reapply r135075, but modify format-strings.c and format-strings-fixit.c test cases to be more portable with an explicit target triple.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135134 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings-fixit.c
1e713f50e904b96623425efa7119fcb98243e111 26-Apr-2011 Ted Kremenek <kremenek@apple.com> When generating printf fixits, preserve the original formating for unsigned integers (e.g., 'x', 'o').

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130164 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings-fixit.c
45f9b7e8f23072d662ee1cc758f4ecb0da5e3322 21-Jun-2010 Tom Care <tcare@apple.com> Bug 7377: printf checking fails to flag some undefined behavior
http://llvm.org/bugs/show_bug.cgi?id=7377

Updated format string highlighting and fixits to take advantage of the new CharSourceRange class.
- Change HighlightRange to allow highlighting whitespace only in a CharSourceRange (for warnings about the ' ' (space) flag)
- Change format specifier range helper function to allow for half-open ranges (+1 to end)
- Enabled previously failing tests (FIXMEs/XFAILs removed)
- Small fixes and additions to format string test cases

M test/Sema/format-strings.c
M test/Sema/format-strings-fixit.c
M lib/Frontend/TextDiagnosticPrinter.cpp
M lib/Sema/SemaChecking.cpp

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106480 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings-fixit.c
4c6021995032a898fb0502d5d1fd2df37638e57b 18-Jun-2010 Tom Care <tcare@apple.com> Printf format strings: Added some more tests and fixed some minor bugs.
- Precision toStrings shouldn't print a dot when they have no value.
- Length of char length modifier is now returned correctly.
- Added several fixit tests.

Note: fixit tests are currently broken due to a bug in HighlightRange. Marking as XFAIL for now.

M test/Sema/format-strings-fixit.c
M include/clang/Analysis/Analyses/PrintfFormatString.h
M lib/Analysis/PrintfFormatString.cpp


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106275 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings-fixit.c
01cb1aa458516b9061a65ea4b8a2ca55f71cb34f 17-Jun-2010 Ted Kremenek <kremenek@apple.com> Fix format string checking of '%c' by treating it as an integer conversion. Fixes PR 7391.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106196 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings-fixit.c
13927a431dd733336cfd664bf0840747a71b0a43 16-Jun-2010 Ted Kremenek <kremenek@apple.com> Extend format string type-checking to include '%p'. Fixes remaining cases PR 4468.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106151 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings-fixit.c
876e994957472eda4b40136d4e1d6e08e2be338f 11-Jun-2010 Tom Care <tcare@apple.com> Small fixes regarding printf fix suggestions.
- Added some handling of flags that become invalid when changing the conversion specifier.
- Changed fixit behavior to remove unnecessary length modifiers.
- Separated some tests out and added some comments.

modified:
lib/Analysis/PrintfFormatString.cpp
test/Sema/format-strings-fixit.c


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105807 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings-fixit.c
3bfc5f49e0e37e235bb0d33bcbcb36af9d1f84ab 09-Jun-2010 Tom Care <tcare@apple.com> Added FixIt support to printf format string checking.
- Refactored LengthModifier to be a class.
- Added toString methods in all member classes of FormatSpecifier.
- FixIt suggestions keep user specified flags unless incorrect.

Limitations:
- The suggestions are not conversion specifier sensitive. For example, if we have a 'pad with zeroes' flag, and the correction is a string conversion specifier, we do not remove the flag. Clang will warn us on the next compilation.

A test/Sema/format-strings-fixit.c
M include/clang/Analysis/Analyses/PrintfFormatString.h
M lib/Analysis/PrintfFormatString.cpp
M lib/Sema/SemaChecking.cpp


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105680 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings-fixit.c