summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaChecking.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Move UTF conversion routines from clang/lib/Basic to llvm/lib/SupportDmitri Gribenko2013-01-301-1/+1
| | | | | | This is required to use them in TableGen. llvm-svn: 173924
* c: When checking on validity of sizeof passed as size ofFariborz Jahanian2013-01-301-1/+2
| | | | | | | | argument to be memset, check for its type to be complete before calling Context.getTypeSize(PointeeTy) to prevent crash. // rdar://13081751. llvm-svn: 173872
* Patch to check for integer overflow. It has beenFariborz Jahanian2013-01-241-1/+16
| | | | | | commented on and approved by Richard Smith. llvm-svn: 173377
* Make __attribute__((nonnull)) use the general expression evaluator to search forNick Lewycky2013-01-231-2/+14
| | | | | | | nulls instead of limiting itself to the language-defined "null pointer constant". llvm-svn: 173227
* Defer checking for unsequenced operations on the RHS of && and || in order toRichard Smith2013-01-171-7/+17
| | | | | | reduce stack usage and hopefully bring back the linux x86_64 buildbot. llvm-svn: 172765
* -Wunsequenced: if the LHS of an &&, || or ?: is not constant, check forRichard Smith2013-01-171-6/+22
| | | | | | | | | unsequenced operations in the RHS. We don't compare the RHS with the rest of the expression yet; such checks will need care to avoid diagnosing unsequenced operations which are both in conditionally-evaluated subexpressions which actually can't occur together, such as in '(b && ++x) + (!b && ++x)'. llvm-svn: 172760
* Attempt to work around bug in older GCCs to fix buildbot.Richard Smith2013-01-171-3/+3
| | | | llvm-svn: 172693
* Add -Wunsequenced (with compatibility alias -Wsequence-point) to warn onRichard Smith2013-01-171-0/+418
| | | | | | | expressions which have undefined behavior due to multiple unsequenced modifications or an unsequenced modification and use of a variable. llvm-svn: 172690
* ArrayRef'ize Sema APIs related to format string checkingDmitri Gribenko2013-01-131-41/+44
| | | | llvm-svn: 172367
* s/CPlusPlus0x/CPlusPlus11/gRichard Smith2013-01-021-1/+1
| | | | llvm-svn: 171367
* Tweak Sema::CheckLiteralKind() to also include block literalsTed Kremenek2012-12-211-11/+6
| | | | | | | This simplifies some diagnostic logic in checkUnsafeAssignLiteral(), hopefully making it less error prone. llvm-svn: 170945
* Change checkUnsafeAssignLiteral() to use the new Sema::CheckLiteralKind().Ted Kremenek2012-12-211-24/+15
| | | | | | | | | | Along the way, fix a bug in CheckLiteralKind(), previously in diagnoseObjCLiteralComparison, where we didn't ignore parentheses in boxed expressions for purpose of classification. In other words, both @42 and @(42) should be classified as numeric literals. llvm-svn: 170931
* Use descriptive enum instead of raw integers for checkUnsafeAssignLiteral().Ted Kremenek2012-12-211-7/+9
| | | | llvm-svn: 170920
* Sink call to checkUnsafeAssignLiteral() into checkUnsafeAssignObject().Ted Kremenek2012-12-211-23/+22
| | | | llvm-svn: 170919
* Remove duplicate includes.Roman Divacky2012-12-211-2/+0
| | | | llvm-svn: 170903
* Extend checkUnsafeAssigns() to also handle assigning an object literal to a ↵Ted Kremenek2012-12-211-0/+39
| | | | | | | | | | weak reference. Thanks to Jordan Rose and John McCall for their sage code review. Fixes <rdar://problem/12569201>. llvm-svn: 170864
* Refactor checkUnsafeAssigns() to avoid code duplication with while loop.Ted Kremenek2012-12-211-16/+22
| | | | | | | | This is just a minor bit of refactoring, but it is nice cleanup for the subsequent patch that adds warning support for assigning literals to weak variables. llvm-svn: 170863
* Revert r170500. It over-zealously converted *ALL* things named Attributes, ↵Bill Wendling2012-12-201-3/+3
| | | | | | which is wrong here. llvm-svn: 170721
* Rename the 'Attributes' class to 'Attribute'. It's going to represent a ↵Bill Wendling2012-12-191-3/+3
| | | | | | single attribute in the future. llvm-svn: 170500
* Format strings: offer a cast to 'unichar' for %C in Objective-C contexts.Jordan Rose2012-12-051-24/+67
| | | | | | | | | | | | | | | | | | | 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
* Format strings: add more expression types that don't need parens to cast.Jordan Rose2012-12-051-0/+12
| | | | | | | No functionality change (the test change is a comment only, and the new functionality can't be tested using the current test). llvm-svn: 169399
* Format strings: a character literal should be printed with %c, not %d.Jordan Rose2012-12-051-10/+18
| | | | | | | | | | | | | | | | | | The type of a character literal is 'int' in C, but if the user writes a character /as/ a literal, we should assume they meant it to be a character and not a numeric value, and thus offer %c as a correction rather than %d. There's a special case for multi-character literals (like 'MooV'), which have implementation-defined value and usually cannot be printed with %c. These still use %d as the suggestion. In C++, the type of a character literal is 'char', and so this problem doesn't exist. <rdar://problem/12282316> llvm-svn: 169398
* Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth2012-12-041-12/+12
| | | | | | | | | | | | | 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
* Make -Wtautological-constant-out-of-range-compare behave sanely for enums ↵Eli Friedman2012-11-301-4/+3
| | | | | | | | with a signed fixed type. <rdar://problem/12780159>. llvm-svn: 169051
* Fix some trailing whitespace (on a blank line) to cycle/test bots.David Blaikie2012-11-191-1/+1
| | | | llvm-svn: 168340
* Take into account the zero sign bit for positive numbers when computing the bitRichard Trieu2012-11-161-1/+5
| | | | | | | width of an enum with negative values in IntRange. Include a test for -Wtautological-constant-out-of-range-compare where this had manifested. llvm-svn: 168126
* Fix an off-by-one error by switching < to <= in ↵Richard Trieu2012-11-151-1/+1
| | | | | | -Wtautological-constant-out-of-range-compare and added test case. llvm-svn: 168023
* Improve -Wtautological-constant-out-of-range-compare by taking into accountRichard Trieu2012-11-141-15/+73
| | | | | | | | | type conversion between integers. This allows the warning to be more accurate. Also, turned the warning off in an analyzer test. The relavent test cases are covered by the tests in Sema. llvm-svn: 167992
* PR14284: crash on ext-valid returning NULL from a void functionDavid Blaikie2012-11-081-1/+2
| | | | llvm-svn: 167565
* Address review comments for r167358: explicitly check for CK_BitCast instead ofDmitri Gribenko2012-11-031-2/+1
| | | | | | checking against a blacklist. llvm-svn: 167362
* Handle CK_NullToPointer casts in -Wtype-safety properly. Fixes PR14249.Dmitri Gribenko2012-11-031-1/+3
| | | | llvm-svn: 167358
* Add null check for malformed code.Ted Kremenek2012-10-111-2/+5
| | | | llvm-svn: 165733
* Minor cleanup for r165678; no functional change.Eli Friedman2012-10-111-1/+1
| | | | llvm-svn: 165679
* Make sure we perform the variadic method check correctly for calls to a ↵Eli Friedman2012-10-111-2/+14
| | | | | | member operator(). PR14057. llvm-svn: 165678
* Check if an IdentifierInfo* is null when the FunctionDecl isn't a simple C ↵Ted Kremenek2012-10-021-2/+6
| | | | | | | | function. Fixes <rdar://problem/12355298> llvm-svn: 164988
* -Wformat: Don't check format strings in uninstantiated templates.Jordan Rose2012-10-021-3/+2
| | | | | | | | | | | | | Also applies to -Wnonnull, -Wtype-safety, and -Wnon-pod-varargs. All of these can be better checked at instantiation time. This change does not actually affect regular CallExpr function calls, since the checks there only happen after overload resolution. However, it will affect Objective-C method calls. <rdar://problem/12373934> llvm-svn: 164984
* -Warc-repeated-use-of-weak: check ivars and variables as well.Jordan Rose2012-09-281-1/+11
| | | | | | | | | | Like properties, loading from a weak ivar twice in the same function can give you inconsistent results if the object is deallocated between the two loads. It is safer to assign to a strong local variable and use that. Second half of <rdar://problem/12280249>. llvm-svn: 164855
* Revert 'Fix a typo 'iff' => 'if''. iff is an abreviation of if and only if. ↵Sylvestre Ledru2012-09-271-1/+1
| | | | | | See: http://en.wikipedia.org/wiki/If_and_only_if Commit 164766 llvm-svn: 164769
* Fix a typo 'iff' => 'if'Sylvestre Ledru2012-09-271-1/+1
| | | | llvm-svn: 164766
* Avoid multiple atomic builtin declaration.Abramo Bagnara2012-09-221-4/+13
| | | | llvm-svn: 164454
* Improvements to my patch in r164143 perFariborz Jahanian2012-09-201-18/+16
| | | | | | Richard's comments. // rdar://12202422 llvm-svn: 164316
* minor refactoring of my last check-in.Fariborz Jahanian2012-09-181-2/+2
| | | | llvm-svn: 164145
* c: warn when an integer value comparison with anFariborz Jahanian2012-09-181-6/+68
| | | | | | | | integral expression have the obvious result. Patch reviewed by John McCall off line. // rdar://12202422 llvm-svn: 164143
* -Warc-retain-cycles: look through [^{...} copy] and Block_copy(^{...})Jordan Rose2012-09-171-0/+18
| | | | | | | | | | | | | Retain cycles happen in the case where a block is persisted past its life on the stack, and the way that occurs is by copying the block. We should thus look through any explicit copies we see. Note that Block_copy is actually a type-safe wrapper for _Block_copy, which does all the real work. <rdar://problem/12219663> llvm-svn: 164039
* const _Atomic(T) is not an atomic type, so do not allow it as the type 'A' inRichard Smith2012-09-151-1/+5
| | | | | | | C11 7.17's atomic operations. GNU's __atomic_* builtins do allow const-qualified atomics, though (!!) so don't restrict those. llvm-svn: 163964
* -Warc-retain-cycles: warn at variable initialization as well as assignment.Jordan Rose2012-09-151-1/+16
| | | | | | | | | | | | | | | | | | Specifically, this should warn: __block block_t a = ^{ a(); }; Furthermore, this case which previously warned now does not, since the value of 'b' is captured before the assignment occurs: block_t b; // not __block b = ^{ b(); }; (This will of course warn under -Wuninitialized, as before.) <rdar://problem/11015883> llvm-svn: 163962
* Format strings: offer a fixit for Darwin's %D/%U/%O to ISO %d/%u/%o.Jordan Rose2012-09-131-5/+22
| | | | | | <rdar://problem/12061922> llvm-svn: 163772
* Format strings: %D, %U, and %O are valid on Darwin (same as %d, %u, %o).Jordan Rose2012-09-131-2/+4
| | | | | | | | | These will warn under -Wformat-non-iso, and will still be rejected outright on other platforms. <rdar://problem/12061922> llvm-svn: 163771
* Format strings: suggest %lld instead of %qd and %Ld with -Wformat-non-iso.Jordan Rose2012-09-081-40/+46
| | | | | | | As a corollary to the previous commit, even when an extension is available, we can still offer a fixit to the standard modifier. llvm-svn: 163453
* Format strings: %Ld isn't available on Darwin or Windows.Jordan Rose2012-09-081-27/+51
| | | | | | | | | This seems to be a GNU libc extension; we offer a fixit to %lld on these platforms. <rdar://problem/11518237> llvm-svn: 163452
OpenPOWER on IntegriCloud