summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaChecking.cpp
Commit message (Collapse)AuthorAgeFilesLines
* 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
* Check format strings when a called function has more than one FormatAttr ↵Ted Kremenek2010-09-091-7/+10
| | | | | | (one for 'scanf' and one for 'printf'). Fixes <rdar://problem/8409437>. llvm-svn: 113472
* It appears that technically a null format string is not warned under ↵Ted Kremenek2010-09-091-0/+7
| | | | | | | | -Wformat-nonliteral, as the function processing the format string can decided whether or not to accept a null format string (e.g., asl_log). Fixes <rdar://problem/8269537>. llvm-svn: 113469
* Avoid redundant recursive calls in SemaCheckStringLiteral by just updating ↵Ted Kremenek2010-09-091-7/+5
| | | | | | | | the expression and trying again. llvm-svn: 113468
* Have Sema check for validity of CGString literalFariborz Jahanian2010-09-071-4/+17
| | | | | | instead of asserting in IRGen. Fixes radar 8390459. llvm-svn: 113253
* Enhance return-stack-address check (in Sema) to handle fields that ↵Ted Kremenek2010-09-021-3/+8
| | | | | | themselves are references. (Fixes PR 7999; fix by Chandler Carruth). llvm-svn: 112792
* Split out a header to hold APIs meant for the Sema implementation from Sema.h.John McCall2010-08-251-0/+1
| | | | | | | Clients of Sema don't need to know (for example) the list of diagnostics we support. llvm-svn: 112093
* GCC didn't care for my attempt at API compatibility, so brute-force everythingJohn McCall2010-08-251-39/+39
| | | | | | to the new constants. llvm-svn: 112047
* More incremental progress towards not including Expr.h in Sema.h.John McCall2010-08-251-2/+2
| | | | llvm-svn: 112044
* Split FunctionScopeInfo and BlockScopeInfo into their own header.John McCall2010-08-251-0/+2
| | | | llvm-svn: 112038
* Remove Sema.h's dependency on DeclCXX.h.John McCall2010-08-251-0/+1
| | | | llvm-svn: 112032
* Fix printf format string checking for '%lc' (which expects a wint_t or ↵Ted Kremenek2010-08-241-0/+3
| | | | | | compatible argument). Fixes PR 7981. llvm-svn: 111978
* OwningExprResult -> ExprResult. This patch brought to you byJohn McCall2010-08-241-5/+5
| | | | | | | M-x query-replace-regexp \(Sema::\|Action::\|Parser::\|\)Owning\(Expr\|Stmt\)Result -> \2Result llvm-svn: 111903
* Generate Attr subclasses with TableGen.Alexis Hunt2010-08-181-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | Now all classes derived from Attr are generated from TableGen. Additionally, Attr* is no longer its own linked list; SmallVectors or Attr* are used. The accompanying LLVM commit contains the updates to TableGen necessary for this. Some other notes about newly-generated attribute classes: - The constructor arguments are a SourceLocation and a Context&, followed by the attributes arguments in the order that they were defined in Attr.td - Every argument in Attr.td has an appropriate accessor named getFoo, and there are sometimes a few extra ones (such as to get the length of a variadic argument). Additionally, specific_attr_iterator has been introduced, which will iterate over an AttrVec, but only over attributes of a certain type. It can be accessed through either Decl::specific_attr_begin/end or the global functions of the same name. llvm-svn: 111455
* Convert all uses of StringLiteral::getStrData() to StringLiteral::getString()Benjamin Kramer2010-08-171-13/+8
| | | | | | and remove getStrData(). Patch by Peter Davies (with some tweaks). llvm-svn: 111229
OpenPOWER on IntegriCloud