summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/format-strings-scanf.c
Commit message (Collapse)AuthorAgeFilesLines
* [clang] Add getUnsignedPointerDiffType methodAlexander Shaposhnikov2017-09-281-0/+30
| | | | | | | | | | | | | | | | | C11 standard refers to the unsigned counterpart of the type ptrdiff_t in the paragraph 7.21.6.1p7 where it defines the format specifier %tu. In Clang (in PrintfFormatString.cpp, lines 508-510) there is a FIXME for this case, in particular, Clang didn't diagnose %tu issues at all, i.e. it didn't emit any warnings on the code printf("%tu", 3.14). In this diff we add a method getUnsignedPointerDiffType for getting the corresponding type similarly to how it's already done in the other analogous cases (size_t, ssize_t, ptrdiff_t etc) and fix -Wformat diagnostics for %tu plus the emitted fix-it as well. Test plan: make check-all Differential revision: https://reviews.llvm.org/D38270 llvm-svn: 314470
* [clang] Fix handling of "%zd" in scanfAlexander Shaposhnikov2017-07-201-3/+31
| | | | | | | | | | | | | This diff addresses FIXMEs in lib/Analysis/ScanfFormatString.cpp for the case of ssize_t format specifier and adds tests. In particular, this change enables Clang to emit a warning on incorrect using of "%zd"/"%zn". Test plan: make check-all Differential revision: https://reviews.llvm.org/D35652 llvm-svn: 308662
* [Sema] Attempt to fix tests for utf-8 invalid format string specifiersBruno Cardoso Lopes2016-03-291-8/+0
| | | | | | | | | | Followup from r264752. Attempt to appease buildbots: http://lab.llvm.org:8011/builders/clang-ppc64be-linux/builds/2882 http://lab.llvm.org:8011/builders/clang-s390x-linux/builds/2619 llvm-svn: 264765
* [Sema] Handle UTF-8 invalid format string specifiersBruno Cardoso Lopes2016-03-291-0/+8
| | | | | | | | | | | | | | | | | Improve invalid format string specifier handling by printing out invalid specifiers characters with \x, \u and \U. Previously clang would print gargabe whenever the character is unprintable. Example, before: NSLog(@"%\u25B9"); => warning: invalid conversion specifier ' [-Wformat-invalid-specifier] after: NSLog(@"%\u25B9"); => warning: invalid conversion specifier '\u25b9' [-Wformat-invalid-specifier] Differential Revision: http://reviews.llvm.org/D18296 rdar://problem/24672159 llvm-svn: 264752
* Reduce false positives in printf/scanf format checkerAndy Gibbs2016-02-261-1/+13
| | | | | | | | | | | | | | | Summary: The printf/scanf format checker is a little over-zealous in handling the conditional operator. This patch reduces work by not checking code-paths that are never used and reduces false positives regarding uncovered arguments, for example in the code fragment: printf(minimal ? "%i\n" : "%i: %s\n", code, msg); Reviewers: rtrieu Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D15636 llvm-svn: 262025
* scanf analysis: handle scanlists that start with ^] (PR19559)Hans Wennborg2014-04-291-0/+5
| | | | llvm-svn: 207573
* Revert "Don't require -re suffix on -verify directives with regexes."Alp Toker2013-12-141-2/+2
| | | | | | | | | | This patch was submitted to the list for review and didn't receive a LGTM. (In fact one explicit objection and one query were raised.) This reverts commit r197295. llvm-svn: 197299
* Don't require -re suffix on -verify directives with regexes.Hans Wennborg2013-12-141-2/+2
| | | | | | Differential Revision: http://llvm-reviews.chandlerc.com/D2392 llvm-svn: 197295
* Change semantics of regex expectations in the diagnostic verifierHans Wennborg2013-12-111-2/+2
| | | | | | | | | | | | | | | | | | | | | | | Previously, a line like // expected-error-re {{foo}} treats the entirety of foo as a regex. This is inconvenient when matching type names containing regex characters. For example, to match "void *(class test8::A::*)(void)" inside such a regex, one would have to type "void \*\(class test8::A::\*\)\(void\)". This patch changes the semantics of expected-error-re to only treat the parts of the directive wrapped in double curly braces as regexes. This avoids the escaping problem and leads to nicer patterns for those cases; see e.g. the change to test/Sema/format-strings-scanf.c. (The balanced search for closing }} of a directive also makes us handle the full directive in test\SemaCXX\constexpr-printing.cpp:41 and :53.) Differential Revision: http://llvm-reviews.chandlerc.com/D2388 llvm-svn: 197092
* clang/test/Sema/format-strings-scanf.c: Relax a couple of expressions with ↵NAKAMURA Takumi2012-09-081-2/+2
| | | | | | | | | expected-warning-re to let matched for Win32 targets. - format specifies type 'wchar_t **' (aka 'int **') but the argument has type 'float *' - format specifies type 'wchar_t **' (aka 'unsigned short **') but the argument has type 'float *' llvm-svn: 163468
* Format strings: %Ld isn't available on Darwin or Windows.Jordan Rose2012-09-081-11/+1
| | | | | | | | | This seems to be a GNU libc extension; we offer a fixit to %lld on these platforms. <rdar://problem/11518237> llvm-svn: 163452
* Properly check length modfiers for %n in format strings.Hans Wennborg2012-08-071-0/+26
| | | | llvm-svn: 161408
* Remove ScanfArgType and bake that logic into ArgType.Hans Wennborg2012-08-071-0/+6
| | | | | | | | 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
* -Wformat: better handling of qualifiers on pointer argumentsHans Wennborg2012-07-311-0/+18
| | | | | | | 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 check the argument type for %n.Hans Wennborg2012-07-301-0/+5
| | | | | | | This makes Clang check that the corresponding argument for "%n" in a format string is a pointer to int. llvm-svn: 160966
* Format string analysis: give 'q' its own enumerator.Hans Wennborg2012-02-161-0/+4
| | | | | | | | | 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
* FormatCheckers should emit all diagnostics using EmitFormatDiagnostic().Jean-Daniel Dupas2012-01-311-0/+4
| | | | llvm-svn: 149394
* Teach scanf/printf checking about '%Ld' and friends (a GNU extension). ↵Ted Kremenek2012-01-241-0/+10
| | | | | | Fixes PR 9466. llvm-svn: 148859
* The 'l' length modifier makes sense with the scanlist conversion specifier.Ted Kremenek2012-01-201-1/+4
| | | | llvm-svn: 148586
* Tighten format string diagnostic and make it a bit clearer (and a bit closer ↵Ted Kremenek2012-01-201-12/+12
| | | | | | to GCC's). llvm-svn: 148579
* Treat -Wformat=0 as an alias for -Wformat.Hans Wennborg2012-01-171-0/+3
| | | | | | Fixes PR9195. llvm-svn: 148300
* scanf: parse the 'm' length modifier, and check that the right argumentsHans Wennborg2012-01-121-2/+18
| | | | | | 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-1/+2
| | | | | | | Before r148025 we (accidentally) didn't check whether a length modifier is appropriate for a scanlist, but now we do. llvm-svn: 148026
* scanf analysis: don't bail out after successful parse of scanlistHans Wennborg2012-01-121-0/+4
| | | | llvm-svn: 148025
* Fix test/Sema/format-strings-scanf.cHans Wennborg2011-12-151-1/+1
| | | | llvm-svn: 146651
* Support the 'a' length modifier in scanf format strings as a C90Hans Wennborg2011-12-151-0/+9
| | | | | | | | | extension. This fixes gcc.dg/format/c90-scanf-3.c and ext-4.c (test for excess errors). llvm-svn: 146649
* Fix signature of vsscanf in Builtins.defHans Wennborg2011-12-121-1/+1
| | | | llvm-svn: 146392
* Fix signature of sscanf in Builtins.defHans Wennborg2011-12-121-1/+1
| | | | llvm-svn: 146390
* Make fscanf, vscanf, etc. be recognized as scanf-like functions.Hans Wennborg2011-12-121-1/+23
| | | | llvm-svn: 146367
* Check that arguments to a scanf call match the format specifier,Hans Wennborg2011-12-101-3/+4
| | | | | | and offer fixits when there is a mismatch. llvm-svn: 146326
* Fix for PR9751 to change the behavior of -Wformat warnings. If the formatRichard Trieu2011-10-281-0/+12
| | | | | | | | | | | 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. llvm-svn: 143168
* Hookup checking for invalid length modifiers in scanf format strings.Ted Kremenek2010-07-201-0/+8
| | | | llvm-svn: 108907
* Don't warn when a '%%' or '%*d' (scanf) is used in a format string with ↵Ted Kremenek2010-07-191-0/+7
| | | | | | | | positional arguments, since these don't actually consume an argument. llvm-svn: 108757
* Hook up 'invalid conversion' warning for scanf format strings.Ted Kremenek2010-07-191-0/+1
| | | | llvm-svn: 108750
* Add missing conversion specifier parsing for 'u', 'x', 'o', and 's'. Fixes ↵Ted Kremenek2010-07-191-0/+3
| | | | | | <rdar://problem/8204052>. llvm-svn: 108742
* Remove unicode quotes characters that somehow made it into a recent commit ↵Ted Kremenek2010-07-161-1/+1
| | | | | | of mine. llvm-svn: 108552
* Hook up warning for an incomplete scanlist in scanf format strings.Ted Kremenek2010-07-161-0/+1
| | | | llvm-svn: 108542
* Tweak zero-field width in scanf format string diagnostic.Ted Kremenek2010-07-161-2/+2
| | | | llvm-svn: 108541
* Add initial test cases for scanf format string checking.Ted Kremenek2010-07-161-0/+14
llvm-svn: 108503
OpenPOWER on IntegriCloud