summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/format-strings-fixit.c
Commit message (Collapse)AuthorAgeFilesLines
* Move the fixit for -Wformat-security to a note.Bob Wilson2016-03-151-6/+0
| | | | | | | | r263299 added a fixit for the -Wformat-security warning, but that runs into complications with our guideline that error recovery should be done as-if the fixit had been applied. Putting the fixit on a note avoids that. llvm-svn: 263584
* Add fix-it for format-security warnings.Bob Wilson2016-03-111-0/+6
| | | | llvm-svn: 263299
* Revert "clang/test/Driver/crash-report.c: This requires rewriter for ↵Alp Toker2014-07-161-1/+0
| | | | | | | | | | | | | | | | | | | | | -frewrite-includes. [PR20321]" We've decided to make the core rewriter class and PP rewriters mandatory. They're only a few hundred lines of code in total and not worth supporting as a distinct build configuration, especially since doing so disables key compiler features. This reverts commit r213150. Revert "clang/test: Introduce the feature "rewriter" for --enable-clang-rewriter." This reverts commit r213148. Revert "Move clang/test/Frontend/rewrite-*.c to clang/test/Frontend/Rewriter/" This reverts commit r213146. llvm-svn: 213159
* clang/test: Introduce the feature "rewriter" for --enable-clang-rewriter.NAKAMURA Takumi2014-07-161-0/+1
| | | | llvm-svn: 213148
* Remove wchar_t* buffer from scanf format fix-it test.Jordan Rose2014-03-201-5/+0
| | | | | | | | | | | | Amends r204300 to not try to test fixing a wchar_t* to "%ls", which we don't do correctly anyway. In C mode, wchar_t is just a typedef for a normal primitive integer type, not a distinct type like it is in C++. To make this work correctly, we'll need to look for the wchar_t typedef, not just the builtin type. Should fix the buildbots. llvm-svn: 204349
* Make format-strings-fixit.c aware of "%hu" uint16_t on wchar_t for targeting ↵NAKAMURA Takumi2014-03-201-2/+2
| | | | | | win32. llvm-svn: 204334
* scanf format checking: include the buffer length in the fix-it for %s.Jordan Rose2014-03-201-2/+26
| | | | | | Patch by Zach Davis! llvm-svn: 204300
* Format strings: don't ever convert %+d to %lu.Jordan Rose2013-01-171-4/+4
| | | | | | | | | | 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. llvm-svn: 172762
* 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
* -Wformat-non-iso: warn about positional arguments (pr12017)Hans Wennborg2012-03-091-0/+6
| | | | | | | | | 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
* Make -Wformat fix-its preserve original conversion specifiers.Hans Wennborg2012-02-151-11/+59
| | | | | | | | | | | | | | | | | 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". llvm-svn: 150578
* Check that arguments to a scanf call match the format specifier,Hans Wennborg2011-12-101-5/+70
| | | | | | and offer fixits when there is a mismatch. llvm-svn: 146326
* fix format specifier fixit for printf("%ld", "foo");Hans Wennborg2011-12-091-1/+5
| | | | | | It should reset the length modifier (unless it's a wchar_t string). llvm-svn: 146252
* Break out ssize_t test from Sema/format-strings-fixit.cHans Wennborg2011-10-191-2/+0
| | | | | | | Move to a separate test that sets a specific target triple so that the type of ssize_t is known. llvm-svn: 142481
* Another attempt at fixing format-strings-fixit.c.Hans Wennborg2011-10-181-5/+5
| | | | | | | 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. llvm-svn: 142348
* Disable the ssize_t test in format-strings-fixit.c.Hans Wennborg2011-10-181-3/+2
| | | | | | | | | | | | | | | | 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. llvm-svn: 142345
* Suggest %zu for size_t args to printf.Hans Wennborg2011-10-181-0/+18
| | | | | | | | 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. llvm-svn: 142342
* PR10867: Work around a bug in lit. Multiple RUN: lines are joined with &&, so:Richard Smith2011-09-061-1/+1
| | | | | | | | | | | | | | | | | 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. llvm-svn: 139132
* Revert r135147 and r135075. The consensus was that this wasn't the right ↵Ted Kremenek2011-07-141-3/+3
| | | | | | thing to do. llvm-svn: 135152
* Reapply r135075, but modify format-strings.c and format-strings-fixit.c test ↵Ted Kremenek2011-07-141-3/+3
| | | | | | cases to be more portable with an explicit target triple. llvm-svn: 135134
* When generating printf fixits, preserve the original formating for unsigned ↵Ted Kremenek2011-04-251-0/+26
| | | | | | integers (e.g., 'x', 'o'). llvm-svn: 130164
* Bug 7377: printf checking fails to flag some undefined behavior Tom Care2010-06-211-5/+3
| | | | | | | | | | | | | | | | | 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 llvm-svn: 106480
* Printf format strings: Added some more tests and fixed some minor bugs.Tom Care2010-06-181-0/+15
| | | | | | | | | | | | | | - 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 llvm-svn: 106275
* Fix format string checking of '%c' by treating it as an integer conversion. ↵Ted Kremenek2010-06-171-0/+2
| | | | | | Fixes PR 7391. llvm-svn: 106196
* Extend format string type-checking to include '%p'. Fixes remaining cases ↵Ted Kremenek2010-06-161-0/+1
| | | | | | PR 4468. llvm-svn: 106151
* Small fixes regarding printf fix suggestions.Tom Care2010-06-111-3/+11
| | | | | | | | | | | | - 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 llvm-svn: 105807
* Added FixIt support to printf format string checking.Tom Care2010-06-091-0/+20
- 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 llvm-svn: 105680
OpenPOWER on IntegriCloud