summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaChecking.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Move a method from IdentifierTable.h out of line and remove the SmallString ↵Benjamin Kramer2012-02-041-0/+1
| | | | | | | | include. Fix all the transitive include users. llvm-svn: 149783
* Do not show macro expansion in strncat warnings, which can be defined asAnna Zaks2012-02-031-7/+16
| | | | | | a builtin. llvm-svn: 149657
* Change the check for constant-conversion with width-1 bitfields so it ↵Eli Friedman2012-02-021-2/+2
| | | | | | doesn't suppress quite as many cases. Based off a testcase in the gcc testsuite. llvm-svn: 149572
* Add a new compiler warning, which flags anti-patterns used as the sizeAnna Zaks2012-02-011-4/+109
| | | | | | | | | | | argument in strncat. The warning is ignored by default since it needs more qualification. TODO: The warning message and the note are messy when strncat is a builtin due to the macro expansion. llvm-svn: 149524
* Revert r149359. This was a hack to a problem with an easy workaround, and ↵Ted Kremenek2012-01-311-14/+4
| | | | | | it doesn't feel like general solution. llvm-svn: 149404
* FormatCheckers should emit all diagnostics using EmitFormatDiagnostic().Jean-Daniel Dupas2012-01-311-15/+21
| | | | llvm-svn: 149394
* Don't warn about -Wshorten-64-to-32 in unreachable code. Fixes ↵Ted Kremenek2012-01-311-4/+14
| | | | | | <rdar://problem/10759934>. Apparently this is a common idiom in Linux (among other places). llvm-svn: 149359
* Make a bunch of local functions 'static'.Ted Kremenek2012-01-311-22/+23
| | | | llvm-svn: 149358
* Let %S, %ls, %C match 16bit types in NSStrings.Nico Weber2012-01-311-1/+2
| | | | | | 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-0/+7
| | | | | | | | | 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-58/+40
| | | | | | | - 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
* Added source location for the template keyword in AST template-id expressions.Abramo Bagnara2012-01-271-0/+1
| | | | llvm-svn: 149127
* Turn off implicit truncation warning for compound assignment to bitfields; ↵Eli Friedman2012-01-261-2/+2
| | | | | | | | it might be reasonable in some cases, but it clearly doesn't make sense in some cases, like the included testcase. <rdar://problem/10238797>, part 2. llvm-svn: 149095
* Make the bitfield implicit truncation warning slightly more aggressive, and ↵Eli Friedman2012-01-261-8/+9
| | | | | | make the printed warning a bit more accurate. The new behavior matches gcc's -Wconversion. <rdar://problem/10238797>. llvm-svn: 149089
* Add support for const pointer to literal-objc string as format attribute.Jean-Daniel Dupas2012-01-251-0/+4
| | | | llvm-svn: 148948
* Add "multiple format attributes" support on block.Jean-Daniel Dupas2012-01-251-6/+6
| | | | llvm-svn: 148890
* Make sure the AST correctly represents lvalue-to-rvalue conversions where ↵Eli Friedman2012-01-231-0/+6
| | | | | | appropriate. llvm-svn: 148673
* objc-arc: when 'assign' attribute is unspecified,Fariborz Jahanian2012-01-171-4/+24
| | | | | | | | rely on property's type for its life-time to avoid bogus warning with -Warc-unsafe-retained-assign. // rdar://10694932 llvm-svn: 148355
* Fix a couples of issues in format strings checking.Jean-Daniel Dupas2012-01-171-73/+96
| | | | | | | 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
* Remove unreachable code in Clang. (replace with llvm_unreachable where ↵David Blaikie2012-01-171-2/+2
| | | | | | appropriate or when GCC requires it) llvm-svn: 148292
* Use Builtin ID as the return valueAnna Zaks2012-01-171-18/+30
| | | | | | | | | | for FunctionDecl::getMemoryFunctionKind(). This is a follow up on the Chris's review for r148142: We don't want to pollute FunctionDecl with an extra enum. (To make this work, added memcmp and family to the library builtins.) llvm-svn: 148267
* Some improvements to the handling of C11 atomic types:David Chisnall2012-01-161-1/+7
| | | | | | | | | | | | | | | | | | - Add atomic-to/from-nonatomic cast types - Emit atomic operations for arithmetic on atomic types - Emit non-atomic stores for initialisation of atomic types, but atomic stores and loads for every other store / load - Add a __atomic_init() intrinsic which does a non-atomic store to an _Atomic() type. This is needed for the corresponding C11 stdatomic.h function. - Enables the relevant __has_feature() checks. The feature isn't 100% complete yet, but it's done enough that we want people testing it. Still to do: - Make the arithmetic operations on atomic types (e.g. Atomic(int) foo = 1; foo++;) use the correct LLVM intrinsic if one exists, not a loop with a cmpxchg. - Add a signal fence builtin - Properly set the fenv state in atomic operations on floating point values - Correctly handle things like _Atomic(_Complex double) which are too large for an atomic cmpxchg on some platforms (this requires working out what 'correctly' means in this context) - Fix the many remaining corner cases llvm-svn: 148242
* Move identification of memory setting and copying functions (memset,Anna Zaks2012-01-131-88/+20
| | | | | | | memcmp, strncmp,..) out of Sema and into FunctionDecl so that the logic could be reused in the analyzer. llvm-svn: 148142
* objc-arc: fixes a crash when trying to find out retaining cycleFariborz Jahanian2012-01-101-4/+12
| | | | | | ownership of property sent to 'super'. // rdar://10640891 llvm-svn: 147868
* Suppress -Wunused-value within macros from system headers.Matt Beaumont-Gay2012-01-061-13/+8
| | | | | | | Along the way, move a helper function from SemaChecking.cpp to a more accessible home in SourceManager. llvm-svn: 147692
* Add an APValue representation for the difference between two ↵Eli Friedman2012-01-041-1/+1
| | | | | | | | | | address-of-label expressions. Add support to Evaluate and CGExprConstant for generating/handling them. Remove the special-case for such differences in Expr::isConstantInitializer. With that done, remove a bunch of buggy code from CGExprConstant for handling scalar expressions which is no longer necessary. Fixes PR11705. llvm-svn: 147561
* Small refactoring and simplification of constant evaluation and some of itsRichard Smith2011-12-281-4/+2
| | | | | | clients. No functionality change. llvm-svn: 147318
* PR11594: Don't blindly build a UnaryOperator UO_Minus on an expression whichRichard Smith2011-12-161-1/+3
| | | | | | | might not be an rvalue when checking array accesses. Instead, pass through a flag indicating the array index is negated. llvm-svn: 146753
* Support the 'a' length modifier in scanf format strings as a C90Hans Wennborg2011-12-151-2/+4
| | | | | | | | | extension. This fixes gcc.dg/format/c90-scanf-3.c and ext-4.c (test for excess errors). llvm-svn: 146649
* Enhance the -Wsign-compare handling to suppress the -Wsign-compare warning ↵Eli Friedman2011-12-151-1/+1
| | | | | | in the case of a shifted bitfield. PR11572. llvm-svn: 146634
* r146430 lost some compile-time performance on ↵Matt Beaumont-Gay2011-12-141-19/+24
| | | | | | MultiSource/Benchmarks/MiBench/security-rijndael; this gets most of it back. llvm-svn: 146562
* Suppress -Warray-bounds in certain cases involving macros from system headers.Matt Beaumont-Gay2011-12-121-1/+11
| | | | | | The motivation here is a "clever" implementation of strncmp(), which peels the first few comparisons via chained conditional expressions which ensure that the input arrays are known at compile time to be sufficiently large. llvm-svn: 146430
* Check that arguments to a scanf call match the format specifier,Hans Wennborg2011-12-101-2/+32
| | | | | | and offer fixits when there is a mismatch. llvm-svn: 146326
* Add notes for suppressing and (if it's a zero-arg function returning bool) ↵David Blaikie2011-12-091-0/+10
| | | | | | fixing the function-to-bool conversion warning. llvm-svn: 146280
* Make printf warnings refer to wint_t and wchar_t by nameHans Wennborg2011-12-091-3/+0
| | | | | | in addition to underlying type. llvm-svn: 146254
* Make printf warnings refer to intmax_t et al. by nameHans Wennborg2011-12-071-3/+3
| | | | | | | | | | | | in addition to underlying type. For example, the warning for printf("%zu", 42.0); changes from "conversion specifies type 'unsigned long'" to "conversion specifies type 'size_t' (aka 'unsigned long')" (This is a second attempt after r145697, which got reverted.) llvm-svn: 146032
* Switch a cast to a dyn_cast and check the pointer before using. Fixes a crashRichard Trieu2011-12-061-4/+5
| | | | | | | | | | in the following code: void test4(bool (&x)(void)) { while (x); } llvm-svn: 145918
* Add a warning for implicit conversion from function literals (and staticLang Hames2011-12-051-0/+19
| | | | | | | | | | | | | methods) to bool. E.g. void foo() {} if (f) { ... // <- Warns here. } Only applies to non-weak functions, and does not apply if the function address is taken explicitly with the addr-of operator. llvm-svn: 145849
* Revert r145697 and dependent patch r145702. It added a dependency fromNick Lewycky2011-12-021-1/+1
| | | | | | lib/Analysis to lib/Sema which is cyclical. llvm-svn: 145724
* Make conversion specifier warning refer to typedef if possible.Hans Wennborg2011-12-021-1/+1
| | | | | | | | For example, the warning for printf("%zu", 42.0); changes from "conversion specifies type 'unsigned long'" to "conversion specifies type 'size_t' (aka 'unsigned long')" llvm-svn: 145697
* Specially whitelist the selector 'addOperationWithBlock:' for the ↵Ted Kremenek2011-12-011-1/+7
| | | | | | | | retain-cycle checking in -Warc-retain-cycles. This commonly is hit by users using NSOperationQueue. Fixes <rdar://problem/10465721>. llvm-svn: 145548
* Suppress -Warray-bounds for classes (not just structs) where the last field isMatt Beaumont-Gay2011-11-291-2/+5
| | | | | | a 1-length character array. llvm-svn: 145445
* Merge branch 'yo-dawg-i-herd-u-like-arrays'Matt Beaumont-Gay2011-11-291-0/+11
| | | | llvm-svn: 145421
* When checking a call to a builtin atomic operation, be sure toDouglas Gregor2011-11-281-13/+199
| | | | | | | | | consider the _<width> variants as well, which we'll see if we're performing the type checking in a template instantiation where the call expression itself was originally not type-dependent. Fixes PR11411. llvm-svn: 145248
* Fix Neon builtin pointer argument checking for "sret" builtins.Bob Wilson2011-11-161-22/+18
| | | | | | | | | | | The code for checking Neon builtin pointer argument types was assuming that there would only be one pointer argument. But, for vld2-4 builtins, the first argument is a special sret pointer where the result will be stored. So, instead of scanning all the arguments to find a pointer, have TableGen figure out the index of the pointer argument that needs checking. That's better than scanning all the arguments regardless. <rdar://problem/10448804> llvm-svn: 144834
* Constant expression evaluation: support for evaluation of structs and unions ofRichard Smith2011-11-101-3/+3
| | | | | | | literal types, as well as derived-to-base casts for lvalues and derived-to-virtual-base casts. llvm-svn: 144265
* There's no good reason to track temporaries in ExprWithCleanups,John McCall2011-11-101-0/+6
| | | | | | | but it is sometimes useful to track blocks. Do so. Also optimize the storage of these expressions. llvm-svn: 144263
* Mark the overloaded atomic builtins as having custom type checking,Douglas Gregor2011-11-081-8/+0
| | | | | | | | | which they do. This avoids all of the default argument promotions that we (1) don't want, and (2) undo during that custom type checking, and makes sure that we don't run into trouble during template instantiation. Fixes PR11320. llvm-svn: 144110
* Check pointer types for arguments of Neon load/store macros. rdar://9958031Bob Wilson2011-11-081-3/+54
| | | | | | | | | | | The Neon load/store intrinsics need to be implemented as macros to avoid hiding alignment attributes on the pointer arguments, and the macros can only evaluate those pointer arguments once (in case they have side effects), so it has been hard to get the right type checking for those pointers. I tried various alternatives in the arm_neon.h header, but it's much more straightforward to just check directly in Sema. llvm-svn: 144075
* Clean up type flags for overloaded Neon builtins. No functional change.Bob Wilson2011-11-081-23/+21
| | | | | | | | | This patch just adds a simple NeonTypeFlags class to replace the various hardcoded constants that had been used until now. Unfortunately I couldn't figure out a good way to avoid duplicating that class between clang and TableGen, but since it's small and rarely changes, that's not so bad. llvm-svn: 144054
OpenPOWER on IntegriCloud