summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaChecking.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Warn about implicit conversions between values of different, namedDouglas Gregor2011-02-221-0/+11
| | | | | | enumeration types. Fixes <rdar://problem/8559831>. llvm-svn: 126183
* Don't produce "comparison is always (true|false)" warnings when theDouglas Gregor2011-02-191-1/+5
| | | | | | comparison itself is a constant expression. Fixes PR7536. llvm-svn: 126057
* Fix assertion failure on -Warray-bounds for 32-bit builds of Clang.Ted Kremenek2011-02-181-1/+4
| | | | llvm-svn: 125821
* Enhance the array bounds checking to work for several other constructs,Chandler Carruth2011-02-171-10/+14
| | | | | | | | | especially C++ code, and generally expand the test coverage. Logic adapted from a patch by Kaelyn Uhrain <rikka@google.com> and another Googler. llvm-svn: 125775
* Clean up the style of this function to match the conventions in the restChandler Carruth2011-02-171-28/+27
| | | | | | of Clang, and reflows the code a bit to make it easier to read. llvm-svn: 125773
* Implement a sub-group of -Wconversion: -Wliteral-conversion. ThisChandler Carruth2011-02-171-3/+9
| | | | | | | | | | | specifically targets literals which are implicitly converted, a those are more often unintended and trivial to fix. This can be especially helpful for diagnosing what makes 'const int x = 1e6' not an ICE. Original patch authored by Jim Meehan with contributions from other Googlers and a few cleanups from myself. llvm-svn: 125745
* Change the representation of GNU ?: expressions to use a different expressionJohn McCall2011-02-171-2/+10
| | | | | | | | | | | | | | | | | | | | | | class and to bind the shared value using OpaqueValueExpr. This fixes an unnoticed problem with deserialization of these expressions where the deserialized form would lose the vital pointer-equality trait; or rather, it fixes it because this patch also does the right thing for deserializing OVEs. Change OVEs to not be a "temporary object" in the sense that copy elision is permitted. This new representation is not totally unawkward to work with, but I think that's really part and parcel with the semantics we're modelling here. In particular, it's much easier to fix things like the copy elision bug and to make the CFG look right. I've tried to update the analyzer to deal with this in at least some obvious cases, and I think we get a much better CFG out, but the printing of OpaqueValueExprs probably needs some work. llvm-svn: 125744
* Fix assertion failure in -Warray-bounds on template parameters used as arrays.Ted Kremenek2011-02-161-1/+3
| | | | llvm-svn: 125693
* Tweak -Warray-bounds diagnostics based on feedback from Chandler.Ted Kremenek2011-02-161-8/+14
| | | | llvm-svn: 125649
* Add trivial buffer overflow checking in Sema.Ted Kremenek2011-02-161-0/+30
| | | | llvm-svn: 125640
* Give some convenient idiomatic accessors to Stmt::child_range andJohn McCall2011-02-131-2/+1
| | | | | | | Stmt::const_child_range, then make a bunch of places use them instead of the individual iterator accessors. llvm-svn: 125450
* Before checking bitfield initialization, make sure that neither theDouglas Gregor2011-02-041-0/+7
| | | | | | | bit-field width nor the initializer value are type- or value-dependent. Fixes PR8712. llvm-svn: 124866
* An insomniac stab at making block declarations list the variables they closeJohn McCall2011-02-021-1/+1
| | | | | | | on, as well as more reliably limiting invalid references to locals from nested scopes. llvm-svn: 124721
* Add semantic checking that the "thousands grouping"Ted Kremenek2011-01-081-0/+2
| | | | | | | prefix in a printf format string is matched with the appropriate conversion specifier. llvm-svn: 123055
* Don't try to compute the value of a value-dependent expression whenDouglas Gregor2010-12-211-0/+3
| | | | | | checking trivial comparisons. Fixes PR8795. llvm-svn: 122322
* Fix diagnostic pragmas.Argyrios Kyrtzidis2010-12-151-3/+5
| | | | | | | | | | | | Diagnostic pragmas are broken because we don't keep track of the diagnostic state changes and we only check the current/latest state. Problems manifest if a diagnostic is emitted for a source line that has different diagnostic state than the current state; this can affect a lot of places, like C++ inline methods, template instantiations, the lexer, etc. Fix the issue by having the Diagnostic object keep track of the source location of the pragmas so that it is able to know what is the diagnostic state at any given source location. Fixes rdar://8365684. llvm-svn: 121873
* Do not assert on shifts of Neon polynomial types.Bob Wilson2010-12-101-4/+2
| | | | | | | | Most Neon shift intrinsics do not have variants for polynomial types, but vsri_n and vsli_n do support them, and we need to properly range-check the shift immediates for them. llvm-svn: 121509
* PR5207: Change APInt methods trunc(), sext(), zext(), sextOrTrunc() andJay Foad2010-12-071-6/+5
| | | | | | | | zextOrTrunc(), and APSInt methods extend(), extOrTrunc() and new method trunc(), to be const and to return a new value instead of modifying the object in place. llvm-svn: 121121
* Although we currently have explicit lvalue-to-rvalue conversions, they'reJohn McCall2010-12-041-2/+2
| | | | | | | | | | | | | | | | | | | not actually frequently used, because ImpCastExprToType only creates a node if the types differ. So explicitly create an ICE in the lvalue-to-rvalue conversion code in DefaultFunctionArrayLvalueConversion() as well as several other new places, and consistently deal with the consequences throughout the compiler. In addition, introduce a new cast kind for loading an ObjCProperty l-value, and make sure we emit those nodes whenever an ObjCProperty l-value appears that's not on the LHS of an assignment operator. This breaks a couple of rewriter tests, which I've x-failed until future development occurs on the rewriter. Ted Kremenek kindly contributed the analyzer workarounds in this patch. llvm-svn: 120890
* Follow through references to catch returned stack addresses, local blocks, ↵Argyrios Kyrtzidis2010-11-301-50/+127
| | | | | | | | | | | | label addresses or references to temporaries, e.g: const int& g2() { int s1; int &s2 = s1; // expected-note {{binding reference variable 's2' here}} return s2; // expected-warning {{reference to stack memory associated with local variable 's1' returned}} } llvm-svn: 120483
* Revert r120331 since it causes spurious warnings and a possible assertion ↵Argyrios Kyrtzidis2010-11-291-27/+3
| | | | | | hit when self-host. llvm-svn: 120351
* Emit warnings if we are returning a reference to a local temporary.Argyrios Kyrtzidis2010-11-291-3/+27
| | | | | | The issue was brought to our attention by Matthieu Monrocq. llvm-svn: 120331
* Calculate the value kind of an expression when it's created andJohn McCall2010-11-181-2/+3
| | | | | | | | | | | | | store it on the expression node. Also store an "object kind", which distinguishes ordinary "addressed" l-values (like variable references and pointer dereferences) and bitfield, @property, and vector-component l-values. Currently we're not using these for much, but I aim to switch pretty much everything calculating l-valueness over to them. For now they shouldn't necessarily be trusted. llvm-svn: 119685
* a metric ton of refactoring later, Sema::getLocationOfStringLiteralByte Chris Lattner2010-11-171-63/+3
| | | | | | | | no longer depends on Preprocessor, so we can move it out of Sema into a nice new StringLiteral::getLocationOfByte method that can be used by any AST client. llvm-svn: 119481
* propagate preprocessor out of StringLiteralParser. It is nowChris Lattner2010-11-171-2/+2
| | | | | | possible to create one without a preprocessor. llvm-svn: 119476
* push use of Preprocessor out farther.Chris Lattner2010-11-171-5/+2
| | | | llvm-svn: 119471
* push use of Preprocessor out of getOffsetOfStringByte Chris Lattner2010-11-171-1/+3
| | | | llvm-svn: 119470
* refactor the interface to StringLiteralParser::getOffsetOfStringByte,Chris Lattner2010-11-171-1/+1
| | | | | | pushing the dependency on the preprocessor out a bit. llvm-svn: 119468
* Fix PR8625 and correctly interpret member-calls to static members whenChandler Carruth2010-11-161-6/+10
| | | | | | | | | | | | producing warnings. This feels really fragile, and I've not audited all other argument index-based warnings. I suspect we'll grow this bug on another warning eventually. It might be nice to adjust the argument indices when building up the attribute AST node, as we already have to remember about the 'this' argument within that code to produce correct errors. llvm-svn: 119340
* Kill CK_Unknown and flesh out the documentation for the existing CastKinds.John McCall2010-11-161-2/+0
| | | | llvm-svn: 119331
* Assorted work leading towards the elimination of CK_Unknown.John McCall2010-11-151-1/+1
| | | | llvm-svn: 119138
* Undo a refactor-o and base the bitfield-truncation warning on theJohn McCall2010-11-111-1/+5
| | | | | | | uncoerced value. Also, whitelist bool bitfields, which aren't really a truncation. llvm-svn: 118778
* Extend the bitfield-truncation warning to initializations.John McCall2010-11-111-38/+60
| | | | | | rdar://problem/8652606 llvm-svn: 118773
* When -Wconversion computes the range of a type, it uses the (bit-)range John McCall2010-11-101-19/+40
| | | | | | | | | | | of the enumerators rather than the actual expressible range. This is great when dealing with opaque *values* of that type, but when computing the range of the type for purposes of converting *into* it, it produces warnings in cases we don't care about (e.g. enum_t x = 500;). Divide the logic into these two cases and use the more conservative range for targets. llvm-svn: 118735
* Add a variant of GCC-style vector types for ARM NEON.Bob Wilson2010-11-101-1/+1
| | | | | | | | | NEON vector types need to be mangled in a special way to comply with ARM's ABI, similar to some of the AltiVec-specific vector types. This patch is mostly just renaming a bunch of "AltiVecSpecific" things, since they will no longer be specific to AltiVec. Besides that, it just adds the new "NeonVector" enum. llvm-svn: 118724
* Tweak to bitfield-overflow warning: don't warn about storingJohn McCall2010-11-101-1/+8
| | | | | | | a positive value into a signed bitfield of the exact width of the value. llvm-svn: 118657
* Add a warning for implicit truncation of constant values due toJohn McCall2010-11-091-3/+55
| | | | | | | | bitfield assignment. Implements rdar://problem/7809123 llvm-svn: 118647
* Split out -Wconversion warnings about constant precision into theirJohn McCall2010-11-091-0/+26
| | | | | | | | | | | own subcategory, -Wconstant-conversion, which is on by default. Tweak the constant folder to give better results in the invalid case of a negative shift amount. Implements rdar://problem/6792488 llvm-svn: 118636
* Require that the types of the parameters of a block literal are complete.Douglas Gregor2010-11-011-5/+7
| | | | llvm-svn: 117942
* When checking whether a return statement returns a stack-localDouglas Gregor2010-10-211-4/+11
| | | | | | | variable, handle conditional operators involving a throw-expression. Fixes GCC DejaGNU's g++.dg/template/cond4.C. llvm-svn: 117027
* Previously, the printf warnings would say your arguments type was 'int' when ↵Ted Kremenek2010-10-211-2/+5
| | | | | | | | | | it was really a 'char' or a 'short'. This fixes that and allows the hints to suggest 'h' modifiers for small ints. Patch by Justin Bogner! llvm-svn: 116996
* fix PR7885, rejecting invalid uses of __builtin_constant_p.Chris Lattner2010-10-121-0/+10
| | | | llvm-svn: 116317
* Track the location of the context requiring an implicit conversion and use itJohn McCall2010-10-081-29/+46
| | | | | | to white-list conversions required by system headers. rdar://problem/8232669 llvm-svn: 116029
* Fix an infinite loop, caused by unintended syntax bug (the 'break;' after ↵Argyrios Kyrtzidis2010-10-071-7/+3
| | | | | | | | 'default:' was intended to break out of the while loop). Fixes rdar://8518859&8520617. llvm-svn: 115985
* Provide a slightly specialized diagnostic for tautological comparisonsJohn McCall2010-10-061-4/+20
| | | | | | of an enum value. llvm-svn: 115725
* kill off CheckX86BuiltinFunctionCallChris Lattner2010-10-011-9/+0
| | | | llvm-svn: 115382
* move imperative code to declarative definitions.Chris Lattner2010-10-011-22/+0
| | | | llvm-svn: 115381
* diagnose errors when a builtin that require constant arguments don't have them.Chris Lattner2010-10-011-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | For example, on: #include <emmintrin.h> int foo(int N) { __m128i white2; white2 = _mm_slli_si128(white2, N); return 0; } we used to get: fatal error: error in backend: Cannot yet select: intrinsic %llvm.x86.sse2.psll.dq now we get: /Users/sabre/t.c:4:11: error: argument to '__builtin_ia32_pslldqi128' must be a constant integer white2 = _mm_slli_si128(white2, N); ^~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /Users/sabre/t.c:1: /Volumes/Projects/cvs/llvm/Debug+Asserts/lib/clang/2.9/include/emmintrin.h:781:13: note: instantiated from: ((__m128i)__builtin_ia32_pslldqi128((__m128i)(VEC), (IMM)*8)) ^ ~~~~~~~ 1 error generated. llvm-svn: 115374
* When warning about comparing an unsigned int to being >= 0, don't issue a ↵Ted Kremenek2010-09-231-1/+11
| | | | | | | | | warning if the zero value was an enum or was expanded from a macro. Fixes: <rdar://problem/8414119> llvm-svn: 114695
* fix rdar://8445858 - __sync_* intrinsics erroneously reject ObjC pointersChris Lattner2010-09-171-1/+1
| | | | llvm-svn: 114209
OpenPOWER on IntegriCloud