summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaCXXCast.cpp
Commit message (Collapse)AuthorAgeFilesLines
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-231-2/+2
| | | | | | | | LLVM.h imports them into the clang namespace. llvm-svn: 135852
* Remove unused variable.Benjamin Kramer2011-07-081-2/+1
| | | | llvm-svn: 134731
* objc++-arc: more diagnosis of converting a weak-unavailableFariborz Jahanian2011-07-081-8/+1
| | | | | | object to a __weak object type. // rdar://9732636 llvm-svn: 134706
* objc++-arc: diagnose assignment/cast of a weak-unavailableFariborz Jahanian2011-07-071-2/+10
| | | | | | | object to a __weak object/type. // rdar://9732636. One item is yet todo. llvm-svn: 134655
* [ARC] When casting from a pointer to an objective-c object with known ↵Argyrios Kyrtzidis2011-07-011-7/+13
| | | | | | | | | | | | | | ownership, if the cast type has no ownership specified, implicitly "transfer" the ownership of the cast'ed type to the cast type: id x; static_cast<NSString**>(&x); // Casting as (__strong NSString**). This currently only works for C++ named casts, C casts to follow. llvm-svn: 134273
* ^cat^cast^Fariborz Jahanian2011-06-211-2/+2
| | | | llvm-svn: 133529
* Add comment before CheckObjCARCConversion is called onFariborz Jahanian2011-06-211-0/+2
| | | | | | Expr value not getting changed by this call. llvm-svn: 133527
* objc-arc: CodeGen part of unbridged cast of CF types.Fariborz Jahanian2011-06-211-3/+6
| | | | | | // rdar://9474349 llvm-svn: 133525
* Automatic Reference Counting.John McCall2011-06-151-33/+104
| | | | | | | | | | 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
* Remove all references to InitializationSequence::FailedSequence from outside ↵Sebastian Redl2011-06-051-4/+2
| | | | | | SemaInit.cpp. Replace them with the boolean conversion or the new Failed() function. This is a first step towards removing InitializationSequence::SequenceKind. No functionality change. llvm-svn: 132664
* Fix a bug in -Wundefined-reinterpret-cast where we failed to lookChandler Carruth2011-05-241-1/+1
| | | | | | | | | | through sugared types when testing for TagTypes. This was the actual cause of the only false positive in Clang+LLVM. Next evaluation will be over a much larger selection of code including large amounts of open source code. llvm-svn: 131957
* Introduce Type::isSignedIntegerOrEnumerationType() andDouglas Gregor2011-05-201-0/+1
| | | | | | | | | | | | | Type::isUnsignedIntegerOrEnumerationType(), which are like Type::isSignedIntegerType() and Type::isUnsignedIntegerType() but also consider the underlying type of a C++0x scoped enumeration type. Audited all callers to the existing functions, switching those that need to also handle scoped enumeration types (e.g., those that deal with constant values) over to the new functions. Fixes PR9923 / <rdar://problem/9447851>. llvm-svn: 131735
* In Microsoft mode, allow conversion from pointer to integral type no matter ↵Francois Pichet2011-05-111-3/+5
| | | | | | | | | | | what size the integral type is. Necessary to parse MFC code. Example: void f(char *ptr) { char var = (char)ptr; } llvm-svn: 131201
* Add a warning for when reinterpret_cast leads to undefined behavior, patch ↵Argyrios Kyrtzidis2011-05-021-0/+60
| | | | | | by Richard Trieu! llvm-svn: 130703
* Make yet another placeholder type, this one marking that an expression is a ↵John McCall2011-04-261-10/+8
| | | | | | | | | | | bound member function, i.e. something of the form 'x.f' where 'f' is a non-static member function. Diagnose this in the general case. Some of the new diagnostics are probably worse than the old ones, but we now get this right much more universally, and there's certainly room for improvement in the diagnostics. llvm-svn: 130239
* Exhaust the cases.Argyrios Kyrtzidis2011-04-231-1/+2
| | | | llvm-svn: 130043
* Don't allow reinterpret_cast to reference of vector element and property ↵Argyrios Kyrtzidis2011-04-221-3/+12
| | | | | | expression. Thanks goes to Eli Friedman! llvm-svn: 130036
* reinterpret_cast to reference of a bit-field is not allowed.Argyrios Kyrtzidis2011-04-221-0/+7
| | | | | | Fixes rdar://9202628 & http://llvm.org/PR9564. llvm-svn: 130024
* Testing my commit access. A few whitespace changes to Sema/SemaCXXCast.cpp.Richard Trieu2011-04-161-7/+5
| | | | llvm-svn: 129629
* Implement appropriate semantics for C++ casting and conversion whenDouglas Gregor2011-04-151-13/+20
| | | | | | | | | | | | | | | | | | | | | | | | | dealing with address-space- and GC-qualified pointers. Previously, these qualifiers were being treated just like cvr-qualifiers (in some cases) or were completely ignored, leading to uneven behavior. For example, const_cast would allow conversion between pointers to different address spaces. The new semantics are fairly simple: reinterpret_cast can be used to explicitly cast between pointers to different address spaces (including adding/removing addresss spaces), while static_cast/dynamic_cast/const_cast do not tolerate any changes in the address space. C-style casts can add/remove/change address spaces through the reinterpret_cast mechanism. Other non-CVR qualifiers (e.g., Objective-C GC qualifiers) work similarly. As part of this change, I tweaked the "casts away constness" diagnostic to use the term "casts away qualifiers". The term "constness" actually comes from the C++ standard, despite the fact that removing "volatile" also falls under that category. In Clang, we also have restrict, address spaces, ObjC GC attributes, etc., so the more general "qualifiers" is clearer. llvm-svn: 129583
* Remove CK_DynamicToNull.Anders Carlsson2011-04-111-8/+0
| | | | llvm-svn: 129265
* As a first step towards fixing PR9641, add a CK_DynamicToNull cast kind whichAnders Carlsson2011-04-101-0/+8
| | | | | | | | | | | | | | | | | | represents a dynamic cast where we know that the result is always null. For example: struct A { virtual ~A(); }; struct B final : A { }; struct C { }; bool f(B* b) { return dynamic_cast<C*>(b); } llvm-svn: 129256
* Simplify calling CheckPlaceholderExpr, converge on it in a few places,John McCall2011-04-101-19/+17
| | | | | | and move a vector-splat check to follow l-value conversion. llvm-svn: 129254
* Use ExprResult& instead of Expr *& in SemaJohn Wiegley2011-04-081-89/+137
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Basic, untested implementation for an "unknown any" type requested by LLDB.John McCall2011-04-071-0/+1
| | | | | | | | | | | | The idea is that you can create a VarDecl with an unknown type, or a FunctionDecl with an unknown return type, and it will still be valid to access that object as long as you explicitly cast it at every use. I'm still going back and forth about how I want to test this effectively, but I wanted to go ahead and provide a skeletal implementation for the LLDB folks' benefit and because it also improves some diagnostic goodness for placeholder expressions. llvm-svn: 129065
* supported: AltiVec vector initialization with a single literal according to ↵Anton Yartsev2011-03-271-0/+10
| | | | | | PIM section 2.5.1 - after initialization all elements have the value specified by the literal llvm-svn: 128375
* Fixes for some more expressions containing function templateids thatDouglas Gregor2011-03-121-53/+9
| | | | | | should be resolvable, from Faisal Vali! llvm-svn: 127521
* Push nested-name-specifier source location information intoDouglas Gregor2011-02-281-2/+3
| | | | | | | | | | | | | UnresolvedLookupExpr and UnresolvedMemberExpr. Also, improve the computation that checks whether the base of a member expression (either unresolved or dependent-scoped) is implicit. The previous check didn't cover all of the cases we use in our representation, which threw off source-location information for these expressions (which, in turn, caused some breakage in libclang's token annotation). llvm-svn: 126681
* Remove a dead variable.Daniel Dunbar2011-02-201-1/+0
| | | | llvm-svn: 126073
* Handle the resolution of a reference to a function template (whichDouglas Gregor2011-02-191-37/+101
| | | | | | | | includes explicitly-specified template arguments) to a function template specialization in cases where no deduction is performed or deduction fails. Patch by Faisal Vali, fixes PR7505! llvm-svn: 126048
* Implement C++0x [expr.static.cast]p9, which permits explicitly castingDouglas Gregor2011-02-181-10/+15
| | | | | | | | | | a scoped enumeration type to an integral or floating type, properly. There was an over-eager assertion, and it was missing the floating-point case. Fixes PR9107/<rdar://problem/8937402>. llvm-svn: 125825
* Don't crash on hierarchy static_casts which appear in variable initializers.John McCall2011-02-141-11/+29
| | | | | | PR9221. llvm-svn: 125532
* Provide overload diagnostics when explicit casts involving class types fail.John McCall2011-02-141-15/+97
| | | | | | PR8626. llvm-svn: 125506
* Fix a horrible bug in our handling of C-style casting, where a C-styleDouglas Gregor2011-01-271-3/+2
| | | | | | | | | | | derived-to-base cast that also casts away constness (one of the cases for static_cast followed by const_cast) would be treated as a bit-cast rather than a derived-to-base class, causing miscompiles and heartburn. Fixes <rdar://problem/8913298>. llvm-svn: 124340
* Handle C-style casts to rvalue reference types that cast away constness.Douglas Gregor2011-01-261-4/+14
| | | | llvm-svn: 124319
* When performing a glvalue-to-xvalue static_cast that involves aDouglas Gregor2011-01-251-6/+17
| | | | | | | derived-to-base conversion, set the cast kind and base path appropriately. llvm-svn: 124189
* Update const_cast semantics for rvalue references. Add tests forDouglas Gregor2011-01-221-5/+4
| | | | | | reinterpret_cast and const_cast using rvalue references. llvm-svn: 124007
* Teach static_cast and dynamic_cast about rvalue references.Douglas Gregor2011-01-221-13/+13
| | | | llvm-svn: 124006
* Fix warnings found by gcc-4.6, from -Wunused-but-set-variable andJeffrey Yasskin2011-01-181-2/+0
| | | | | | -Wint-to-pointer-cast. llvm-svn: 123719
* Add the location of the right parenthesis of a C++ named castDouglas Gregor2011-01-121-4/+5
| | | | | | | (static_cast, dynamic_cast, reinterpret_cast, or const_cast) to improve source-location information. Fixes PR8960. llvm-svn: 123336
* Change all self assignments X=X to (void)X, so that we can turn on aJeffrey Yasskin2010-12-231-1/+1
| | | | | | | | | new gcc warning that complains on self-assignments and self-initializations. Fix one bug found by the warning, in which one clang::OverloadCandidate constructor failed to initialize its FunctionTemplate member. llvm-svn: 122459
* Although we currently have explicit lvalue-to-rvalue conversions, they'reJohn McCall2010-12-041-0/+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
* Fix another case of giving the wrong value kind to a dependent cast toJohn McCall2010-11-301-1/+4
| | | | | | a non-dependent type. llvm-svn: 120384
* For internal consistency's sake, compute the value kind of a dependent castJohn McCall2010-11-261-0/+3
| | | | | | based on the known properties of the casted-to type. Fixes a crash on spirit. llvm-svn: 120180
* Switch a lot of call-sites over to using the new value-kind calculations.John McCall2010-11-241-5/+5
| | | | llvm-svn: 120084
* Calculate the value kind of an expression when it's created andJohn McCall2010-11-181-22/+33
| | | | | | | | | | | | | 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
* Kill CK_Unknown and flesh out the documentation for the existing CastKinds.John McCall2010-11-161-2/+2
| | | | llvm-svn: 119331
* Assorted work leading towards the elimination of CK_Unknown.John McCall2010-11-151-8/+16
| | | | llvm-svn: 119138
* Introduce a null-to-pointer implicit cast kind.John McCall2010-11-131-1/+3
| | | | llvm-svn: 118966
* Fix warning about unused variable 'Fn' in no-asserts builds. Also reflow thisNick Lewycky2010-11-091-8/+5
| | | | | | block so that it looks more like the rest of the file. No functional change. llvm-svn: 118459
OpenPOWER on IntegriCloud