summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaCXXCast.cpp
Commit message (Collapse)AuthorAgeFilesLines
* 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
* Properly diagnose invalid casts to function references. Patch byDouglas Gregor2010-11-081-9/+87
| | | | | | Faisal Vali, tweaked by me. Fixes PR8230. llvm-svn: 118400
* Emit error when using a bound member function for something other than ↵Argyrios Kyrtzidis2010-11-011-0/+9
| | | | | | | | calling it. Also avoids IRGen crashes due to accepting invalid code. llvm-svn: 117943
* Implement C++0x scoped enumerations, from Daniel Wallin! (and tweaked aDouglas Gregor2010-10-081-0/+9
| | | | | | bit by me). llvm-svn: 116122
* One who seeks knowledge learns something new every day.John McCall2010-08-261-4/+3
| | | | | | | | | One who seeks the Tao unlearns something new every day. Less and less remains until you arrive at non-action. When you arrive at non-action, nothing will be left undone. llvm-svn: 112244
* Split out a header to hold APIs meant for the Sema implementation from Sema.h.John McCall2010-08-251-1/+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-49/+49
| | | | | | to the new constants. llvm-svn: 112047
* OwningExprResult -> ExprResult. This patch brought to you byJohn McCall2010-08-241-3/+3
| | | | | | | M-x query-replace-regexp \(Sema::\|Action::\|Parser::\|\)Owning\(Expr\|Stmt\)Result -> \2Result llvm-svn: 111903
* Abstract out passing around types and kill off ActionBase.John McCall2010-08-241-1/+1
| | | | llvm-svn: 111901
* Kill off ExprArg (now just Expr*) and StmtArg (now just Stmt*).John McCall2010-08-231-2/+1
| | | | llvm-svn: 111863
* Sundry incremental steps towards killing off Action.John McCall2010-08-231-1/+1
| | | | llvm-svn: 111795
* On second thought, don't warn about reinterpret_casts under -Wcast-align.John McCall2010-08-191-2/+0
| | | | llvm-svn: 111497
* Error out if reinterpret_casting between member pointers of two differentCharles Davis2010-08-161-0/+7
| | | | | | sizes. llvm-svn: 111119
* Implement -Wcast-align. The initial design of this diagnostic diverges John McCall2010-08-121-0/+6
| | | | | | | | from GCC's in that we warn on *any* increase in alignment requirements, not just those that are enforced by hardware. Please let us know if this causes major problems for you (which it shouldn't, since it's an optional warning). llvm-svn: 110959
* Move Sema's headers into include/clang/Sema, renaming a few along the way.Douglas Gregor2010-08-121-2/+2
| | | | llvm-svn: 110945
* Allow reference binding of a reference of Objective-C object type toDouglas Gregor2010-08-071-1/+2
| | | | | | | | an lvalue of another, compatible Objective-C object type (e.g., a subclass). Introduce a new initialization sequence step kind to describe this binding, along with a new cast kind. Fixes PR7741. llvm-svn: 110513
* Store inheritance paths after CastExprs instead of inside them.John McCall2010-08-071-27/+27
| | | | | | | | | | | | | | | This takes some trickery since CastExpr has subclasses (and indeed, is abstract). Also, smoosh the CastKind into the bitfield from Expr. Drops two words of storage from Expr in the common case of expressions which don't need inheritance paths. Avoids a separate allocation and another word of overhead in cases needing inheritance paths. Also has the advantage of not leaking memory, since destructors for AST nodes are never run. llvm-svn: 110507
* When dynamic_cast'ing from a type to itself, fill in the cast kindDouglas Gregor2010-07-291-0/+1
| | | | | | with CK_NoOp. Fixes PR7727. llvm-svn: 109757
* Fix namespace polution.Dan Gohman2010-07-261-1/+1
| | | | llvm-svn: 109440
* Fix for PR7694: make sure to pass in a RecordType to CheckBaseClassAccess;Eli Friedman2010-07-231-1/+1
| | | | | | | fixes crashes on both valid and invalid code. The diagnostic here could potentially be improved, but it's good enough as-is. llvm-svn: 109257
* Introduce a new cast kind for an "lvalue bitcast", which handlesDouglas Gregor2010-07-131-2/+5
| | | | | | | | | | | | | | | | reinterpret_casts (possibly indirectly via C-style/functional casts) on values, e.g., int i; reinterpret_cast<short&>(i); The IR generated for this is essentially the same as for *reinterpret_cast<short*>(&i). Fixes PR6437, PR7593, and PR7344. llvm-svn: 108294
OpenPOWER on IntegriCloud