summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/format-strings.c
Commit message (Collapse)AuthorAgeFilesLines
* add a bunch of missing prototypes to testsChris Lattner2010-01-091-0/+1
| | | | llvm-svn: 93072
* fix a bug handling the gnu ?: extension. Patch by Storlek on IRC,Chris Lattner2009-12-221-0/+1
| | | | | | who prefers to be stealthy and mysterious. llvm-svn: 91888
* Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'.Daniel Dunbar2009-12-151-1/+1
| | | | | | | | | - This is designed to make it obvious that %clang_cc1 is a "test variable" which is substituted. It is '%clang_cc1' instead of '%clang -cc1' because it can be useful to redefine what gets run as 'clang -cc1' (for example, to set a default target). llvm-svn: 91446
* Don't #include <stdio.h> when tests don't need it, or use clang instead of ↵Daniel Dunbar2009-11-171-8/+11
| | | | | | clang-cc when they do. llvm-svn: 89070
* Fix some Window-isms to get these tests to pass on Windows.John Thompson2009-10-291-1/+5
| | | | llvm-svn: 85450
* Fix <rdar://problem/6880975> [format string] Assertion failed: (Arg < ↵Ted Kremenek2009-05-131-0/+5
| | | | | | | | | NumArgs && "Arg access out of range!"). For format string checking, only check the type of the format specifier for non-vararg functions. llvm-svn: 71672
* implement -Wformat-security properly, which is enabled by default.Chris Lattner2009-04-291-0/+12
| | | | | | This enables one specific class of non-literal format warnings. llvm-svn: 70368
* tweak warning options to be more like gcc:Chris Lattner2009-04-291-1/+1
| | | | | | | | | | | 1. All all variants of -Wformat*, make them imply -Wformat. GCC warns if you use -Wformatfoo without -Wformat. We just make one imply the other. 2. Make -Wformat-nonliteral default to off, like gcc. It is an incredible nuisance. 3. Accept but currently ignore -Wformat-extra-args. llvm-svn: 70362
* Rename clang to clang-cc.Daniel Dunbar2009-03-241-1/+1
| | | | | | Tests and drivers updated, still need to shuffle dirs. llvm-svn: 67602
* Fix <rdar://problem/6704086> by allowing the format string checking in Sema toTed Kremenek2009-03-201-0/+14
| | | | | | | | allow non-literal format strings that are variables that (a) permanently bind to a string constant and (b) whose string constants are resolvable within the same translation unit. llvm-svn: 67404
* use the full spelling of a string literal token so that trigraphsChris Lattner2009-02-181-2/+7
| | | | | | | | | | | | | | | | | | | | | and escaped newlines don't throw off the offset computation. On this testcase: printf("abc\ def" "%*d", (unsigned) 1, 1); Before: t.m:5:5: warning: field width should have type 'int', but argument has type 'unsigned int' def" ^ after: t.m:6:12: warning: field width should have type 'int', but argument has type 'unsigned int' "%*d", (unsigned) 1, 1); ^ ~~~~~~~~~~~~ llvm-svn: 64930
* add c testcase for string literal diagnostic improvement.Chris Lattner2009-02-181-0/+3
| | | | llvm-svn: 64929
* Add hook to add attributes to function declarations that we knowDouglas Gregor2009-02-141-0/+6
| | | | | | | | | | | | | | | | about, whether they are builtins or not. Use this to add the appropriate "format" attribute to NSLog, NSLogv, asprintf, and vasprintf, and to translate builtin attributes (from Builtins.def) into actual attributes on the function declaration. Use the "printf" format attribute on function declarations to determine whether we should do format string checking, rather than looking at an ad hoc list of builtins and "known" function names. Be a bit more careful about when we consider a function a "builtin" in C++. llvm-svn: 64561
* Fix test case (incomplete "expected-warning" line)Ted Kremenek2009-01-121-1/+1
| | | | llvm-svn: 62119
* Patch by Roman Divacky:Ted Kremenek2009-01-121-0/+6
| | | | | | | | | Extend string-literal checking for printf() format string to handle conditional ternary operators where both sides are literals. This fixes PR 3319: http://llvm.org/bugs/show_bug.cgi?id=3319 llvm-svn: 62117
* Add support for format string checking of object-size checkingDaniel Dunbar2008-10-021-0/+4
| | | | | | | versions of sprintf and friends. - Added FIXME that this mechanism should be generalized. llvm-svn: 56962
* Fix test failure on Linux.Eli Friedman2008-08-201-0/+3
| | | | llvm-svn: 55032
* Add EXTWARN Diagnostic class.Daniel Dunbar2008-08-051-3/+3
| | | | | | | | | | | | - Like EXTENSION but always generates a warning (even without -pedantic). - Updated ptr -> int, int -> ptr, and incompatible cast warnings to be EXTWARN. - Other EXTENSION level diagnostics should be audited for upgrade. - Updated several test cases to fix code which produced unanticipated warnings. llvm-svn: 54335
* Modified format-string checking to not emit a warning when all of theTed Kremenek2007-12-171-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | following hold: (1) A vprintf-like function is called that takes the argument list via a via_list argument. (2) The format string is a non-literal that is the parameter value of the enclosing function, e.g: void logmessage(const char *fmt,...) { va_list ap; va_start(ap,fmt); fprintf(fmt,ap); // Do not emit a warning. } In the future this special case will be enhanced to consult the "format" attribute attached to a function declaration instead of just allowing a blank check for all function parameters to be used as format strings to vprintf-like functions. This will happen when more support for attributes becomes available. llvm-svn: 45114
* Fix a warningAnders Carlsson2007-10-151-1/+1
| | | | llvm-svn: 42973
* Added notion of '*' specified format width/specifiers when checkingTed Kremenek2007-10-121-0/+8
| | | | | | | | | printf format strings. Added type checking to see if the matching width/precision argument was of type 'int'. Thanks to Anders Carlsson for reporting this missing feature. llvm-svn: 42933
* Add some more diagnostics for va_start, fix tests so they pass with these ↵Anders Carlsson2007-10-121-3/+2
| | | | | | new diags. llvm-svn: 42917
* rename -parse-ast-print to -ast-printChris Lattner2007-10-111-1/+1
| | | | | | | rename -parse-ast-dump to -ast-dump remove -parse-ast, which is redundant with -fsyntax-only llvm-svn: 42852
* Removed option "-parse-ast-check" from clang driver. This is now implementedTed Kremenek2007-09-261-1/+1
| | | | | | | | | | | | using "-parse-ast -verify". Updated all test cases (using a sed script) that invoked -parse-ast-check to now use -parse-ast -verify. Fixed a bug where using "-verify" instead of "-parse-ast-check" would not correctly create the DiagClient needed to accumulate diagnostics. llvm-svn: 42365
* Added support for additional format string checking for the printfTed Kremenek2007-08-141-0/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | family of functions. Previous functionality only included checking to see if the format string was a string literal. Now we check parse the format string (if it is a literal) and perform the following checks: (1) Warn if: number conversions (e.g. "%d") != number data arguments. (2) Warn about missing format strings (e.g., "printf()"). (3) Warn if the format string is not a string literal. (4) Warn about the use se of '%n' conversion. This conversion is discouraged for security reasons. (5) Warn about malformed conversions. For example '%;', '%v'; these are not valid. (6) Warn about empty format strings; e.g. printf(""). Although these can be optimized away by the compiler, they can be indicative of broken programmer logic. We may need to add additional support to see when such cases occur within macro expansion to avoid false positives. (7) Warn if the string literal is wide; e.g. L"%d". (8) Warn if we detect a '\0' character WITHIN the format string. Test cases are included. llvm-svn: 41076
* initial support for checking format strings, patch by Ted Kremenek:Chris Lattner2007-08-101-0/+23
"I've coded up some support in clang to flag warnings for non-constant format strings used in calls to printf-like functions (all the functions listed in "man fprintf"). Non-constant format strings are a source of many security exploits in C/C++ programs, and I believe are currently detected by gcc using the flag -Wformat-nonliteral." llvm-svn: 41003
OpenPOWER on IntegriCloud