aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/ScanfFormatString.cpp
AgeCommit message (Collapse)Author
2012-09-13Format strings: %D, %U, and %O are valid on Darwin (same as %d, %u, %o).Jordan Rose
These will warn under -Wformat-non-iso, and will still be rejected outright on other platforms. <rdar://problem/12061922> git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163771 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-10Remove redundant semicolons which are null statements.Dmitri Gribenko
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163546 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-08Format strings: %Ld isn't available on Darwin or Windows.Jordan Rose
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
2012-08-07Properly check length modfiers for %n in format strings.Hans Wennborg
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161408 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-07Remove ScanfArgType and bake that logic into ArgType.Hans Wennborg
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161407 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-07Rename analyze_format_string::ArgTypeResult to ArgTypeHans Wennborg
Also remove redundant constructors and unused member functions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161403 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-31-Wformat: better handling of qualifiers on pointer argumentsHans Wennborg
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
2012-07-30Make -Wformat check the argument type for %n.Hans Wennborg
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
2012-07-27Make -Wformat walk the typedef chain when looking for size_t, etc.Hans Wennborg
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". git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160886 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-04Make suggestions for mismatched enum arguments to printf/scanf.Jordan Rose
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157962 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-16Format string analysis: give 'q' its own enumerator.Hans Wennborg
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
2012-02-15Make -Wformat fix-its preserve original conversion specifiers.Hans Wennborg
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". git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150578 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-24Teach scanf/printf checking about '%Ld' and friends (a GNU extension). ↵Ted Kremenek
Fixes PR 9466. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148859 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-20More dead code removal (using -Wunreachable-code)David Blaikie
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148577 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-12scanf: parse the 'm' length modifier, and check that the right argumentsHans Wennborg
are used with that and the 'a' length modifier. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148029 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-12scanf analysis: don't bail out after successful parse of scanlistHans Wennborg
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148025 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-15Support the 'a' length modifier in scanf format strings as a C90Hans Wennborg
extension. This fixes gcc.dg/format/c90-scanf-3.c and ext-4.c (test for excess errors). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146649 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-10Check that arguments to a scanf call match the format specifier,Hans Wennborg
and offer fixits when there is a mismatch. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146326 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-27Revert r109428 "Hoist argument type checking into CheckFormatHandler. This ↵Michael J. Spencer
is prep for scanf format" Got errors about ASTContext being undefined with Visual Studio 2010. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109491 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-26Fix namespace polution.Dan Gohman
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109440 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-26Hoist argument type checking into CheckFormatHandler. This is prep for ↵Ted Kremenek
scanf format string argument type checking. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109428 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-20Hookup checking for invalid length modifiers in scanf format strings.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108907 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-20Add 'ConversionSpecifier' root class in 'analyze_format_string' namespace andTed Kremenek
derived 'PrintfConversionSpecifier' from this class. We will do the same for 'ScanfConversionSpecifier'. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108903 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-20Rename 'ConsumedSoFarArg' -> 'nArg' and 'OutIntPtrArg' to 'nArg' (scanf and ↵Ted Kremenek
printf checking). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108900 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-19Add missing conversion specifier parsing for 'u', 'x', 'o', and 's'. Fixes ↵Ted Kremenek
<rdar://problem/8204052>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108742 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-16Hook up warning for an incomplete scanlist in scanf format strings.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108542 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-16Add the main scanf-parsing logic that I meant to include in my previous commit.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108502 91177308-0d34-0410-b5e6-96231b3b80d8