summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis/FormatString.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Format strings: offer a fixit for Darwin's %D/%U/%O to ISO %d/%u/%o.Jordan Rose2012-09-131-0/+23
| | | | | | <rdar://problem/12061922> llvm-svn: 163772
* Format strings: %D, %U, and %O are valid on Darwin (same as %d, %u, %o).Jordan Rose2012-09-131-0/+12
| | | | | | | | | These will warn under -Wformat-non-iso, and will still be rejected outright on other platforms. <rdar://problem/12061922> llvm-svn: 163771
* Format strings: suggest %lld instead of %qd and %Ld with -Wformat-non-iso.Jordan Rose2012-09-081-11/+3
| | | | | | | As a corollary to the previous commit, even when an extension is available, we can still offer a fixit to the standard modifier. llvm-svn: 163453
* Format strings: %Ld isn't available on Darwin or Windows.Jordan Rose2012-09-081-3/+27
| | | | | | | | | This seems to be a GNU libc extension; we offer a fixit to %lld on these platforms. <rdar://problem/11518237> llvm-svn: 163452
* Remove ScanfArgType and bake that logic into ArgType.Hans Wennborg2012-08-071-18/+48
| | | | | | | | This is useful for example for %n in printf, which expects a pointer to int with the same logic for checking as %d would have in scanf. llvm-svn: 161407
* Rename analyze_format_string::ArgTypeResult to ArgTypeHans Wennborg2012-08-071-10/+10
| | | | | | Also remove redundant constructors and unused member functions. llvm-svn: 161403
* -Wformat: better handling of qualifiers on pointer argumentsHans Wennborg2012-07-311-0/+7
| | | | | | | Warn about using pointers to const-qualified types as arguments to scanf. Ignore the volatile qualifier when checking if types match. llvm-svn: 161052
* Make -Wformat walk the typedef chain when looking for size_t, etc.Hans Wennborg2012-07-271-0/+34
| | | | | | | | | | | | | | 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". llvm-svn: 160886
* Teach printf/scanf about enums with fixed underlying types.Jordan Rose2012-06-041-0/+6
| | | | llvm-svn: 157961
* Make -Wformat accept printf("%hhx", c); with -funsigned-charHans Wennborg2012-05-081-2/+1
| | | | | | | | | For "%hhx", printf expects an unsigned char. This makes Clang accept a 'char' argument for that also when using -funsigned-char. This fixes PR12761. llvm-svn: 156388
* Fix handling of wint_t - we can't assume wint_t is purely an integer ↵James Molloy2012-05-041-10/+10
| | | | | | | | | | | | 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 llvm-svn: 156165
* Support '%p' format specifier with block pointers.Ted Kremenek2012-03-151-1/+1
| | | | llvm-svn: 152839
* -Wformat-non-iso: warn about positional arguments (pr12017)Hans Wennborg2012-03-091-0/+3
| | | | | | | | | 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. llvm-svn: 152403
* Warn about non-standard format strings (pr12017)Hans Wennborg2012-02-221-0/+71
| | | | | | | | | 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.) llvm-svn: 151154
* Format string analysis: give 'q' its own enumerator.Hans Wennborg2012-02-161-3/+6
| | | | | | | | | 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. llvm-svn: 150697
* Tweak format string checking to work with %@ and ObjC toll-free bridging. ↵Ted Kremenek2012-02-061-3/+17
| | | | | | <rdar://problem/10814120> llvm-svn: 149907
* Format string warnings: don't a.k.a. wchar_t with wchar_t.Hans Wennborg2012-01-311-1/+1
| | | | | | | | | | | This fixes the case where Clang would output: error: format specifies type 'wchar_t *' (aka 'wchar_t *') ArgTypeResult::getRepresentativeTypeName needs to take into account that wchar_t can be a built-in type (as opposed to in C, where it is a typedef). llvm-svn: 149387
* Fix NSLog format string checking for %@.Ted Kremenek2012-01-251-1/+2
| | | | llvm-svn: 148885
* Teach scanf/printf checking about '%Ld' and friends (a GNU extension). ↵Ted Kremenek2012-01-241-0/+8
| | | | | | Fixes PR 9466. llvm-svn: 148859
* The 'l' length modifier makes sense with the scanlist conversion specifier.Ted Kremenek2012-01-201-0/+1
| | | | llvm-svn: 148586
* More dead code removal (using -Wunreachable-code)David Blaikie2012-01-201-7/+3
| | | | llvm-svn: 148577
* scanf: parse the 'm' length modifier, and check that the right argumentsHans Wennborg2012-01-121-0/+21
| | | | | | are used with that and the 'a' length modifier. llvm-svn: 148029
* scanf analysis: the 'a' length modifier is valid with a scanlistHans Wennborg2012-01-121-0/+1
| | | | | | | Before r148025 we (accidentally) didn't check whether a length modifier is appropriate for a scanlist, but now we do. llvm-svn: 148026
* Support the 'a' scanf length modifier as an extension in C++.Hans Wennborg2011-12-281-1/+1
| | | | | | | It should not be supported in C++11, since that uses the C99 standard library, in which 'a' is a format specifier. llvm-svn: 147310
* Support the 'a' length modifier in scanf format strings as a C90Hans Wennborg2011-12-151-1/+28
| | | | | | | | | extension. This fixes gcc.dg/format/c90-scanf-3.c and ext-4.c (test for excess errors). llvm-svn: 146649
* Make printf warnings refer to wint_t and wchar_t by nameHans Wennborg2011-12-091-5/+4
| | | | | | in addition to underlying type. llvm-svn: 146254
* Move definition of ConversionSpecifier::toString() to FormatString.cppHans Wennborg2011-12-091-4/+41
| | | | | | | It's declared in FormatString.h, so it shouldn't be defined in PrintfFormatString.cpp. llvm-svn: 146253
* Make printf warnings refer to intmax_t et al. by nameHans Wennborg2011-12-071-2/+9
| | | | | | | | | | | | in addition to underlying type. For example, the warning for printf("%zu", 42.0); changes from "conversion specifies type 'unsigned long'" to "conversion specifies type 'size_t' (aka 'unsigned long')" (This is a second attempt after r145697, which got reverted.) llvm-svn: 146032
* Revert r145697 and dependent patch r145702. It added a dependency fromNick Lewycky2011-12-021-12/+13
| | | | | | lib/Analysis to lib/Sema which is cyclical. llvm-svn: 145724
* Make conversion specifier warning refer to typedef if possible.Hans Wennborg2011-12-021-13/+12
| | | | | | | | For example, the warning for printf("%zu", 42.0); changes from "conversion specifies type 'unsigned long'" to "conversion specifies type 'size_t' (aka 'unsigned long')" llvm-svn: 145697
* Tweak printf format string parsing to accept 'hh' conversion specifier to ↵Ted Kremenek2011-10-251-5/+21
| | | | | | accept any char, not just signed char. Fixes <rdar://problem/10303638>. llvm-svn: 142908
* Removing a bunch of dead returns/breaks after llvm_unreachables.David Blaikie2011-09-231-2/+0
| | | | llvm-svn: 140407
* Switch assert(0/false) llvm_unreachable.David Blaikie2011-09-231-2/+2
| | | | llvm-svn: 140367
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-231-1/+1
| | | | | | | | LLVM.h imports them into the clang namespace. llvm-svn: 135852
* Revert r135147 and r135075. The consensus was that this wasn't the right ↵Ted Kremenek2011-07-141-14/+12
| | | | | | thing to do. llvm-svn: 135152
* Add extra sanity checking in FormatString::matchesType() that we are ↵Ted Kremenek2011-07-141-3/+6
| | | | | | comparing integers to integers. This happens not to be an issue now, but the extra check helps future proof in case of future refactorings. llvm-svn: 135147
* Reapply r135075, but modify format-strings.c and format-strings-fixit.c test ↵Ted Kremenek2011-07-141-10/+9
| | | | | | cases to be more portable with an explicit target triple. llvm-svn: 135134
* Revert r135075, "format string checking: long and int have the same widths ↵NAKAMURA Takumi2011-07-141-9/+10
| | | | | | | | on 32-bit, so we shouldn't warn about using" It fails on freebsd, mingw and msvc10. llvm-svn: 135129
* format string checking: long and int have the same widths on 32-bit, so we ↵Ted Kremenek2011-07-131-10/+9
| | | | | | | | shouldn't warn about using an "int" format specifier with a "long" type in 32-bit. llvm-svn: 135075
* Re-relax conversion specifier checking for printf format strings and ↵Ted Kremenek2011-07-131-3/+4
| | | | | | conversion specifiers. My recent change was a mistake. llvm-svn: 135048
* Fix inversion in argument type checking for format strings with conversion ↵Ted Kremenek2011-07-131-2/+2
| | | | | | specifiers for character types. llvm-svn: 135046
* Revert r133024, "[format strings] correctly suggest correct type for '%@'Daniel Dunbar2011-06-281-2/+1
| | | | | | | | | specifiers. Fixes <rdar://problem/9607158>." because it causes false positives on some code that uses CF toll free bridging. - I'll let Doug or Ted figure out the right fix here, possibly just to accept any pointer type. llvm-svn: 134041
* [format strings] correctly suggest correct type for '%@' specifiers. Fixes ↵Ted Kremenek2011-06-141-1/+2
| | | | | | <rdar://problem/9607158>. llvm-svn: 133024
* Don't warn when matching %p to nullptr.Anders Carlsson2010-11-061-2/+2
| | | | llvm-svn: 118344
* Fix printf format string checking for '%lc' (which expects a wint_t or ↵Ted Kremenek2010-08-241-0/+21
| | | | | | compatible argument). Fixes PR 7981. llvm-svn: 111978
* Detabify.Eli Friedman2010-08-221-1/+1
| | | | llvm-svn: 111768
* Revert r109428 "Hoist argument type checking into CheckFormatHandler. This ↵Michael J. Spencer2010-07-271-3/+1
| | | | | | | | is prep for scanf format" Got errors about ASTContext being undefined with Visual Studio 2010. llvm-svn: 109491
* Hoist argument type checking into CheckFormatHandler. This is prep for ↵Ted Kremenek2010-07-261-1/+3
| | | | | | | | scanf format string argument type checking. llvm-svn: 109428
* Move 'hasValidLengthModifier' from PrintfFormatSpecifier to FormatSpecifier.Ted Kremenek2010-07-201-2/+75
| | | | llvm-svn: 108906
* Add most of the boilerplate support for scanf format string checking. This ↵Ted Kremenek2010-07-161-0/+380
includes handling the parsing of scanf format strings and hooking the checking into Sema. Most of this checking logic piggybacks on what was already there for checking printf format strings, but the checking logic has been refactored to support both. What is left to be done is to support argument type checking in format strings and of course fix the usual tail of bugs that will follow. llvm-svn: 108500
OpenPOWER on IntegriCloud