summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaCXXCast.cpp
Commit message (Collapse)AuthorAgeFilesLines
* 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
* Whenever we're creating an expression that is typically an rvalueDouglas Gregor2010-07-131-4/+7
| | | | | | | | | | | | | | | | (e.g., a call, cast, etc.), immediately adjust the expression's type to strip cv-qualifiers off of all non-class types (in C++) or all types (in C). This effectively extends my previous fix for PR7463, which was restricted to calls, to other kinds of expressions within similar characteristics. I've audited every use of getNonReferenceType() in the code base, switching to the newly-renamed getNonLValueExprType() where necessary. Big thanks to Eli for pointing out just how incomplete my original fix for PR7463 actually was. We've been handling cv-qualifiers on rvalues wrong for a very, very long time. Fixes PR7463. llvm-svn: 108253
* Allow C-style casts and reinterpret_casts between block pointers andDouglas Gregor2010-07-081-7/+29
| | | | | | either integer values or other pointers. Fixes <rdar://problem/8134521>. llvm-svn: 107905
* Give Type::isIntegralType() an ASTContext parameter, so that itDouglas Gregor2010-06-161-8/+5
| | | | | | | | | | | | provides C "integer type" semantics in C and C++ "integral type" semantics in C++. Note that I still need to update isIntegerType (and possibly other predicates) using the same approach I've taken for isIntegralType(). The two should have the same meaning, but currently don't (!). llvm-svn: 106074
* Introduce Type::isIntegralOrEnumerationType(), to cover those placesDouglas Gregor2010-06-161-1/+1
| | | | | | | | | | in C++ that involve both integral and enumeration types. Convert all of the callers to Type::isIntegralType() that are meant to work with both integral and enumeration types over to Type::isIntegralOrEnumerationType(), to prepare to eliminate enumeration types as integral types. llvm-svn: 106071
* Tweak our handling of the notion of a standard conversion sequenceDouglas Gregor2010-06-091-1/+1
| | | | | | | | | | | | | being a subsequence of another standard conversion sequence. Instead of requiring exact type equality for the second conversion step, require type *similarity*, which is type equality with cv-qualifiers removed at all levels. This appears to match the behavior of EDG and VC++ (albeit not GCC), and feels more intuitive. Big thanks to John for the line of reasoning that supports this change: since cv-qualifiers are orthogonal to the second conversion step, we should ignore them in the type comparison. llvm-svn: 105678
* When deciding whether reinterpret_cast casts away constness we need to look ↵Anders Carlsson2010-06-041-2/+7
| | | | | | at array qualifiers. Fixes rdar://problem/8018292. llvm-svn: 105494
* Use CanQualType to enforce the use of a canonical type argument toDouglas Gregor2010-05-211-1/+1
| | | | | | | CXXBasePaths::isAmbiguous(), rather than just asserting that we have a canonical type. Fixes PR7176. llvm-svn: 104374
* Permit Objective C object pointers to be const_casted.John McCall2010-05-181-1/+3
| | | | llvm-svn: 104019
* Rework when and how vtables are emitted, by tracking where vtables areDouglas Gregor2010-05-131-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "used" (e.g., we will refer to the vtable in the generated code) and when they are defined (i.e., because we've seen the key function definition). Previously, we were effectively tracking "potential definitions" rather than uses, so we were a bit too eager about emitting vtables for classes without key functions. The new scheme: - For every use of a vtable, Sema calls MarkVTableUsed() to indicate the use. For example, this occurs when calling a virtual member function of the class, defining a constructor of that class type, dynamic_cast'ing from that type to a derived class, casting to/through a virtual base class, etc. - For every definition of a vtable, Sema calls MarkVTableUsed() to indicate the definition. This happens at the end of the translation unit for classes whose key function has been defined (so we can delay computation of the key function; see PR6564), and will also occur with explicit template instantiation definitions. - For every vtable defined/used, we mark all of the virtual member functions of that vtable as defined/used, unless we know that the key function is in another translation unit. This instantiates virtual member functions when needed. - At the end of the translation unit, Sema tells CodeGen (via the ASTConsumer) which vtables must be defined (CodeGen will define them) and which may be used (for which CodeGen will define the vtables lazily). From a language perspective, both the old and the new schemes are permissible: we're allowed to instantiate virtual member functions whenever we want per the standard. However, all other C++ compilers were more lazy than we were, and our eagerness was both a performance issue (we instantiated too much) and a portability problem (we broke Boost test cases, which now pass). Notes: (1) There's a ton of churn in the tests, because the order in which vtables get emitted to IR has changed. I've tried to isolate some of the larger tests from these issues. (2) Some diagnostics related to implicitly-instantiated/implicitly-defined virtual member functions have moved to the point of first use/definition. It's better this way. (3) I could use a review of the places where we MarkVTableUsed, to see if I missed any place where the language effectively requires a vtable. Fixes PR7114 and PR6564. llvm-svn: 103718
* Objective-C++ Sema - Allow static_cast of one objc pointer toFariborz Jahanian2010-05-121-1/+5
| | | | | | another. llvm-svn: 103630
* Allow static_cast to objective-c pointers.Fariborz Jahanian2010-05-101-2/+3
| | | | | | Fixes radar 7952457. llvm-svn: 103447
* Add base paths for CK_BaseToDerived and CK_BaseToDerivedMemberPointer.Anders Carlsson2010-04-241-14/+22
| | | | llvm-svn: 102261
* Add base paths to CK_UncheckedDerivedToBase and CK_DerivedToBaseMemberPointer.Anders Carlsson2010-04-241-8/+12
| | | | llvm-svn: 102260
* Actually produce base paths for CastExprs of kind CK_DerivedToBase.Anders Carlsson2010-04-241-21/+29
| | | | llvm-svn: 102259
* Add BasePath arguments to all cast expr constructors.Anders Carlsson2010-04-241-3/+11
| | | | llvm-svn: 102258
* Collapse the three separate initialization paths inDouglas Gregor2010-04-161-83/+29
| | | | | | | | | | | | | | | | | | TryStaticImplicitCast (for references, class types, and everything else, respectively) into a single invocation of InitializationSequence. One of the paths (for class types) was the only client of Sema::TryInitializationByConstructor, which I have eliminated. This also simplified the interface for much of the cast-checking logic, eliminating yet more code. I've kept the representation of C++ functional casts with <> 1 arguments the same, despite the fact that I hate it. That fix will come soon. To satisfy my paranoia, I've bootstrapped + tested Clang with these changes. llvm-svn: 101549
* Switch the checking of implicit casts for static_cast, C-style, andDouglas Gregor2010-04-161-17/+15
| | | | | | | | | | functional casts over to InitializationSequence, eliminating a caller of Sema::TryImplicitConversion. We also get access and ambiguity checking "for free". More cleanups to come in this routine. llvm-svn: 101526
* Kill ForceRValue once and for allDouglas Gregor2010-04-161-1/+0
| | | | llvm-svn: 101502
* Always diagnose and complain about problems inDouglas Gregor2010-04-141-8/+10
| | | | | | | | | | ResolveAddressOfOverloadedFunction when asked to complain. Previously, we had some weird handshake where ResolveAddressOfOverloadedFunction expected its caller to handle some of the diagnostics but not others, and yet there was no way for the caller to know which case we were in. Eliminate this madness, fixing <rdar://problem/7765884>. llvm-svn: 101312
* Propagate the "found declaration" (i.e. the using declaration instead ofJohn McCall2010-03-301-3/+6
| | | | | | | | | | | | | the underlying/instantiated decl) through a lot of API, including "intermediate" MemberExprs required for (e.g.) template instantiation. This is necessary because of the access semantics of member accesses to using declarations: only the base class *containing the using decl* need be accessible from the naming class. This allows us to complete an access-controlled selfhost, if there are no recent regressions. llvm-svn: 99936
* Optimize PartialDiagnostic's memory-allocation behavior by placing aDouglas Gregor2010-03-291-4/+4
| | | | | | | | | | | | | | cache of PartialDiagnostic::Storage objects into an allocator within the ASTContext. This eliminates a significant amount of malloc traffic, for a 10% performance improvement in -fsyntax-only wall-clock time with 403.gcc's combine.c. Also, eliminate the RequireNonAbstractType hack I put in earlier, which was but a symptom of this larger problem. Fixes <rdar://problem/7806091>. llvm-svn: 99849
OpenPOWER on IntegriCloud