History log of /external/clang/test/Sema/format-strings.c
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
6bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89 29-May-2014 Stephen Hines <srhines@google.com> Update Clang for 3.5 rebase (r209713).

Change-Id: I8c9133b0f8f776dc915f270b60f94962e771bc83
/external/clang/test/Sema/format-strings.c
651f13cea278ec967336033dd032faef0e9fc2ec 24-Apr-2014 Stephen Hines <srhines@google.com> Updated to Clang 3.5a.

Change-Id: I8127eb568f674c2e72635b639a3295381fe8af82
/external/clang/test/Sema/format-strings.c
2243e78a6580ead4d17b76c924cd4b630b50d6ae 18-Jun-2013 Eli Friedman <eli.friedman@gmail.com> Correctly compute the index of the first string format argument when deciding
whether to emit a -Wformat-security warning. <rdar://problem/14178260>.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184214 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
d147f8fa3ef5dbebd1f24b72e52dedaebeaaa4b5 12-Jan-2013 Dmitri Gribenko <gribozavr@gmail.com> Add a comment to test to clarify the intention here

Comment is taken from the commit message of r151080, by Jean-Daniel Dupas


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172332 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
8be066e6733364cd34f25c4f7b7344f72aa23369 08-Sep-2012 Jordan Rose <jordan_rose@apple.com> Format strings: suggest %lld instead of %qd and %Ld with -Wformat-non-iso.

As a corollary to the previous commit, even when an extension is
available, we can still offer a fixit to the standard modifier.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163453 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
bbb6bb4952b77e57b842b4d3096848123ae690e7 08-Sep-2012 Jordan Rose <jordan_rose@apple.com> Format strings: %Ld isn't available on Darwin or Windows.

This seems to be a GNU libc extension; we offer a fixit to %lld on
these platforms.

<rdar://problem/11518237>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163452 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
f7158fa034174d2756736d1032b75d01d9deeb4c 07-Aug-2012 Hans Wennborg <hans@hanshq.net> Properly check length modfiers for %n in format strings.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161408 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
5deddafd3ef51e94b4ac4d80e38271d3768b1af6 31-Jul-2012 Hans Wennborg <hans@hanshq.net> -Wformat: better handling of qualifiers on pointer arguments

Warn about using pointers to const-qualified types as arguments to
scanf. Ignore the volatile qualifier when checking if types match.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161052 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
78a1b196cc6854a29c0ff2d6ea5f5643be6040c6 30-Jul-2012 Matt Beaumont-Gay <matthewbg@google.com> Do not warn on correct use of the '%n' format specifier.

While '%n' can be used for evil in an attacker-controlled format string, there
isn't any acute danger in using it in a literal format string with an argument
of the appropriate type.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160984 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
cec9ce49dcf4b4b768043f96c8ef8c1d4cdbb6b9 30-Jul-2012 Hans Wennborg <hans@hanshq.net> Make -Wformat check the argument type for %n.

This makes Clang check that the corresponding argument for "%n" in a
format string is a pointer to int.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160966 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
abf145ab57fc56bfb9c48333fcc65b49a564dc60 17-May-2012 Matt Beaumont-Gay <matthewbg@google.com> Use the argument location instead of the format string location when warning
about argument type mismatch.

This gives a nicer diagnostic in cases like
printf(fmt,
i);
where previously the snippet just pointed at 'fmt' (with a note at the
definition of fmt).

It's a wash for cases like
printf("%f",
i);
where previously we snippeted the offending portion of the format string,
but didn't indicate which argument was at fault.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156968 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
e2c60667d1bc29b7e148f9c9828dcbdbfc5b82b0 12-May-2012 Matt Beaumont-Gay <matthewbg@google.com> Merge branch 'format-string-braced-init'

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156653 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
bf9da1f8292bb66720ada94a050ede9dca17f60a 11-May-2012 Rafael Espindola <rafael.espindola@gmail.com> Fix a recent regression with the merging of format attributes.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156597 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
101d4e0c8ffbcdaaa58cddf1c20f98aa1b4501c4 08-May-2012 Hans Wennborg <hans@hanshq.net> Make -Wformat accept printf("%hhx", c); with -funsigned-char

