summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaChecking.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* Rip out CK_GetObjCProperty.John McCall2011-11-071-16/+0
| | | | llvm-svn: 143910
* Change the AST representation of operations on Objective-CJohn McCall2011-11-061-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | property references to use a new PseudoObjectExpr expression which pairs a syntactic form of the expression with a set of semantic expressions implementing it. This should significantly reduce the complexity required elsewhere in the compiler to deal with these kinds of expressions (e.g. IR generation's special l-value kind, the static analyzer's Message abstraction), at the lower cost of specifically dealing with the odd AST structure of these expressions. It should also greatly simplify efforts to implement similar language features in the future, most notably Managed C++'s properties and indexed properties. Most of the effort here is in dealing with the various clients of the AST. I've gone ahead and simplified the ObjC rewriter's use of properties; other clients, like IR-gen and the static analyzer, have all the old complexity *and* all the new complexity, at least temporarily. Many thanks to Ted for writing and advising on the necessary changes to the static analyzer. I've xfailed a small diagnostics regression in the static analyzer at Ted's request. llvm-svn: 143867
* Rename Expr::Evaluate to Expr::EvaluateAsRValue to make it clear that it willRichard Smith2011-10-291-3/+3
| | | | | | | | implicitly perform an lvalue-to-rvalue conversion if used on an lvalue expression. Also improve the documentation of Expr::Evaluate* to indicate which of them will accept expressions with side-effects. llvm-svn: 143263
* Fix for PR9751 to change the behavior of -Wformat warnings. If the formatRichard Trieu2011-10-281-117/+218
| | | | | | | | | | | string is part of the function call, then there is no difference. If the format string is not, the warning will point to the call site and a note will point to where the format string is. Fix-it hints for strings are moved to the note if a note is emitted. This will prevent changes to format strings that may be used in multiple places. llvm-svn: 143168
* Restore r142914 and r142915, now with missing file and apparentJohn McCall2011-10-251-1/+2
| | | | | | GCC compiler workaround. llvm-svn: 142931
* Revert r142914 and r142915, due to possibly missing file.NAKAMURA Takumi2011-10-251-2/+1
| | | | | | r142914: "Introduce a placeholder type for "pseudo object"" r142915: "Pull the pseudo-object stuff into its own file." llvm-svn: 142921
* Introduce a placeholder type for "pseudo object"John McCall2011-10-251-1/+2
| | | | | | | | | | | | | | | expressions: expressions which refer to a logical rather than a physical l-value, where the logical object is actually accessed via custom getter/setter code. A subsequent patch will generalize the AST for these so that arbitrary "implementing" sub-expressions can be provided. Right now the only client is ObjC properties, but this should be generalizable to similar language features, e.g. Managed C++'s __property methods. llvm-svn: 142914
* Only emit implicit constant conversion truncation warnings in reachable ↵Ted Kremenek2011-10-221-3/+5
| | | | | | code. Apparently this is what GCC does, and some code depends on this. Fixes <rdar://problem/10321089>. llvm-svn: 142716
* Move static array parameter checks to SemaExpr, per Doug's requestPeter Collingbourne2011-10-191-61/+0
| | | | llvm-svn: 142465
* Suggest %zu for size_t args to printf.Hans Wennborg2011-10-181-1/+1
| | | | | | | | For PR11152. Make PrintSpecifier::fixType() suggest "%zu" for size_t, etc. rather than looking at the underlying type and suggesting "%llu" or other platform-specific length modifiers. Applies to C99 and C++11. llvm-svn: 142342
* Add sema checks for calls to functions taking static array parametersPeter Collingbourne2011-10-161-0/+61
| | | | llvm-svn: 142157
* Add template instantiation support for AtomicExpr.Eli Friedman2011-10-141-22/+15
| | | | llvm-svn: 142012
* Only warn in -Wliteral-conversion if the conversion loses informationMatt Beaumont-Gay2011-10-141-19/+7
| | | | llvm-svn: 141955
* Extend -Wno-sizeof-array-argument to strncpy and friends.Nico Weber2011-10-131-4/+43
| | | | | | This finds 2 bugs in chromium and 1 in hunspell, with 0 false positives. llvm-svn: 141902
* Initial implementation of __atomic_* (everything except __atomic_is_lock_free).Eli Friedman2011-10-111-0/+170
| | | | llvm-svn: 141632
* Constant expression evaluation refactoring:Richard Smith2011-10-101-11/+4
| | | | | | | | | | | - Remodel Expr::EvaluateAsInt to behave like the other EvaluateAs* functions, and add Expr::EvaluateKnownConstInt to capture the current fold-or-assert behaviour. - Factor out evaluation of bitfield bit widths. - Fix a few places which would evaluate an expression twice: once to determine whether it is a constant expression, then again to get the value. llvm-svn: 141561
* Don't analyze comparisons in type- or value-dependentDouglas Gregor2011-10-101-0/+3
| | | | | | subexpressions. Fixes PR10291. llvm-svn: 141552
OpenPOWER on IntegriCloud