summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaCXXCast.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Kill off two more uses of Sema::CheckReferenceInit in favor of the newDouglas Gregor2010-03-251-2/+2
| | | | | | | | initialization code. Exposed a bug where we were not marking an implicit conversion as an lvalue when we were forming a call to a conversion function whose return type is a reference. llvm-svn: 99459
* Switch static_cast from the old reference-initialization code (viaDouglas Gregor2010-03-241-20/+17
| | | | | | | | CheckReferenceInit) over to the new initialization code (InitializationSequence), which is better-tested and doesn't require us to compute the entire conversion sequence twice. llvm-svn: 99452
* Perform access control for the implicit base and member destructor callsJohn McCall2010-03-161-4/+4
| | | | | | required when emitting a destructor definition. llvm-svn: 98609
* Perform overload resolution when static_cast'ing from aDouglas Gregor2010-03-071-4/+34
| | | | | | | pointer-to-member-to-derived to a pointer-to-member-to-base. Fixes PR6072. llvm-svn: 97923
* Eliminate the ASTContext parameter from RecordDecl::getDefinition()Douglas Gregor2010-02-111-1/+1
| | | | | | | and CXXRecordDecl::getDefinition(); it's totally unnecessary. No functionality change. llvm-svn: 95836
* Improve access control diagnostics. Perform access control on member-pointerJohn McCall2010-02-101-6/+8
| | | | | | | conversions. Fix an access-control bug where privileges were not considered at intermediate points along the inheritance path. Prepare for friends. llvm-svn: 95775
* Patch to allow reinterpret_cast on objective-c pointers.Fariborz Jahanian2010-02-031-7/+28
| | | | | | (partial fix for radar 7591784). llvm-svn: 95245
* Implement the lvalue-to-rvalue conversion where needed. TheDouglas Gregor2010-02-031-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | lvalue-to-rvalue conversion adjusts lvalues of qualified, non-class type to rvalue expressions of the unqualified variant of that type. For example, given: const int i; (void)(i + 17); the lvalue-to-rvalue conversion for the subexpression "i" will turn it from an lvalue expression (a DeclRefExpr) with type 'const int' into an rvalue expression with type 'int'. Both C and C++ mandate this conversion, and somehow we've slid through without implementing it. We now have both DefaultFunctionArrayConversion and DefaultFunctionArrayLvalueConversion, and which gets used depends on whether we do the lvalue-to-rvalue conversion or not. Generally, we do the lvalue-to-rvalue conversion, but there are a few notable exceptions: - the left-hand side of a '.' operator - the left-hand side of an assignment - a C++ throw expression - a subscript expression that's subscripting a vector Making this change exposed two issues with blocks: - we were deducing const-qualified return types of non-class type from a block return, which doesn't fit well - we weren't always setting the known return type of a block when it was provided with the ^return-type syntax Fixes the current Clang-on-Clang compile failure and PR6076. llvm-svn: 95167
* Preserve type source information for C++ named casts through templateJohn McCall2010-01-151-3/+16
| | | | | | instantiation. llvm-svn: 93533
* Preserve type source information in explicit cast expressions.John McCall2010-01-151-6/+8
| | | | | | Patch by Enea Zaffanella. llvm-svn: 93522
* Introduce a specific representation for the ambiguous implicit conversionJohn McCall2010-01-121-1/+1
| | | | | | | sequence. Lots of small relevant changes. Fixes some serious problems with ambiguous conversions; also possibly improves associated diagnostics. llvm-svn: 93214
* Fix support for const_cast<>s of array types which actual change theChandler Carruth2009-12-291-2/+3
| | | | | | | | CV-qualifiers. Remove an error expectation from the 'good' set of const-cast test cases. With this patch, the final non-template test case from PR5542 passes. (It's the same as the one already in const-cast.cpp.) llvm-svn: 92257
* Remove some dead variables clang-analyzer found.Benjamin Kramer2009-12-251-2/+0
| | | | llvm-svn: 92162
* Make sure that reinterpret_cast gets a CastKind on all successfulDouglas Gregor2009-12-221-1/+5
| | | | | | | paths. Fixes "cannot compile this unexpected cast lvalue yet" error in llvm/lib/Analysis/IPA/GlobalsModRef.cpp. llvm-svn: 91932
* Fix semantic diagnostics that embed English works, from Nicola Gigante!Douglas Gregor2009-12-161-1/+1
| | | | llvm-svn: 91503
* Patch to allow C-style cast from 'void *' to block pointer type.Fariborz Jahanian2009-12-111-0/+5
| | | | | | (fixes radar 7465023). llvm-svn: 91171
* Reimplement reference initialization (C++ [dcl.init.ref]) using theDouglas Gregor2009-12-091-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | new notion of an "initialization sequence", which encapsulates the computation of the initialization sequence along with diagnostic information and the capability to turn the computed sequence into an expression. At present, I've only switched one CheckReferenceInit callers over to this new mechanism; more will follow. Aside from (hopefully) being much more true to the standard, the diagnostics provided by this reference-initialization code are a bit better than before. Some examples: p5-var.cpp:54:12: error: non-const lvalue reference to type 'struct Derived' cannot bind to a value of unrelated type 'struct Base' Derived &dr2 = b; // expected-error{{non-const lvalue reference to ... ^ ~ p5-var.cpp:55:9: error: binding of reference to type 'struct Base' to a value of type 'struct Base const' drops qualifiers Base &br3 = bc; // expected-error{{drops qualifiers}} ^ ~~ p5-var.cpp:57:15: error: ambiguous conversion from derived class 'struct Diamond' to base class 'struct Base': struct Diamond -> struct Derived -> struct Base struct Diamond -> struct Derived2 -> struct Base Base &br5 = diamond; // expected-error{{ambiguous conversion from ... ^~~~~~~ p5-var.cpp:59:9: error: non-const lvalue reference to type 'long' cannot bind to a value of unrelated type 'int' long &lr = i; // expected-error{{non-const lvalue reference to type ... ^ ~ p5-var.cpp:74:9: error: non-const lvalue reference to type 'struct Base' cannot bind to a temporary of type 'struct Base' Base &br1 = Base(); // expected-error{{non-const lvalue reference to ... ^ ~~~~~~ p5-var.cpp:102:9: error: non-const reference cannot bind to bit-field 'i' int & ir1 = (ib.i); // expected-error{{non-const reference cannot ... ^ ~~~~~~ p5-var.cpp:98:7: note: bit-field is declared here int i : 17; // expected-note{{bit-field is declared here}} ^ llvm-svn: 90992
* More detailed analysis of typecast to an objective-c pointerFariborz Jahanian2009-12-081-8/+14
| | | | | | in objective-c++ mode without being too lenient. llvm-svn: 90895
* Patch to allow cstyle cast of objective-c pointers in objective-c++Fariborz Jahanian2009-12-081-0/+4
| | | | | | mode as they are pervasive. llvm-svn: 90867
* CastsAwayConstness shouldn't care if member pointers point into different ↵Sebastian Redl2009-11-181-1/+25
| | | | | | classes. Fixes PR5545. llvm-svn: 89215
* First part of changes to eliminate problems with cv-qualifiers andDouglas Gregor2009-11-161-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | sugared types. The basic problem is that our qualifier accessors (getQualifiers, getCVRQualifiers, isConstQualified, etc.) only look at the current QualType and not at any qualifiers that come from sugared types, meaning that we won't see these qualifiers through, e.g., typedefs: typedef const int CInt; typedef CInt Self; Self.isConstQualified() currently returns false! Various bugs (e.g., PR5383) have cropped up all over the front end due to such problems. I'm addressing this problem by splitting each qualifier accessor into two versions: - the "local" version only returns qualifiers on this particular QualType instance - the "normal" version that will eventually combine qualifiers from this QualType instance with the qualifiers on the canonical type to produce the full set of qualifiers. This commit adds the local versions and switches a few callers from the "normal" version (e.g., isConstQualified) over to the "local" version (e.g., isLocalConstQualified) when that is the right thing to do, e.g., because we're printing or serializing the qualifiers. Also, switch a bunch of Context.getCanonicalType(T1).getUnqualifiedType() == Context.getCanonicalType(T2).getQualifiedType() expressions over to Context.hasSameUnqualifiedType(T1, T2) llvm-svn: 88969
* Set the cast kind for a few more code paths.Eli Friedman2009-11-161-2/+8
| | | | llvm-svn: 88893
* When performing a static downcast as part of a static_cast, make sureDouglas Gregor2009-11-151-12/+17
| | | | | | | | | | that we're dealing with canonical types like the documentation say (yay, CanQualType). Alas, this is another instance where using getQualifiers() on a non-canonical QualType got us in trouble. Good news: with this fix, Clang can now parse all of its own headers! llvm-svn: 88848
* - Have TryStaticImplicitCast set the cast kind to NoOp when binding a ↵Sebastian Redl2009-11-141-36/+39
| | | | | | | | | reference. CheckReferenceInit already inserts implicit casts to the necessary types. This fixes an assertion in CodeGen for some casts and brings a fix for PR5453 close, if I understand that bug correctly. - Also, perform calculated implicit cast sequences if they're determined to work. This finally diagnoses static_cast to ambiguous or implicit bases and fixes two long-standing fixmes in the test case. For the C-style cast, this requires propagating the access check suppression pretty deep into other functions. - Pass the expressions for TryStaticCast and TryStaticImplicitCast by reference. This should lead to a better AST being emitted for such casts, and also fixes a memory leak, because CheckReferenceInit and PerformImplicitConversion wrap the node passed to them. These wrappers were previously lost. llvm-svn: 88809
* When type-checking a static cast (or the static_cast part of a C-styleDouglas Gregor2009-11-141-0/+13
| | | | | | | | cast) that is converting to a class type, enumerate its constructors as in any other direct initialization. This ensures that we get the proper conversion sequence. llvm-svn: 88751
* Set CK_BaseToDerived in TryStaticDowncast.Anders Carlsson2009-11-121-10/+17
| | | | llvm-svn: 86996
* If we have a C-style cast, functional cast, or a static_cast to aDouglas Gregor2009-11-061-2/+2
| | | | | | | | | | class type, don't perform the array-to-pointer or function-to-pointer conversions, because we may end up binding a reference to a function or array. With this change, FileCheck now passes -fsyntax-only! llvm-svn: 86211
* Fixed two places where we needed to force completion of a typeDouglas Gregor2009-11-051-1/+2
| | | | | | | | | | | | (without complaining if it fails) to get proper semantics: reference binding with a derived-to-base conversion and the enumeration of constructors for user-defined conversions. There are probably more cases to fix, but my prior attempt at statically ensuring that complete-type checking always happens failed. Perhaps I'll try again. With this change, Clang can parse include/llvm/*.h! llvm-svn: 86129
* Add a CK_DerivedToBaseMemberPointer cast kind and use it in Sema (Still no ↵Anders Carlsson2009-10-301-3/+5
| | | | | | codegen). llvm-svn: 85552
* Try to instantiate templates before doing hierarchy checks in static_cast. ↵Sebastian Redl2009-10-221-1/+6
| | | | | | Fixes PR5261. llvm-svn: 84860
* Set the cast kind to CK_NoOp for C-style casts that are really const casts. ↵Anders Carlsson2009-10-191-0/+3
| | | | | | Fixes PR5248. llvm-svn: 84514
* Use CK_BitCast for member function pointer casts. Fixes PR5138.Anders Carlsson2009-10-181-1/+5
| | | | llvm-svn: 84438
* Refactor the code that walks a C++ inheritance hierarchy, searchingDouglas Gregor2009-10-061-6/+7
| | | | | | | | | for bases, members, overridden virtual methods, etc. The operations isDerivedFrom and lookupInBases are now provided by CXXRecordDecl, rather than by Sema, so that CodeGen and other clients can use them directly. llvm-svn: 83396
* Patch to implement static casting which requires one Fariborz Jahanian2009-10-011-1/+2
| | | | | | user-defined type conversion. Fixes PR5040. llvm-svn: 83211
* Cast cleanup.Anders Carlsson2009-09-261-29/+31
| | | | llvm-svn: 82826
* Refactor the representation of qualifiers to bring ExtQualType out of theJohn McCall2009-09-241-9/+10
| | | | | | | | Type hierarchy. Demote 'volatile' to extended-qualifier status. Audit our use of qualifiers and fix a few places that weren't dealing with qualifiers quite right; many more remain. llvm-svn: 82705
* Improve diagnostic location information when checking the initialization of ↵Douglas Gregor2009-09-231-0/+1
| | | | | | a reference llvm-svn: 82666
* Improve handling of vector casts in C++.Anders Carlsson2009-09-161-0/+26
| | | | llvm-svn: 82072
* Handle reinterpret_cast between integral types and pointer types.Anders Carlsson2009-09-151-7/+12
| | | | llvm-svn: 81837
* If a cast expression needs either a conversion function or a constructor to ↵Anders Carlsson2009-09-091-8/+32
| | | | | | be called, generate implicit child expressions that call them. llvm-svn: 81383
* Remove tabs, and whitespace cleanups.Mike Stump2009-09-091-40/+27
| | | | llvm-svn: 81346
* Check that the destination type of a static_cast expression is a complete type.Anders Carlsson2009-09-071-0/+8
| | | | llvm-svn: 81151
* Use the correct cast kinds for bit casts and function to pointer decay. ↵Anders Carlsson2009-09-011-10/+17
| | | | | | Fixes PR4827. llvm-svn: 80720
* Allow explicit ctors for casts.Anders Carlsson2009-08-281-1/+1
| | | | llvm-svn: 80374
* Pass InOverloadResolution all the way down to IsPointerConversion.Anders Carlsson2009-08-281-1/+2
| | | | llvm-svn: 80368
* ir-gen related patch for type conversionFariborz Jahanian2009-08-281-14/+3
| | | | | | with class type conversion methods. WIP. llvm-svn: 80365
* Remove more default arguments.Anders Carlsson2009-08-271-1/+5
| | | | llvm-svn: 80260
* Remove default arguments from TryImplicitConversion and fix a bug found in ↵Anders Carlsson2009-08-271-2/+6
| | | | | | the process. llvm-svn: 80258
* Bye-bye old RequireCompleteType.Anders Carlsson2009-08-261-4/+5
| | | | llvm-svn: 80182
* ir-gen for type convesion of class objects. WIP.Fariborz Jahanian2009-08-261-0/+4
| | | | llvm-svn: 80178
OpenPOWER on IntegriCloud