summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis/ScanfFormatString.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Remove trailing spaceFangrui Song2018-07-301-13/+13
| | | | | | sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} llvm-svn: 338291
* [clang] Add getUnsignedPointerDiffType methodAlexander Shaposhnikov2017-09-281-2/+2
| | | | | | | | | | | | | | | | | 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/+2
| | | | | | | | | | | | | 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
* Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.Galina Kistanova2017-06-031-0/+2
| | | | llvm-svn: 304641
* [Sema] Don't crash on scanf on forward-declared enums.Benjamin Kramer2016-08-201-1/+5
| | | | | | | | This is valid in GNU C, which allows pointers to incomplete enums. GCC just pretends that the underlying type is 'int' in those cases, follow that behavior. llvm-svn: 279374
* [Sema] Handle UTF-8 invalid format string specifiersBruno Cardoso Lopes2016-03-291-3/+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
* MS format strings: allow the 'h' length modifier with C, C, s and S (PR20808)Hans Wennborg2014-09-041-0/+6
| | | | llvm-svn: 217196
* MS format strings: support the 'w' length modifier (PR20808)Hans Wennborg2014-09-041-0/+5
| | | | llvm-svn: 217195
* [C++11] Use 'nullptr'. Analysis edition.Craig Topper2014-05-201-1/+1
| | | | llvm-svn: 209191
* Fix bad comment from r207573.Hans Wennborg2014-05-021-1/+1
| | | | llvm-svn: 207854
* scanf analysis: handle scanlists that start with ^] (PR19559)Hans Wennborg2014-04-291-0/+9
| | | | llvm-svn: 207573
* scanf format checking: include the buffer length in the fix-it for %s.Jordan Rose2014-03-201-6/+17
| | | | | | Patch by Zach Davis! llvm-svn: 204300
* Analysis: Add support for MS specific printf format specifiersDavid Majnemer2013-08-211-2/+12
| | | | | | | | | | | | | | Summary: Adds support for %I, %I32 and %I64. Reviewers: hans, jordan_rose, rnk, majnemer Reviewed By: majnemer CC: cfe-commits, cdavis5x Differential Revision: http://llvm-reviews.chandlerc.com/D1456 llvm-svn: 188937
* Add support for __wchar_t in -fms-extensions mode.Hans Wennborg2013-05-101-2/+2
| | | | | | | | | | | | | | | | | MSVC provides __wchar_t. This is the same as the built-in wchar_t type from C++, but it is also available with -fno-wchar and in C. The commit changes ASTContext to have two different types for this: - WCharTy is the built-in type used for wchar_t in C++ and __wchar_t. - WideCharTy is the type of a wide character literal. In C++ this is the same as WCharTy, and in C it is an integer type compatible with the type in <stddef.h>. This fixes PR15815. llvm-svn: 181587
* s/CPlusPlus0x/CPlusPlus11/gRichard Smith2013-01-021-1/+1
| | | | llvm-svn: 171367
* Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth2012-12-041-1/+1
| | | | | | | | | | | | | uncovered. This required manually correcting all of the incorrect main-module headers I could find, and running the new llvm/utils/sort_includes.py script over the files. I also manually added quite a few missing headers that were uncovered by shuffling the order or moving headers up to be main-module-headers. llvm-svn: 169237
* Format strings: %D, %U, and %O are valid on Darwin (same as %d, %u, %o).Jordan Rose2012-09-131-3/+23
| | | | | | | | | These will warn under -Wformat-non-iso, and will still be rejected outright on other platforms. <rdar://problem/12061922> llvm-svn: 163771
* Remove redundant semicolons which are null statements.Dmitri Gribenko2012-09-101-1/+1
| | | | llvm-svn: 163546
* Format strings: %Ld isn't available on Darwin or Windows.Jordan Rose2012-09-081-3/+5
| | | | | | | | | 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-1/+24
| | | | llvm-svn: 161408
* Remove ScanfArgType and bake that logic into ArgType.Hans Wennborg2012-08-071-92/+55
| | | | | | | | 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-52/+52
| | | | | | Also remove redundant constructors and unused member functions. llvm-svn: 161403
* -Wformat: better handling of qualifiers on pointer argumentsHans Wennborg2012-07-311-3/+9
| | | | | | | 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/+7
| | | | | | | This makes Clang check that the corresponding argument for "%n" in a format string is a pointer to int. llvm-svn: 160966
* Make -Wformat walk the typedef chain when looking for size_t, etc.Hans Wennborg2012-07-271-15/+2
| | | | | | | | | | | | | | 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
* Make suggestions for mismatched enum arguments to printf/scanf.Jordan Rose2012-06-041-0/+5
| | | | llvm-svn: 157962
* Format string analysis: give 'q' its own enumerator.Hans Wennborg2012-02-161-1/+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
* Make -Wformat fix-its preserve original conversion specifiers.Hans Wennborg2012-02-151-8/+10
| | | | | | | | | | | | | | | | | 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
* Teach scanf/printf checking about '%Ld' and friends (a GNU extension). ↵Ted Kremenek2012-01-241-2/+6
| | | | | | Fixes PR 9466. llvm-svn: 148859
* More dead code removal (using -Wunreachable-code)David Blaikie2012-01-201-2/+2
| | | | llvm-svn: 148577
* scanf: parse the 'm' length modifier, and check that the right argumentsHans Wennborg2012-01-121-3/+14
| | | | | | are used with that and the 'a' length modifier. llvm-svn: 148029
* scanf analysis: don't bail out after successful parse of scanlistHans Wennborg2012-01-121-1/+1
| | | | llvm-svn: 148025
* Support the 'a' length modifier in scanf format strings as a C90Hans Wennborg2011-12-151-5/+12
| | | | | | | | | extension. This fixes gcc.dg/format/c90-scanf-3.c and ext-4.c (test for excess errors). llvm-svn: 146649
* Check that arguments to a scanf call match the format specifier,Hans Wennborg2011-12-101-1/+252
| | | | | | and offer fixits when there is a mismatch. llvm-svn: 146326
* Revert r109428 "Hoist argument type checking into CheckFormatHandler. This ↵Michael J. Spencer2010-07-271-6/+0
| | | | | | | | is prep for scanf format" Got errors about ASTContext being undefined with Visual Studio 2010. llvm-svn: 109491
* Fix namespace polution.Dan Gohman2010-07-261-0/+1
| | | | llvm-svn: 109440
* Hoist argument type checking into CheckFormatHandler. This is prep for ↵Ted Kremenek2010-07-261-0/+6
| | | | | | | | scanf format string argument type checking. llvm-svn: 109428
* Hookup checking for invalid length modifiers in scanf format strings.Ted Kremenek2010-07-201-21/+23
| | | | llvm-svn: 108907
* Add 'ConversionSpecifier' root class in 'analyze_format_string' namespace andTed Kremenek2010-07-201-27/+27
| | | | | | | derived 'PrintfConversionSpecifier' from this class. We will do the same for 'ScanfConversionSpecifier'. llvm-svn: 108903
* Rename 'ConsumedSoFarArg' -> 'nArg' and 'OutIntPtrArg' to 'nArg' (scanf and ↵Ted Kremenek2010-07-201-1/+1
| | | | | | printf checking). llvm-svn: 108900
* Add missing conversion specifier parsing for 'u', 'x', 'o', and 's'. Fixes ↵Ted Kremenek2010-07-191-0/+4
| | | | | | <rdar://problem/8204052>. llvm-svn: 108742
* Hook up warning for an incomplete scanlist in scanf format strings.Ted Kremenek2010-07-161-2/+2
| | | | llvm-svn: 108542
* Add the main scanf-parsing logic that I meant to include in my previous commit.Ted Kremenek2010-07-161-0/+214
llvm-svn: 108502
OpenPOWER on IntegriCloud