For "%hhx", printf expects an unsigned char. This makes Clang
accept a 'char' argument for that also when using -funsigned-char.

This fixes PR12761.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156388 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
a30d8600b9b52922a92a90b30993564ba257537a 04-May-2012 James Molloy <james.molloy@arm.com> Add a predefine __WINT_UNSIGNED__, similar to __WCHAR_UNSIGNED__, and test them both for ARM and X86.

Use this to fully fix Sema/format-strings.c for non-x86 platforms.

Reviewed by Chandler on IRC.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156169 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
392da48160bd92ceb486792780467cbfdb2d0e8c 04-May-2012 James Molloy <james.molloy@arm.com> Fix handling of wint_t - we can't assume wint_t is purely an integer promotion of wchar_t - they may differ in signedness.

Teach ASTContext about WIntType, and have it taken from TargetInfo like WCharType. Should fix test/Sema/format-strings.c for ARM, with the exception of one subtest which will fail if wint_t and wchar_t are the same size and wint_t is signed, wchar_t is unsigned.

There'll be a followup commit to fix that.

Reviewed by Chandler and Hans at http://llvm.org/reviews/r/8



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156165 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
927a57cb8fb4134dec68997a476d84a15b29f9a8 04-May-2012 Bob Wilson <bob.wilson@apple.com> Add a test for r156092.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156132 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
76517426dc8bf7734c07eefc35171a6bfdba1a2b 22-Feb-2012 Hans Wennborg <hans@hanshq.net> Warn about non-standard format strings (pr12017)

This adds the -Wformat-non-standard flag (off by default,
enabled by -pedantic), which warns about non-standard
things in format strings (such as the 'q' length modifier,
the 'S' conversion specifier, etc.)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151154 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
f57c413e444b441fa75ae8911d183c19b53bdd56 21-Feb-2012 Jean-Daniel Dupas <devlists@shadowlab.org> When calling a non variadic format function(vprintf, vscanf, NSLogv, …), warn if the format string argument is a parameter that is not itself declared as a format string with compatible format.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151080 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
32addd519c6699000ff79c387a1c87f0ab7c3698 16-Feb-2012 Hans Wennborg <hans@hanshq.net> Format string analysis: give 'q' its own enumerator.

This is in preparation for being able to warn about 'q' and other
non-standard format string features.

It also allows us to print its name correctly.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150697 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
4ee01ef7bd170b6f3f3f71882b407cd6408c5b1e 13-Feb-2012 Hans Wennborg <hans@hanshq.net> Fix typo in PrintfConversionSpecifier::isDoubleArg()

