summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaChecking.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Support for C++11 (non-template) alias declarations.Richard Smith2011-04-151-2/+2
| | | | llvm-svn: 129567
* fix a bunch of comment typos found by codespell. Patch byChris Lattner2011-04-151-1/+1
| | | | | | Luis Felipe Strano Moraes! llvm-svn: 129559
* C1X: implement generic selectionsPeter Collingbourne2011-04-151-19/+9
| | | | | | | As an extension, generic selection support has been added for all supported languages. The syntax is the same as for C1X. llvm-svn: 129554
* Enhance the diagnostic for literal float -> int conversions to suggestChandler Carruth2011-04-101-4/+35
| | | | | | | | | | | | rewriting the literal when the value is integral. It is not uncommon to see code written as: const int kBigNumber = 42e5; Without any real awareness that this is no longer an ICE. The note helps automate and ease the process of fixing code that violates the warning. llvm-svn: 129243
* add a __sync_swap builtin to fill out the rest of the __sync builtins. Chris Lattner2011-04-091-1/+4
| | | | | | Patch by Dave Zarzycki! llvm-svn: 129189
* Use ExprResult& instead of Expr *& in SemaJohn Wiegley2011-04-081-17/+21
| | | | | | | | | | | | | | | | | | | | | | | | | This patch authored by Eric Niebler. Many methods on the Sema class (e.g. ConvertPropertyForRValue) take Expr pointers as in/out parameters (Expr *&). This is especially true for the routines that apply implicit conversions to nodes in-place. This design is workable only as long as those conversions cannot fail. If they are allowed to fail, they need a way to report their failures. The typical way of doing this in clang is to use an ExprResult, which has an extra bit to signal a valid/invalid state. Returning ExprResult is de riguour elsewhere in the Sema interface. We suggest changing the Expr *& parameters in the Sema interface to ExprResult &. This increases interface consistency and maintainability. This interface change is important for work supporting MS-style C++ properties. For reasons explained here <http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-February/013180.html>, seemingly trivial operations like rvalue/lvalue conversions that formerly could not fail now can. (The reason is that given the semantics of the feature, getter/setter method lookup cannot happen until the point of use, at which point it may be found that the method does not exist, or it may have the wrong type, or overload resolution may fail, or it may be inaccessible.) llvm-svn: 129143
* Refactor one helper function to merely forward to another so that thereChandler Carruth2011-04-051-7/+6
| | | | | | is a single implementation. No functionality change intended. llvm-svn: 128877
* Apply the nonnull attribute to constructor expressions too.Nick Lewycky2011-03-251-5/+6
| | | | llvm-svn: 128253
* Remove warning for null characters in CFString literals. Clang handles them ↵Ted Kremenek2011-03-151-6/+0
| | | | | | | | just fine, and GCC 4.2 doesn't warn here either. We added this warning back in 2007 when we were comparing against GCC 4.0. llvm-svn: 127704
* Don't warn about null characters in Objective-C format string literals.Ted Kremenek2011-03-151-4/+6
| | | | llvm-svn: 127703
* When we're determining whether to complain about a conversion from oneDouglas Gregor2011-03-121-1/+20
| | | | | | | | enumeration type to another in C, classify enumeration constants as if they had the type of their enclosing enumeration. Fixes <rdar://problem/9116337>. llvm-svn: 127514
* Add support for the OpenCL vec_step operator, by generalising andPeter Collingbourne2011-03-111-1/+1
| | | | | | | extending the existing support for sizeof and alignof. Original patch by Guy Benyei. llvm-svn: 127475
* Profiling showed that 'CheckImplicitConversions' was very slow because of ↵Ted Kremenek2011-03-101-9/+43
| | | | | | | | | | | the call to getSpellingLoc(). On 'aes.c' in the LLVM test suite, this function was consuming 7.4% of -fsyntax-only time. This change fixes this issue by delaying the check that the warning would be issued within a system macro by as long as possible. The main negative of this change is now the logic for this check is done in multiple places in this function instead of just in one place up front. llvm-svn: 127425
* For C++, enhance -Warray-bounds to recursively analyze array subscript ↵Ted Kremenek2011-03-011-15/+38
| | | | | | accesses in ?: expressions. llvm-svn: 126766
* Provide a bit saying that a builtin undergoes custom type-checking, thenJohn McCall2011-02-261-8/+27
| | | | | | | don't let calls to such functions go down the normal type-checking path. Test this out with __builtin_classify_type and __builtin_constant_p. llvm-svn: 126539
* Don't warn about using PredefinedExprs as format string literals. These ↵Ted Kremenek2011-02-241-1/+7
| | | | | | | | never can be a real security issue. Fixes PR 9314. llvm-svn: 126447
* Fix bogus -Warray-bounds warning involving 'array[true]' reported in PR 9296.Ted Kremenek2011-02-231-1/+1
| | | | llvm-svn: 126341
* Update Sema::DiagRuntimeBehavior() to take an optional Stmt* to indicate the ↵Ted Kremenek2011-02-231-3/+3
| | | | | | | | | code the diagnostic is associated with. This Stmt* is unused, but we will use it shortly for pruning diagnostics associated with unreachable code. llvm-svn: 126286
* Change -Warray-bounds logic to use DiagRuntimeBehavior in preparation for ↵Ted Kremenek2011-02-231-7/+11
| | | | | | using basic dataflow to suppress warnings on unreachable array bounds checks. llvm-svn: 126285
* 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
OpenPOWER on IntegriCloud