summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Switch this code to use the more idiomatic 'dyn_cast' pattern.Chandler Carruth2011-08-161-4/+2
| | | | llvm-svn: 137780
* Add fixit notes for -Wconstant-logical-operand.Matt Beaumont-Gay2011-08-151-3/+18
| | | | llvm-svn: 137620
* The current warning in -Wnull-arithmetic for comparisons between NULL and ↵Richard Trieu2011-08-111-3/+4
| | | | | | | | | | | | | | | | | non-pointers is not very helpful. This patch will update the wording to be more helpful to users. Old warning: warning: use of NULL in arithmetic operation [-Wnull-arithmetic] return 10 <= NULL; ^ ~~~~ New warning: warning: comparison between NULL and non-pointer ('int' and NULL) [-Wnull-arithmetic] return 10 <= NULL; ~~ ^ ~~~~ llvm-svn: 137377
* Encapsulate the Objective-C id/Class/SEL "redefinition" types inDouglas Gregor2011-08-111-8/+10
| | | | | | | | | ASTContext with accessors/mutators. The only functional change is that the AST writer won't bother writing the id/Class/SEL redefinition type if it hasn't been explicitly set; previously, it ended up being written as a synonym for the built-in id/Class/SEL. llvm-svn: 137349
* Refactoring of DiagnoseBitwisePrecedence() in SemaExpr.cpp to reduce code ↵Richard Trieu2011-08-101-26/+22
| | | | | | duplication. llvm-svn: 137259
* Change an assert into a check. I'm pretty sure there was a pointJohn McCall2011-08-101-3/+13
| | | | | | | | in time when this assert was valid, but it's not valid now. Also teach this code to correctly introduce function-to-pointer decay. llvm-svn: 137201
* Make sure FunctionDecls aren't considered during overload resolution if thereKaelyn Uhrain2011-08-081-4/+5
| | | | | | are explicit template args. llvm-svn: 137054
* Perform array bounds checking in more situations and properly handle specialKaelyn Uhrain2011-08-051-5/+29
| | | | | | | | | | | | | | | | case situations with the unary operators & and *. Also extend the array bounds checking to work with pointer arithmetic; the pointer arithemtic checking can be turned on using -Warray-bounds-pointer-arithmetic. The changes to where CheckArrayAccess gets called is based on some trial & error and a bunch of digging through source code and gdb backtraces in order to have the check performed under as many situations as possible (such as for variable initializers, arguments to function calls, and within conditional in addition to the simpler cases of the operands to binary and unary operator) while not being called--and triggering warnings--more than once for a given ArraySubscriptExpr. llvm-svn: 136997
* Have the typo correction in DiagnoseEmptyLookup properly handle templateKaelyn Uhrain2011-08-051-5/+9
| | | | | | functions when performing function overload resolution. llvm-svn: 136948
* Fix a small bug where DiagnoseEmptyLookup would no longer print any messagesKaelyn Uhrain2011-08-041-2/+1
| | | | | | | | | when performing typo correction involving any overloaded template functions. The added test cases, while currently demontrating sub-optimal behavior, will not trigger any messages without the 1-line change to SemaExpr.cpp. llvm-svn: 136943
* Improve overloaded function handling in the typo correction code.Kaelyn Uhrain2011-08-031-1/+23
| | | | | | | | Change TypoCorrection to store a set of NamedDecls instead of a single NamedDecl. Also add initial support for performing function overload resolution to Sema::DiagnoseEmptyLookup. llvm-svn: 136807
* Fix formatting of SemaExpr.cpp, mainly fixing lines greater than 80 characters.Richard Trieu2011-08-021-109/+194
| | | | | | No functional change. llvm-svn: 136678
* Introduce a Fix-It for the "missing sentinel" warning, adding anDouglas Gregor2011-07-301-5/+16
| | | | | | | appropriate sentinel at the end of the argument list. Also, put the sentinel warnings under -Wsentinel. Fixes <rdar://problem/8764236>. llvm-svn: 136566
* When complaining about a non-POD second argument to va_arg, use aDouglas Gregor2011-07-301-2/+5
| | | | | | | | special diagnostic for ARC ownership-qualified types. We wouldn't want to expose Objective-C programmers to the term "POD", would we? Fixes <rdar://problem/9772982>. llvm-svn: 136558
* Fix an inconsistency in Sema::ConvertArgumentsForCall in thatPeter Collingbourne2011-07-291-5/+12
| | | | | | | the callee note diagnostic was not emitted in the case where there were too few arguments. llvm-svn: 136437
* Add */& mismatch fixit generation to the Sema::DiagnoseAssignmentResult().Anna Zaks2011-07-281-2/+30
| | | | llvm-svn: 136379
* Add support for C++0x unicode string and character literals, from Craig Topper!Douglas Gregor2011-07-271-7/+32
| | | | llvm-svn: 136210
* Revert r136046 while fixing handling of e.g. &foo[index_one_past_size]Kaelyn Uhrain2011-07-261-17/+0
| | | | llvm-svn: 136113
* Expand array bounds checking to work in the presence of unary & and *,Kaelyn Uhrain2011-07-261-0/+17
| | | | | | | | | and to work with pointer arithmetic in addition to array indexing. The new pointer arithmetic porition of the array bounds checking can be turned on by -Warray-bounds-pointer-arithmetic (and is off by default). llvm-svn: 136046
* Test commitKaelyn Uhrain2011-07-261-1/+0
| | | | llvm-svn: 136044
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-231-13/+13
| | | | | | | | LLVM.h imports them into the clang namespace. llvm-svn: 135852
* This handles the missing cases of opencl vector literals.Tanya Lattner2011-07-151-5/+18
| | | | | | Test cases provided by Anton Lokhmot. llvm-svn: 135322
* Remove warnings of constant operands of logical operators from template ↵Richard Trieu2011-07-151-2/+2
| | | | | | | | | | | | | | instantiations. Upon instantiation of template, value-dependent parameters are replaced by equivalent literals, so code like: template<unsigned int A, unsigned int B> struct S { int foo() { int x = A && B; } } will not warn on A && B on every instantiation. This will still warn on other cases inside templates, which will be caught on checking the template definition. llvm-svn: 135222
* In debugger mode, make ObjC message sends to unknown selectors returnJohn McCall2011-07-131-5/+5
| | | | | | | | | | __unknown_anytype, and rewrite such message sends correctly. I had to bite the bullet and actually add a debugger support mode for this one, which is a bit unfortunate, but there really isn't anything else I could imagine doing; this is clearly just debugger-specific behavior. llvm-svn: 135051
* Fix a bug where a local variable named 'self' is causingFariborz Jahanian2011-07-121-22/+4
| | | | | | | implicit ivar accesses to go through the 'self' variable rather than the real 'self' for the method. // rdar://9730771 llvm-svn: 134992
* Pop block scope after reading from it.Benjamin Kramer2011-07-121-4/+4
| | | | | | Found by valgrind. llvm-svn: 134983
* Fix typo correction crash on overloaded functions, pr10283.Hans Wennborg2011-07-121-2/+1
| | | | | | | It would be cool if we could do overload resolution to suggest the right function, but at least this fixes the crashing. llvm-svn: 134976
* Add diagnostic for constructs like "va_arg(l, float)" which have undefined ↵Eli Friedman2011-07-111-0/+17
| | | | | | behavior. PR10201. llvm-svn: 134926
* objc-arc: Diagnose when captured variable in block literalsFariborz Jahanian2011-07-111-0/+9
| | | | | | | | require destruction and there is possibility of that without construction. Thanks Johnm for review and suggestions offline. // rdar://9535237. llvm-svn: 134906
* objc++-arc: more diagnosis of converting a weak-unavailableFariborz Jahanian2011-07-081-1/+1
| | | | | | object to a __weak object type. // rdar://9732636 llvm-svn: 134706
* objc++-arc: diagnose assignment/cast of a weak-unavailableFariborz Jahanian2011-07-071-21/+11
| | | | | | | object to a __weak object/type. // rdar://9732636. One item is yet todo. llvm-svn: 134655
* objc-arc: diagnose assignment/cast of a weak-unavailableFariborz Jahanian2011-07-071-1/+32
| | | | | | | object to a __weak object/type. // rdar://9732636. This is objc side of things. objc++ side tbd. llvm-svn: 134624
* [ARC] When casting from a pointer to an objective-c object with known ↵Argyrios Kyrtzidis2011-07-011-6/+14
| | | | | | | | | | | | ownership, if the cast type has no ownership specified, implicitly "transfer" the ownership of the cast'ed type to the cast type: id x; (NSString**)&x; // Casting as (__strong NSString**). llvm-svn: 134275
* -Remove Sema::ActOnCastOfParenListExpr and move most of its functionality toArgyrios Kyrtzidis2011-07-011-79/+95
| | | | | | | | | newly introduced Sema::BuildVectorLiteral. -Make Sema::ActOnCastExpr handle a vector initializer both when the cast'ed expression is a ParenListExpr and when it is a ParenExpr. -Ultimately make Sema::ActOnParenOrParenListExpr independent of what the cast type was. llvm-svn: 134274
* Add support for C++ namespace-aware typo correction, e.g., correctingDouglas Gregor2011-06-281-18/+23
| | | | | | | | | | | | | | | vector<int> to std::vector<int> Patch by Kaelyn Uhrain, with minor tweaks + PCH support from me. Fixes PR5776/<rdar://problem/8652971>. Thanks Kaelyn! llvm-svn: 134007
* Cleanup a fixme by using a specific diagnostic for subscriptingChandler Carruth2011-06-271-3/+2
| | | | | | a pointer to void. llvm-svn: 133912
* Factor out (some of) the checking for invalid forms of pointerChandler Carruth2011-06-271-126/+151
| | | | | | | | | | | | | | | | | | | arithmetic into a couple of common routines. Use these to make the messages more consistent in the various contexts, especially in terms of consistently diagnosing binary operators with invalid types on both the left- and right-hand side. Also, improve the grammar and wording of the messages some, handling both two pointers and two (different) types. The wording of function pointer arithmetic diagnostics still strikes me as poorly phrased, and I worry this makes them slightly more awkward if more consistent. I'm hoping to fix that with a follow-on patch and test case that will also make them more helpful when a typedef or template type parameter makes the type completely opaque. Suggestions on better wording are very welcome, thanks to Richard Smith for some initial help on that front. llvm-svn: 133906
* objc-arc: Check on a variety of unsafe assignment of retained Fariborz Jahanian2011-06-241-2/+2
| | | | | | objects. // rdar://9495837 llvm-svn: 133806
* Rename objc_lifetime -> objc_ownership, and modify diagnostics to talk about ↵Argyrios Kyrtzidis2011-06-241-2/+2
| | | | | | | | 'ownership', not 'lifetime'. rdar://9477613. llvm-svn: 133779
* Fix Sema::CheckVectorOperands so that it doesn't try to insert a cast ↵Eli Friedman2011-06-231-36/+29
| | | | | | | | expression into the LHS of a compound assignment. Fixes compound assignment of various "compatible" vector types, including NEON-vector and gcc-vector types. <rdar://problem/9640356> llvm-svn: 133737
* Move all of Sema's member-access-related checking out of SemaExpr.cppDouglas Gregor2011-06-231-1587/+11
| | | | | | | | | and into a new file, SemaExprMember.cpp, bringing SemaExpr.cpp just under 10,000 lines of code (ugh). No functionality change, although I intend to do some refactoring of this code to address PR8368 at some point in the "near" future. llvm-svn: 133674
* Check for placeholders early on inDouglas Gregor2011-06-221-4/+6
| | | | | | | Sema::CreateUnaryExprOrTypeTraitExpr() rather than recursing in some cases. Fixes <rdar://problem/9659191>. llvm-svn: 133663
* Changes ParenListExpr to always require a type.Manuel Klimek2011-06-221-1/+2
| | | | | | | Removes dead code found in the process. Adds a test to verify that ParenListExprs do not have NULL types. llvm-svn: 133637
* Fix the starting location of the Fix-It note for suspicious precedenceDouglas Gregor2011-06-221-1/+2
| | | | | | | issues between a bitwise operator and a comparison operator. Fixes <rdar://problem/9637759>. llvm-svn: 133630
* Revert r133526 which re-orders the suggestions for -Wparentheses on ?:Chandler Carruth2011-06-211-4/+4
| | | | | | | operators. There is a consistent design of having the "silence the warning" option first. llvm-svn: 133570
* Switch the order of the notes for the parentheses suggested in the caseChandler Carruth2011-06-211-4/+4
| | | | | | | | of: a + b ? x : y. In our testing of this flag we've yet to hit a single case where the existing precedence was correct, so we should suggest grouping the ?: first. llvm-svn: 133526
* Make more use of llvm::StringRef in various APIs. In particular, don'tJay Foad2011-06-211-1/+0
| | | | | | use the deprecated forms of llvm::StringMap::GetOrCreateValue(). llvm-svn: 133515
* Warn for un-parenthesized '&' inside '|' (a & b | c), rdar://9553326.Argyrios Kyrtzidis2011-06-201-1/+30
| | | | | | Patch by Henry Mason with tweaks by me. llvm-svn: 133453
* Fix a problem with the diagnostics of invalid arithmetic with functionChandler Carruth2011-06-201-2/+2
| | | | | | | | pointers I found while working on the NULL arithmetic warning. We here always assuming the LHS was the pointer, instead of using the selected pointer expression. llvm-svn: 133428
* Move away from the poor "abstraction" I added to Type. John arguedChandler Carruth2011-06-201-24/+32
| | | | | | | | | | | | | | effectively that this abstraction simply doesn't exist. That is highlighted by the fact that by using it we were papering over a more serious error in this warning: the fact that we warned for *invalid* constructs involving member pointers and block pointers. I've fixed the obvious issues with the warning here, but this is confirming an original suspicion that this warning's implementation is flawed. I'm looking into how we can implement this more reasonably. WIP on that front. llvm-svn: 133425
OpenPOWER on IntegriCloud