summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/nonnull.c
Commit message (Collapse)AuthorAgeFilesLines
* When checking for nonnull parameter attributes, also check the ParmVarDecl ↵Aaron Ballman2014-12-111-0/+12
| | | | | | since the attribute may reside there, instead of just on the FunctionDecl. Fixes PR21668. llvm-svn: 224039
* [Sema] Patch to issue warning on comparing parameters withFariborz Jahanian2014-11-181-0/+58
| | | | | | | | | | | nonnull attribute when comparison is always true/false. Original patch by Steven Wu. I have added extra code to prevent issuing of warning when the nonnull parameter is modified prior to the comparison. This addition prevents false positives in the most obvious cases. There may still be false positive warnings in some cases (as one of my tests indicates), but benefit far outweighs such cases. rdar://18712242 llvm-svn: 222264
* This patch reverts r220496 which issues warning on comparing Fariborz Jahanian2014-11-031-25/+0
| | | | | | | | parameters with nonnull attribute when comparison is always true/false. Patch causes false positive when parameter is modified in the function. llvm-svn: 221163
* patch to issue warning on comparing parameters withFariborz Jahanian2014-10-231-0/+25
| | | | | | | | nonnull attribute when comparison is always true/false. Patch by Steven Wu with few fixes and minor refactoring and adding tests by me. rdar://18712242 llvm-svn: 220496
* Fix representation of __attribute__((nonnull)) to support correctly modelingRichard Smith2014-08-271-4/+33
| | | | | | | | | | | | | | | the no-arguments case. Don't expand this to an __attribute__((nonnull(A, B, C))) attribute, since that does the wrong thing for function templates and varargs functions. In passing, fix a grammar error in the diagnostic, a crash if __attribute__((nonnull(N))) is applied to a varargs function, a bug where the same null argument could be diagnosed multiple times if there were multiple nonnull attributes referring to it, and a bug where nonnull attributes would not be accumulated correctly across redeclarations. llvm-svn: 216520
* The returns_nonnull attribute does not require a function prototype because ↵Aaron Ballman2014-07-111-1/+2
| | | | | | it affects only the return value, not any arguments. In turn, asking for a function or method result type should not require a function prototype either, so getFunctionOrMethodResultType has been relaxed. llvm-svn: 212827
* 'nonnull(1)' on a block parameter should apply to the block's argument.Jordan Rose2014-02-111-0/+8
| | | | | | | | | | | | | | | Thanks to r199467, __attribute__((nonnull)) (without arguments) can apply directly to parameters, instead of being applied to the whole function. However, the old form of nonnull (with an argument index) could also apply to the arguments of function and block pointers, and both of these can be passed as parameters. Now, if 'nonnull' with an argument is found on a parameter, /and/ the parameter is a function or block pointer, it is handled the old way. PR18795 llvm-svn: 201162
* Add basic checking for returning null from functions/methods marked ↵Ted Kremenek2014-01-221-0/+6
| | | | | | | | | | 'returns_nonnull'. This involved making CheckReturnStackAddr into a static function, which is now called by a top-level return value checking routine called CheckReturnValExpr. llvm-svn: 199790
* Making some minor improvements to r199626.Aaron Ballman2014-01-201-4/+4
| | | | llvm-svn: 199663
* Wire up basic parser/sema support for attribute 'returns_nonnull'.Ted Kremenek2014-01-201-0/+6
| | | | | | | | | | | This attribute is supported by GCC. More generally it should probably be a type attribute, but this behavior matches 'nonnull'. This patch does not include warning logic for checking if a null value is returned from a function annotated with this attribute. That will come in subsequent patches. llvm-svn: 199626
* Adding a test case for nonnull being attached to something other than a ↵Aaron Ballman2014-01-171-0/+1
| | | | | | function, Objective-C method, or parameter. llvm-svn: 199496
* Enhance attribute 'nonnull' to be applicable to parameters directly (infix).Ted Kremenek2014-01-171-0/+11
| | | | | | | | | | | | | | | | | | | | | This allows the following syntax: void baz(__attribute__((nonnull)) const char *str); instead of: void baz(const char *str) __attribute__((nonnull(1))); This also extends to Objective-C methods. The checking logic in Sema is not as clean as I would like. Effectively now we need to check both the FunctionDecl/ObjCMethodDecl and the parameters, so the point of truth is spread in two places, but the logic isn't that cumbersome. Implements <rdar://problem/14691443>. llvm-svn: 199467
* This diagnostic did not accept arguments, and did not have any test ↵Aaron Ballman2013-12-261-0/+1
| | | | | | | | coverage. Parameterized the diagnostic, and made it more consistent with other attribute diagnostic wordings. Added test coverage. Since this warning was generalized, it was also given a sensible warning group flag and the corresponding test was updated to reflect this. llvm-svn: 198053
* Refactor some attributes to use checkFunctionOrMethodArgumentIndex instead ↵Aaron Ballman2013-07-301-0/+1
| | | | | | of using custom logic. No functional changes intended. llvm-svn: 187398
* This test was missing its -verify argument.Aaron Ballman2013-07-221-1/+1
| | | | llvm-svn: 186847
* Handle nonnull attribute with optional argument number onFariborz Jahanian2011-06-271-0/+21
| | | | | | | functions with arguments of transparent unions type. // rdar://9584012 llvm-svn: 133941
* Handle some more fallout with the conversion of using PointerType forTed Kremenek2009-07-151-32/+0
| | | | | | | | | | | | | | | Objective-C pointers to using ObjCObjectPointerType. Now the checking for 'attribute ((nonnull))' in Sema doesn't emit an error when trying to apply that attribute to a parameter that is an Objective-C pointer (this is a regression). To prevent this regression from occuring in the future, the 'nonnull.c' test was moved to test/SemaObjC and renamed 'nonnull.m'. I also enhanced the tests to show that function calls involved a NULL Objective-C pointer constant does not trigger a warning. This is consistent with GCC, but should likely be fixed. llvm-svn: 75856
* merge two tests.Chris Lattner2009-05-251-1/+25
| | | | llvm-svn: 72392
* Rename clang to clang-cc.Daniel Dunbar2009-03-241-1/+1
| | | | | | Tests and drivers updated, still need to shuffle dirs. llvm-svn: 67602
* Tidy up sema processing of attribute "nonull":Ted Kremenek2008-09-011-1/+1
| | | | | | | | - warn about nonnull being applied to functions with no pointer arguments - continue processing argument list in the attribute when we encounter a non-pointer parameter being marked as nonnull - when no argument list is specified, only mark pointers as nonnull. This fixes PR 2732 and radar 6188814. llvm-svn: 55610
* Add test case for nonnull attribute.Ted Kremenek2008-07-211-0/+8
Fix indexing bug. llvm-svn: 53882
OpenPOWER on IntegriCloud