summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaChecking.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Automatic Reference Counting.John McCall2011-06-151-14/+268
| | | | | | | | | | Language-design credit goes to a lot of people, but I particularly want to single out Blaine Garst and Patrick Beard for their contributions. Compiler implementation credit goes to Argyrios, Doug, Fariborz, and myself, in no particular order. llvm-svn: 133103
* Warn on memset(ptr, 0, sizeof(ptr)). Diagnostic wording by Jordy Rose.Nico Weber2011-06-141-1/+27
| | | | llvm-svn: 132996
* fix rdar://9546171 - -Wshorten-64-to-32 shouldn't warn on vector bitcasts.Chris Lattner2011-06-141-3/+6
| | | | llvm-svn: 132975
* Fix a broken index left over from before this function was converted toChandler Carruth2011-06-131-1/+1
| | | | | | handle memcpy and memmove. Spotted by Nico. llvm-svn: 132902
* Clean up the "non-POD memaccess" stuff some. This adds a properly namedChandler Carruth2011-06-031-16/+10
| | | | | | | | | | | | | | diagnostic group to cover the cases where we have definitively bad behavior: dynamic classes. It also rips out the existing support for POD-based checking. This didn't work well, and triggered too many false positives. I'm looking into a possibly more principled way to warn on the fundamental buggy construct here. POD-ness isn't the critical aspect anyways, so a clean slate is better. This also removes some silliness from the code until the new checks arrive. llvm-svn: 132534
* Add a new warning on NULL pointer constant to integer conversion.Richard Trieu2011-05-291-0/+7
| | | | | | This path was reviewed by Chandler Carruth at http://codereview.appspot.com/4538074/ llvm-svn: 132297
* A few more is(Un)signedIntegerType/is(Un)signedOrEnumerationType cleanups.Douglas Gregor2011-05-211-2/+3
| | | | llvm-svn: 131793
* Extend -Wnon-pod-memset to also encompass memcpy() and memmove(),Douglas Gregor2011-05-031-36/+44
| | | | | | | | checking both the source and the destination operands, renaming the warning group to -Wnon-pod-memaccess and tweaking the diagnostic text in the process. llvm-svn: 130786
* Separate the -Wnon-pod-memset warnings into two separate warnings:Douglas Gregor2011-05-031-10/+20
| | | | | | | - a default-on warning for pointers to dynamic classes (= classes with vtables) - a default-off warning for other non-POD types llvm-svn: 130781
* Only check the use of memset() if we're refering to a C function namedDouglas Gregor2011-05-031-1/+3
| | | | | | 'memset' with external linkage. llvm-svn: 130770
* Relax the non-POD memset warning to use the less restrictive C++11Chandler Carruth2011-04-291-12/+25
| | | | | | | | | | | definition of POD. Specifically, this allows certain non-aggregate types due to their data members being private. The representation of C++11 POD testing is pretty gross. Any suggestions for improvements there are welcome. Especially the name 'isCXX11PODType()' seems truly unfortunate. llvm-svn: 130492
* Convert assertion in memset checking to a runtime check (because real code ↵Ted Kremenek2011-04-281-1/+6
| | | | | | may provide a deviant definition of memset). llvm-svn: 130368
* Heh, funny thing, 'void' isn't a POD type. Nice of us to suggest it toChandler Carruth2011-04-271-1/+1
| | | | | | | | silence this warning. ;] Fixed that obvious bug and added a bit more testing as well. llvm-svn: 130318
* Add a warning (-Wnon-pod-memset) for calls to memset() withChandler Carruth2011-04-271-0/+34
| | | | | | | | | | a destination pointer that points to a non-POD type. This can flag such horrible bugs as overwriting vptrs when a previously POD structure is suddenly given a virtual method, or creating objects that crash on practically any use by zero-ing out a member when its changed from a const char* to a std::string, etc. llvm-svn: 130299
* 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
OpenPOWER on IntegriCloud