This makes the printf diagnostics issue warnigns for %a, %A, %e, etc.
when used with the wrong argument.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150370 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
2837a2f02195e624b14b419b2d3e6682a6bc5a0f 08-Feb-2012 Jean-Daniel Dupas <devlists@shadowlab.org> non-literal strftime format string is not unsafe.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150009 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
220947bd5a66b0f25f5e74d6029769dfb34f07b4 31-Jan-2012 Jean-Daniel Dupas <devlists@shadowlab.org> FormatCheckers should emit all diagnostics using EmitFormatDiagnostic().



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149394 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
34269df5db40b7c4b4f52aed579d9b3108ff79e4 30-Jan-2012 Jean-Daniel Dupas <devlists@shadowlab.org> Update on format attribute handling.
- Remove the printf0 special handling as we treat it as printf anyway.
- Perform basic checks (non-literal, empty) for all formats and not only printf/scanf.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149236 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
9d24c2cbd9cf1b7c165ccb13221f2efb2f4b49b0 24-Jan-2012 Ted Kremenek <kremenek@apple.com> Teach scanf/printf checking about '%Ld' and friends (a GNU extension). Fixes PR 9466.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148859 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
ce506ae231703a23ea95335cd4de19c60082f361 20-Jan-2012 Ted Kremenek <kremenek@apple.com> Tighten format string diagnostic and make it a bit clearer (and a bit closer to GCC's).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148579 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
55733de16f492dadbf5f4d2809d6c610ba6d86ae 28-Oct-2011 Richard Trieu <rtrieu@google.com> Fix for PR9751 to change the behavior of -Wformat warnings. If the format
string is part of the function call, then there is no difference. If the
format string is not, the warning will point to the call site and a note
will point to where the format string is.

Fix-it hints for strings are moved to the note if a note is emitted. This will
prevent changes to format strings that may be used in multiple places.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143168 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
6ca4a9ae99d65948e578d3e7d1f58ab6a947d2d7 25-Oct-2011 Ted Kremenek <kremenek@apple.com> Tweak printf format string parsing to accept 'hh' conversion specifier to accept any char, not just signed char. Fixes <rdar://problem/10303638>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142908 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
4cd5791f4aa6deb572979bb38c1deedbc155efe0 29-Sep-2011 Ted Kremenek <kremenek@apple.com> Do not warn about empty format strings when there are no data arguments. Fixes <rdar://problem/9473155>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140777 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
62088e3317c74a3a8baf2db3e1bd7ab0b7ddc590 27-Aug-2011 Ted Kremenek <kremenek@apple.com> Control 'invalid conversion specifier' warnings under a subflag (-Wformat-invalid-specifier) of -Wformat. Fixes <rdar://problem/10031930>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138686 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.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.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.c
dc00d8158db573f4a1f91cfaa2a89171c2e5f637 13-Jul-2011 Ted Kremenek <kremenek@apple.com> Re-relax conversion specifier checking for printf format strings and conversion specifiers. My recent change was a mistake.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135048 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
45eb7022ff059ff5a291e24f57ff56428a1e8210 13-Jul-2011 Ted Kremenek <kremenek@apple.com> Fix inversion in argument type checking for format strings with conversion specifiers for character types.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135046 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
b30cd4a09bbf0adfa644b957a2b28fe31c5d45e4 15-Jun-2011 Douglas Gregor <dgregor@apple.com> Don't add redundant FormatAttr, ConstAttr, or NoThrowAttr attributes,
either imlicitly (for builtins) or explicitly (due to multiple
specification of the same attributes). Fixes <rdar://problem/9612060>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133045 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
b43e8ad893706a2499c4901b8f5cb289553d66b1 25-Feb-2011 Ted Kremenek <kremenek@apple.com> Don't warn about using PredefinedExprs as format string literals. These never can be a real security issue.

Fixes PR 9314.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126447 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
751969957e4cbd4c8b5bf8508ab8620e24743005 21-Feb-2011 Chandler Carruth <chandlerc@gmail.com> Allow -Wformat to be enabled without -Wformat-security. GCC gates
-Wformat-security on -Wformat, not vice-versa.

Fixes PR8486. Patch by Oleg Slezberg.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126096 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
65197b4b0c55bb74af0450230d61ee9461223721 08-Jan-2011 Ted Kremenek <kremenek@apple.com> Add semantic checking that the "thousands grouping"
prefix in a printf format string is matched
with the appropriate conversion specifier.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123055 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
bd18d4584aae0ed6f7111ef5713784cf29fe663f 08-Jan-2011 Ted Kremenek <kremenek@apple.com> Add printf format string parsing support for '
prefix to format conversions (POSIX extension).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123054 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
7966297a70996977f167a8676568f02f4283bdd6 02-Dec-2010 Ted Kremenek <kremenek@apple.com> Fix range in printf warnings for invalid conversion specifiers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120735 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
2e6c19abcf97c25f4d7458a9db89c5ab0158717d 21-Nov-2010 Anders Carlsson <andersca@mac.com> The 'X' printf type has a valid alternative form. Fixes PR8641.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119946 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
4d8ae4d57ed18d60da4d3786fb740607aa7c3688 21-Oct-2010 Ted Kremenek <kremenek@apple.com> Previously, the printf warnings would say your arguments type was 'int' when it was really a 'char'
or a 'short'. This fixes that and allows the hints to suggest 'h' modifiers for small ints.

Patch by Justin Bogner!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116996 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
c82faca0be59b072b38bed375e21bd24f1f72647 09-Sep-2010 Ted Kremenek <kremenek@apple.com> Check format strings when a called function has more than one FormatAttr (one for 'scanf' and one for 'printf'). Fixes <rdar://problem/8409437>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113472 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
95355bb53ef3145e463b98c6fd26f8f95e26e26c 09-Sep-2010 Ted Kremenek <kremenek@apple.com> It appears that technically a null format string is not warned under -Wformat-nonliteral, as
the function processing the format string can decided whether or not to accept a null format string (e.g., asl_log). Fixes <rdar://problem/8269537>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113469 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
9325eaf08fcccbc0d038e703f570c64daacdaa31 25-Aug-2010 Ted Kremenek <kremenek@apple.com> Fix printf format string checking for '%lc' (which expects a wint_t or compatible argument). Fixes PR 7981.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111978 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
baa400654bd6f8396f9a07188445ae7955b060a3 20-Jul-2010 Ted Kremenek <kremenek@apple.com> Don't warn when a '%%' or '%*d' (scanf) is used in a format string with positional arguments, since
these don't actually consume an argument.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108757 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.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.c
e4ee9663168dfb2b4122c768091e30217328c9fa 17-Jun-2010 Tom Care <tcare@apple.com> Bug 7377: Fixed several bad printf format string bugs.
- Added warning for undefined behavior when using field specifier
- Added warning for undefined behavior when using length modifier
- Fixed warnings for invalid flags
- Added warning for ignored flags
- Added fixits for the above warnings
- Fixed accuracy of detecting several undefined behavior conditions
- Receive normal warnings in addition to security warnings when using %n
- Fix bug where '+' flag would remain on unsigned conversion suggestions

Summary of changes:
- Added expanded tests
- Added/expanded warnings
- Added position info to OptionalAmounts for fixits
- Extracted optional flags to a wrapper class with position info for fixits
- Added several methods to validate a FormatSpecifier by component, each checking for undefined behavior
- Fixed conversion specifier checking to conform to C99 standard
- Added hooks to detect the invalid states in CheckPrintfHandler::HandleFormatSpecifier

Note: warnings involving the ' ' (space) flag are temporarily disabled until whitespace highlighting no longer triggers assertions. I will make a post about this on cfe-dev shortly.

M test/Sema/format-strings.c
M include/clang/Basic/DiagnosticSemaKinds.td
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@106233 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.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.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.c
b90f4b3fb94056609da9cca5eef7358d95a363b2 26-May-2010 Douglas Gregor <dgregor@apple.com> Tell the string literal parser when it's not permitted to emit
diagnostics. That would be while we're parsing string literals for the
sole purpose of producing a diagnostic about them. Fixes
<rdar://problem/8026030>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104684 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
a41a8c5972c2632247ae7913cf6ce65d45f7e702 22-Apr-2010 Douglas Gregor <dgregor@apple.com> Whenever we complain about a failed initialization of a function or
method parameter, provide a note pointing at the parameter itself so
the user does not have to manually look for the function/method being
called and match up parameters to arguments. For example, we now get:

t.c:4:5: warning: incompatible pointer types passing 'long *' to
parameter of
type 'int *' [-pedantic]
f(long_ptr);
^~~~~~~~
t.c:1:13: note: passing argument to parameter 'x' here
void f(int *x);
^



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102038 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
6ee765348b2855c702fa593fb030ef6abe0d01f6 25-Mar-2010 Ted Kremenek <kremenek@apple.com> Fix two bugs in format-string checking:
(1) Do not assume the data arguments start after the format string
(2) Do not use the fact that a function is variadic to treat it like a va_list printf function

Fixes PR 6697.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99480 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
d49d87719b8e272134e76601e3efc0197785aa8a 01-Mar-2010 Ted Kremenek <kremenek@apple.com> Allow a '0' precision in format strings (as the man page says it is okay).
Fixes <rdar://problem/7700339>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97482 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
e3fc54790250076e33ad25b14e5be293514fe5ea 27-Feb-2010 Ted Kremenek <kremenek@apple.com> Fix crasher caused by setting a bit in a possibly empty bitvector while
doing printf format string checking. This is a recent regression.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97318 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
efaff195ba1fa55b6fe0b0b2435b81451387d241 27-Feb-2010 Ted Kremenek <kremenek@apple.com> For printf format string checking, add support for positional format strings.
Along the way, coelesce some of the diagnostics.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97297 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
7f70dc85d5055c19c8003f43a59135de211ad1b9 26-Feb-2010 Ted Kremenek <kremenek@apple.com> For printf format string checking, move the tracking of the data argument index out of
Sema and into analyze_printf::ParseFormatString(). Also use a bitvector to determine
what arguments have been covered (instead of just checking to see if the last argument consumed is the max argument). This is prep. for support positional arguments (an IEEE extension).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97248 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
78c97fb0bb295f1235469d47e1384a56252090ee 24-Feb-2010 Ted Kremenek <kremenek@apple.com> Disable one test case because of the inconsistent results it is giving on
Windows and Mac OS X. Will investigate later.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97016 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
87260c7eabf88eb2009ba2ba20150cd897483241 24-Feb-2010 Ted Kremenek <kremenek@apple.com> Add support for '%C' and '%S' printf conversion specifiers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97005 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
0da9e9582832ee776030a38420fc851b0118b598 16-Feb-2010 Ted Kremenek <kremenek@apple.com> Add test case to show that Clang now checks the format string
arguments of asprintf (<rdar://problem/6657191>).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96319 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
0395618b6f3a57137abf6d29284e0eef6177c0ad 16-Feb-2010 Ted Kremenek <kremenek@apple.com> Fix test case.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96311 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
4e4b30ec62d78b24e6556fea2624855c193d0e3e 16-Feb-2010 Ted Kremenek <kremenek@apple.com> Refactor the logic for printf argument type-checking into analyze_printf::ArgTypeResult.
Implement printf argument type checking for '%s'.

Fixes <rdar://problem/3065808>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96310 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
5c41ee8c49995fb4fd76d686b239c15cbab261ea 11-Feb-2010 Ted Kremenek <kremenek@apple.com> Patch by Cristian Draghici:

Enhance the printf format string checking when using the format
specifier flags ' ', '0', '+' with the 'p' or 's' conversions (since
they are nonsensical and undefined). This is similar to GCC's
checking.

Also warning when a precision is used with the 'p' conversin
specifier, since it has no meaning.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95869 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
aa74a1e49f7c4b89539830290f76fe2c3e97187f 02-Feb-2010 Douglas Gregor <dgregor@apple.com> Implement promotion for enumeration types.

WHAT!?!

It turns out that Type::isPromotableIntegerType() was not considering
enumeration types to be promotable, so we would never do the
promotion despite having properly computed the promotion type when the
enum was defined. Various operations on values of enum type just
"worked" because we could still compute the integer rank of an enum
type; the oddity, however, is that operations such as "add an enum and
an unsigned" would often have an enum result type (!). The bug
actually showed up as a spurious -Wformat diagnostic
(<rdar://problem/7595366>), but in theory it could cause miscompiles.

In this commit:
- Enum types with a promotion type of "int" or "unsigned int" are
promotable.
- Tweaked the computation of promotable types for enums
- For all of the ABIs, treat enum types the same way as their
underlying types (*not* their promotion types) for argument passing
and return values
- Extend the ABI tester with support for enumeration types



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95117 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
f911eba72e6d7275e5cfdb79ab23fb2aa9cc01d0 02-Feb-2010 Ted Kremenek <kremenek@apple.com> Add format string type checking support for 'long double'.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95026 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
180f2840d1d8bcb2139bfb53e2d88eda280e939e 01-Feb-2010 Ted Kremenek <kremenek@apple.com> Format string checking: selectively ignore implicit casts to 'int'
when checking if the format specifier matches the type of the data
argument and the length modifier indicates the data type is 'char' or
'short'.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94992 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
01aefc6d20fbfd50bfb83926226dee86dd31c9c5 30-Jan-2010 Daniel Dunbar <daniel@zuster.org> Recognize 'q' as a format length modifier (from BSD).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94894 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
c9a89fec60a20eb3269caa95eca048d45ab215ad 30-Jan-2010 Ted Kremenek <kremenek@apple.com> Add format string checking of 'double' arguments. Fixes <rdar://problem/6931734>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94867 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
d635c5fcc45c952b75743dd2f4c86d6950e4954e 30-Jan-2010 Ted Kremenek <kremenek@apple.com> Add basic type checking of format string conversion specifiers and their arguments. Thanks to Cristian Draghici for his help with this patch!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94864 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
31f8e32788adb299acad455363eb7fd244642c82 30-Jan-2010 Ted Kremenek <kremenek@apple.com> Be a little more permissive than C99: allow 'unsigned' to be used for
the field width and precision of a format specifier instead of just
'int'. This matches GCC, and fixes <rdar://problem/6079850>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94856 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
f88c8e02da48afea6a04091f675af5c4facd99f1 29-Jan-2010 Ted Kremenek <kremenek@apple.com> Switch Sema over to using the new implementation of format string
checking. It passes all existing tests, and the diagnostics have been
refined to provide better range information (we now highlight
individual format specifiers) and more precise wording in the
diagnostics.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94837 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
e030358cc06e1cbce3c2e00ca67c946f9164b2a8 09-Jan-2010 Chris Lattner <sabre@nondot.org> add a bunch of missing prototypes to tests


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93072 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
813b70d6db54dbf149cfaa14ec7502142121d86f 22-Dec-2009 Chris Lattner <sabre@nondot.org> fix a bug handling the gnu ?: extension. Patch by Storlek on IRC,
who prefers to be stealthy and mysterious.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91888 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
a5728872c7702ddd09537c95bc3cbd20e1f2fb09 15-Dec-2009 Daniel Dunbar <daniel@zuster.org> Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'.
- This is designed to make it obvious that %clang_cc1 is a "test variable"
which is substituted. It is '%clang_cc1' instead of '%clang -cc1' because it
can be useful to redefine what gets run as 'clang -cc1' (for example, to set
a default target).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91446 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
23afaad895486d4a9ea672f497b63ebc4c588955 17-Nov-2009 Daniel Dunbar <daniel@zuster.org> Don't #include <stdio.h> when tests don't need it, or use clang instead of clang-cc when they do.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89070 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
addb0f69580cd4ae7c61219e126e68ec6aa3c234 29-Oct-2009 John Thompson <John.Thompson.JTSoftware@gmail.com> Fix some Window-isms to get these tests to pass on Windows.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85450 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
42ae3e81a811362c0bf78deb71b72455aadff772 13-May-2009 Ted Kremenek <kremenek@apple.com> Fix <rdar://problem/6880975> [format string] Assertion failed: (Arg < NumArgs && "Arg access out of range!").

For format string checking, only check the type of the format
specifier for non-vararg functions.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71672 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
655f141f4d4c92eeebcc880211313e84c0a8b2f2 29-Apr-2009 Chris Lattner <sabre@nondot.org> implement -Wformat-security properly, which is enabled by default.
This enables one specific class of non-literal format warnings.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70368 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
be8434a0cc0355f652d59553f8aaa3c88bfe3c94 29-Apr-2009 Chris Lattner <sabre@nondot.org> tweak warning options to be more like gcc:

1. All all variants of -Wformat*, make them imply -Wformat. GCC warns
if you use -Wformatfoo without -Wformat. We just make one imply the
other.
2. Make -Wformat-nonliteral default to off, like gcc. It is an incredible
nuisance.
3. Accept but currently ignore -Wformat-extra-args.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70362 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
d7d5f0223bd30dfd618762349c6209dd1d5ea3e6 24-Mar-2009 Daniel Dunbar <daniel@zuster.org> Rename clang to clang-cc.

Tests and drivers updated, still need to shuffle dirs.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67602 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
082d936a5b8323ac2c04558d8bca277a647831a3 20-Mar-2009 Ted Kremenek <kremenek@apple.com> Fix <rdar://problem/6704086> by allowing the format string checking in Sema to
allow non-literal format strings that are variables that (a) permanently bind to
a string constant and (b) whose string constants are resolvable within the same
translation unit.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67404 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
d0d082f2eba4e3ed4eb467d76fd227c6dcd6cce7 18-Feb-2009 Chris Lattner <sabre@nondot.org> use the full spelling of a string literal token so that trigraphs
and escaped newlines don't throw off the offset computation.

On this testcase:
printf("abc\
def"
"%*d", (unsigned) 1, 1);

Before:
t.m:5:5: warning: field width should have type 'int', but argument has type 'unsigned int'
def"
^

after:
t.m:6:12: warning: field width should have type 'int', but argument has type 'unsigned int'
"%*d", (unsigned) 1, 1);
^ ~~~~~~~~~~~~



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64930 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
07f192e1d7af64d63fd80eafd724b70a18ebfbd9 18-Feb-2009 Chris Lattner <sabre@nondot.org> add c testcase for string literal diagnostic improvement.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64929 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
3c385e5f8d9008fff18597ca302be19fa86e51f6 14-Feb-2009 Douglas Gregor <dgregor@apple.com> Add hook to add attributes to function declarations that we know
about, whether they are builtins or not. Use this to add the
appropriate "format" attribute to NSLog, NSLogv, asprintf, and
vasprintf, and to translate builtin attributes (from Builtins.def)
into actual attributes on the function declaration.

Use the "printf" format attribute on function declarations to
determine whether we should do format string checking, rather than
looking at an ad hoc list of builtins and "known" function names.

Be a bit more careful about when we consider a function a "builtin" in
C++.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64561 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
0fdea465617caaa9e1370c82482473f25b14b734 13-Jan-2009 Ted Kremenek <kremenek@apple.com> Fix test case (incomplete "expected-warning" line)


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62119 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
d30ef87f34015d18bde20b9632032d0063d761aa 13-Jan-2009 Ted Kremenek <kremenek@apple.com> Patch by Roman Divacky:

Extend string-literal checking for printf() format string to handle conditional
ternary operators where both sides are literals.

This fixes PR 3319: http://llvm.org/bugs/show_bug.cgi?id=3319


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62117 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
de45428f923b38d80407dbb9ede0df504256f9f6 02-Oct-2008 Daniel Dunbar <daniel@zuster.org> Add support for format string checking of object-size checking
versions of sprintf and friends.
- Added FIXME that this mechanism should be generalized.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56962 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
50ff6f3fb567353ac84aa489bedcfdbfb93da458 20-Aug-2008 Eli Friedman <eli.friedman@gmail.com> Fix test failure on Linux.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55032 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
4489fe10fa073eb326e2c8906db170f009050911 05-Aug-2008 Daniel Dunbar <daniel@zuster.org> Add EXTWARN Diagnostic class.
- Like EXTENSION but always generates a warning (even without
-pedantic).
- Updated ptr -> int, int -> ptr, and incompatible cast warnings to
be EXTWARN.
- Other EXTENSION level diagnostics should be audited for upgrade.
- Updated several test cases to fix code which produced unanticipated
warnings.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54335 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
4a33646560c4faf8fb82a681360eb2dc0573d558 17-Dec-2007 Ted Kremenek <kremenek@apple.com> Modified format-string checking to not emit a warning when all of the
following hold:

(1) A vprintf-like function is called that takes the argument list via a
via_list argument.

(2) The format string is a non-literal that is the parameter value of
the enclosing function, e.g:

void logmessage(const char *fmt,...) {
va_list ap;
va_start(ap,fmt);
fprintf(fmt,ap); // Do not emit a warning.
}

In the future this special case will be enhanced to consult the "format"
attribute attached to a function declaration instead of just allowing a blank
check for all function parameters to be used as format strings to vprintf-like
functions. This will happen when more support for attributes becomes
available.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45114 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
1ff8b58fa0fda7dd3a0a715637c2db2f9573539f 15-Oct-2007 Anders Carlsson <andersca@mac.com> Fix a warning

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42973 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
580b664e9c2acd3bffddfea79b1ce2863cfd9dd0 12-Oct-2007 Ted Kremenek <kremenek@apple.com> Added notion of '*' specified format width/specifiers when checking
printf format strings. Added type checking to see if the matching
width/precision argument was of type 'int'.

Thanks to Anders Carlsson for reporting this missing feature.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42933 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
6eda8c9cefb498ac8403bc65854e6ce411a07855 12-Oct-2007 Anders Carlsson <andersca@mac.com> Add some more diagnostics for va_start, fix tests so they pass with these new diags.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42917 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
3b427b3ba518f7a7293458c2d3d92eebd8458d87 11-Oct-2007 Chris Lattner <sabre@nondot.org> rename -parse-ast-print to -ast-print
rename -parse-ast-dump to -ast-dump
remove -parse-ast, which is redundant with -fsyntax-only



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42852 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
9f3d942e9970bc8f51add390b2a2c46b5a2ab747 26-Sep-2007 Ted Kremenek <kremenek@apple.com> Removed option "-parse-ast-check" from clang driver. This is now implemented
using "-parse-ast -verify".

Updated all test cases (using a sed script) that invoked -parse-ast-check to
now use -parse-ast -verify.

Fixed a bug where using "-verify" instead of "-parse-ast-check" would not
correctly create the DiagClient needed to accumulate diagnostics.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42365 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
71895b9aa3ad71957359497e136b50fcb6136bdf 14-Aug-2007 Ted Kremenek <kremenek@apple.com> Added support for additional format string checking for the printf
family of functions. Previous functionality only included checking to
see if the format string was a string literal. Now we check parse the
format string (if it is a literal) and perform the following checks:

(1) Warn if: number conversions (e.g. "%d") != number data arguments.

(2) Warn about missing format strings (e.g., "printf()").

(3) Warn if the format string is not a string literal.

(4) Warn about the use se of '%n' conversion. This conversion is
discouraged for security reasons.

(5) Warn about malformed conversions. For example '%;', '%v'; these
are not valid.

(6) Warn about empty format strings; e.g. printf(""). Although these
can be optimized away by the compiler, they can be indicative of
broken programmer logic. We may need to add additional support to
see when such cases occur within macro expansion to avoid false
positives.

(7) Warn if the string literal is wide; e.g. L"%d".

(8) Warn if we detect a '\0' character WITHIN the format string.

Test cases are included.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41076 91177308-0d34-0410-b5e6-96231b3b80d8
/external/clang/test/Sema/format-strings.c
59907c4d8f6fc8aacfdaa0273bd7a9c140fbb45f 10-Aug-2007 Chris Lattner <sabre@nondot.org> initial support for checking format strings, patch by Ted Kremenek:

"I've coded up some support in clang to flag warnings for non-constant format strings used in calls to printf-like functions (all the functions listed in "man fprintf"). Non-constant format strings are a source of many security exploits in C/C++ programs, and I believe are currently detected by gcc using the flag -Wformat-nonliteral."



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