summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaObjC/format-strings-objc.m
Commit message (Collapse)AuthorAgeFilesLines
* Fix printf specifier handling: invalid specifier should not be marked as ↵Mehdi Amini2016-12-151-1/+1
| | | | | | | | | | | | "consuming data arguments" Reviewers: rsmith, bruno, dexonsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D27796 llvm-svn: 289850
* [Sema] Formatting warnings should see through Objective-C message sendsAlex Lorenz2016-10-241-0/+38
| | | | | | | | | | | | This commit improves the '-Wformat' warnings by ensuring that the formatting checker can see through Objective-C message sends when we are calling an Objective-C method with an appropriate format_arg attribute. rdar://23622446 Differential Revision: https://reviews.llvm.org/D25820 llvm-svn: 284961
* [Sema] Attempt to fix tests for utf-8 invalid format string specifiersBruno Cardoso Lopes2016-03-291-9/+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
* Move the fixit for -Wformat-security to a note.Bob Wilson2016-03-151-0/+1
| | | | | | | | 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
* Parse 'technical term' format specifier.Ted Kremenek2015-07-021-0/+13
| | | | | | | | | | | | | | | | | | | | | | | Objective-C format strings now support modifier flags that can be attached to a '@' conversion. Currently the only one supported, as of iOS 9 and OS X 10.11, is the new "technical term", denoted by the flag "tt", for example: %[tt]@ instead of just: %@ The 'tt' stands for "technical term", which is used by the string-localization facilities on Darwin to add the appropriate spacing or quotation depending the language locale. Implements <rdar://problem/20374720>. llvm-svn: 241243
* Recommit r222044 with a test fix - it does not make sense to huntAnton Korobeynikov2014-11-141-1/+1
| | | | | | for a typedef before arithmetic conversion in all rare corner cases. llvm-svn: 222049
* Temporary revert r221818 until all the problemsAnton Korobeynikov2014-11-121-1/+1
| | | | | | with objc stuff will be resolved. llvm-svn: 221829
* Update the tests to handle proper result type of (?:)Anton Korobeynikov2014-11-121-1/+1
| | | | llvm-svn: 221824
* Sema: When merging objc string literals, give the result a constant array type.Benjamin Kramer2014-02-251-0/+3
| | | | | | | | Also assert that we never create non-array string literals again. PR18939. llvm-svn: 202147
* Special case '%C' handling in ObjC format strings to handle integer literals ↵Ted Kremenek2013-10-151-0/+5
| | | | | | | | that can represent unicode characters Fixes <rdar://problem/13991617>. llvm-svn: 192673
* Implement C++'s restrictions on the type of an expression passed to a varargRichard Smith2013-08-051-0/+2
| | | | | | | | | | | | | function: it can't be 'void' and it can't be an initializer list. We give a hard error for these rather than treating them as undefined behavior (we can and probably should do the same for non-POD types in C++11, but as of this change we don't). Slightly rework the checking of variadic arguments in a function with a format attribute to ensure that certain kinds of format string problem (non-literal string, too many/too few arguments, ...) don't suppress this error. llvm-svn: 187735
* Handle "typeof" in Objective-C format string checking. This previously crashed.Ted Kremenek2013-04-101-0/+6
| | | | | | | | Yes, this came from actual code. Fixes <rdar://problem/13557053>. llvm-svn: 179155
* Format strings: offer a cast to 'unichar' for %C in Objective-C contexts.Jordan Rose2012-12-051-3/+3
| | | | | | | | | | | | | | | | | | | For most cases where a conversion specifier doesn't match an argument, we usually guess that the conversion specifier is wrong. However, if the argument is an integer type and the specifier is %C, it's likely the user really did mean to print the integer as a character. (This is more common than %c because there is no way to specify a unichar literal -- you have to write an integer literal, such as '0x2603', and then cast it to unichar.) This does not change the behavior of %S, since there are fewer cases where printing a literal Unicode *string* is necessary, but this could easily be changed in the future. <rdar://problem/11982013> llvm-svn: 169400
* Implicitly annotate __CFStringMakeConstantString with format_arg(1).Jordan Rose2012-08-081-3/+3
| | | | | | | | | We handled the builtin version of this function in r157968, but the builtin isn't used when compiling as -fno-constant-cfstrings. This should complete <rdar://problem/6157200>. llvm-svn: 161525
* For varargs, diagnose passing ObjC objects by value like other non-POD types.Jordan Rose2012-07-191-0/+8
| | | | | | | | | | | | | | While we still want to consider this a hard error (non-POD variadic args are normally a DefaultError warning), delaying the diagnostic allows us to give better error messages, which also match the usual non-POD errors more closely. In addition, this change improves the diagnostic messages for format string argument type mismatches by passing down the type of the callee, so we can say "variadic method" or "variadic function" appropriately. <rdar://problem/11825593> llvm-svn: 160517
* Capitalize "Objective-C" and "C++" in user-facing contexts.Jordan Rose2012-07-191-6/+6
| | | | | | No functionality change. llvm-svn: 160516
* Don't crash checking a format string if one of the arguments is invalid.Jordan Rose2012-07-191-0/+17
| | | | | | | | | Previously, we would ask for the SourceLocation of an argument even if it were NULL (i.e. if Sema resulted in an ExprError trying to build it). <rdar://problem/11890818> llvm-svn: 160515
* Teach format string checking about compile-time CFString constants.Jordan Rose2012-06-041-2/+17
| | | | | | | | | | | | | Within the guts of CheckFormatHandler, the IsObjCLiteral flag was being used in two ways: to see if null bytes were allowed, and to see if the '%@' specifier is allowed.* The former usage has been changed to an explicit test and the latter pushed down to CheckPrintfHandler and renamed ObjCContext, since it applies to CFStrings as well. * This also changes how wide chars are interpreted; in OS X Foundation, the wide character type is 'unichar', a typedef for short, rather than wchar_t. llvm-svn: 157968
* Inhibit ObjC format warning only in system headers (NSLocalizedString).Jean-Daniel Dupas2012-05-041-2/+11
| | | | | | Add a test case for the related NSAssert workaround. llvm-svn: 156205
* Added a new attribute, objc_root_class, which informs the compiler when a ↵Patrick Beard2012-04-061-1/+1
| | | | | | | | | root class is intentionally declared. The warning this inhibits, -Wobjc-root-class, is opt-in for now. However, all clang unit tests that would trigger the warning have been updated to use -Wno-objc-root-class. <rdar://problem/7446698> llvm-svn: 154187
* Support '%p' format specifier with block pointers.Ted Kremenek2012-03-151-1/+11
| | | | llvm-svn: 152839
* When calling a non variadic format function(vprintf, vscanf, NSLogv, …), ↵Jean-Daniel Dupas2012-02-211-2/+27
| | | | | | warn if the format string argument is a parameter that is not itself declared as a format string with compatible format. llvm-svn: 151080
* Tweak format string checking to work with %@ and ObjC toll-free bridging. ↵Ted Kremenek2012-02-061-0/+5
| | | | | | <rdar://problem/10814120> llvm-svn: 149907
* Revert r149721. chapuni tells me akyrtzi already fixed the testNico Weber2012-02-041-2/+1
| | | | | | by adding a triple, and the typedef makes things worse on windows. llvm-svn: 149740
* Try to get test passing on windows.Nico Weber2012-02-031-2/+2
| | | | | | Idea by Jean-Daniel Dupas. llvm-svn: 149721
* Add a triple to test/SemaObjC/format-strings-objc.m to make it pass in ↵Argyrios Kyrtzidis2012-02-031-1/+1
| | | | | | windows hosts. llvm-svn: 149696
* Let %S, %ls, %C match 16bit types in NSStrings.Nico Weber2012-01-311-0/+32
| | | | | | As discussed at http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20120130/052200.html llvm-svn: 149325
* Disable "non literal format string" for NSString that result from a macro ↵Jean-Daniel Dupas2012-01-301-1/+9
| | | | | | | | | expansion. This is to prevent diagnostic when using NSLocalizedString or CFCopyLocalizedString macros which are usually used in place of NS and CF strings literals. llvm-svn: 149268
* Update on format attribute handling.Jean-Daniel Dupas2012-01-301-1/+1
| | | | | | | - Remove the printf0 special handling as we treat it as printf anyway. - Perform basic checks (non-literal, empty) for all formats and not only printf/scanf. llvm-svn: 149236
* Add support for const pointer to literal-objc string as format attribute.Jean-Daniel Dupas2012-01-251-0/+18
| | | | llvm-svn: 148948
* Fix NSLog format string checking for %@.Ted Kremenek2012-01-251-0/+7
| | | | llvm-svn: 148885
* Tighten format string diagnostic and make it a bit clearer (and a bit closer ↵Ted Kremenek2012-01-201-2/+2
| | | | | | to GCC's). llvm-svn: 148579
* Fix a couples of issues in format strings checking.Jean-Daniel Dupas2012-01-171-0/+19
| | | | | | | PR 10274: format function attribute with the NSString archetype yields no compiler warnings PR 10275: format function attribute isn't checked in Objective-C methods llvm-svn: 148324
* Revert r133024, "[format strings] correctly suggest correct type for '%@'Daniel Dunbar2011-06-281-1/+0
| | | | | | | | | specifiers. Fixes <rdar://problem/9607158>." because it causes false positives on some code that uses CF toll free bridging. - I'll let Doug or Ted figure out the right fix here, possibly just to accept any pointer type. llvm-svn: 134041
* [format strings] correctly suggest correct type for '%@' specifiers. Fixes ↵Ted Kremenek2011-06-141-0/+1
| | | | | | <rdar://problem/9607158>. llvm-svn: 133024
* Extend format string type-checking to include '%p'. Fixes remaining cases ↵Ted Kremenek2010-06-161-0/+8
| | | | | | PR 4468. llvm-svn: 106151
* Fix crasher caused by setting a bit in a possibly empty bitvector whileTed Kremenek2010-02-271-0/+5
| | | | | | doing printf format string checking. This is a recent regression. llvm-svn: 97318
* Add test case for <rdar://problem/7068334> (which was fixed by r94864).Ted Kremenek2010-01-301-0/+9
| | | | llvm-svn: 94865
* Switch Sema over to using the new implementation of format stringTed Kremenek2010-01-291-1/+1
| | | | | | | | | checking. It passes all existing tests, and the diagnostics have been refined to provide better range information (we now highlight individual format specifiers) and more precise wording in the diagnostics. llvm-svn: 94837
* 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
* Change tests to use clang -cc1...Fariborz Jahanian2009-12-141-1/+1
| | | | llvm-svn: 91297
* Rename clang to clang-cc.Daniel Dunbar2009-03-241-1/+1
| | | | | | Tests and drivers updated, still need to shuffle dirs. llvm-svn: 67602
* Add support for CFString in format attribute.Daniel Dunbar2008-09-261-0/+7
| | | | llvm-svn: 56639
* move all objc sema tests into a new SemaObjC directory. Next step is toChris Lattner2008-07-261-0/+36
remove the objc- prefix from the tests that use it. llvm-svn: 54084
OpenPOWER on IntegriCloud