summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaInit.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix source location of the initializer in Fariborz Jahanian2010-07-211-3/+4
| | | | | | | a copy initialization. Back out hack in objc rewriter. fixes radar 8213998. llvm-svn: 109024
* Update ImplicitCastExpr to be able to represent an XValue.Sebastian Redl2010-07-201-22/+68
| | | | llvm-svn: 108807
* Whenever we're creating an expression that is typically an rvalueDouglas Gregor2010-07-131-5/+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
* When forming a function call or message send expression, be sure toDouglas Gregor2010-07-131-1/+1
| | | | | | | | | | | | | | | | | strip cv-qualifiers from the expression's type when the language calls for it: in C, that's all the time, while C++ only does it for non-class types. Centralized the computation of the call expression type in QualType::getCallResultType() and some helper functions in other nodes (FunctionDecl, ObjCMethodDecl, FunctionType), and updated all relevant callers of getResultType() to getCallResultType(). Fixes PR7598 and PR7463, along with a bunch of getResultType() call sites that weren't stripping references off the result type (nothing stripped cv-qualifiers properly before this change). llvm-svn: 108234
* Reinstate the fix for PR7556. A silly use of isTrivial() wasDouglas Gregor2010-07-081-3/+2
| | | | | | suppressing copies of objects with trivial copy constructors. llvm-svn: 107857
* Revert r107828 and r107827, the fix for PR7556, which seems to beDouglas Gregor2010-07-071-2/+3
| | | | | | breaking bootstrap on Linux. llvm-svn: 107837
* Rename CXXZeroInitValueExpr to CXXScalarValueInitExpr, to reflect itsDouglas Gregor2010-07-071-1/+1
| | | | | | newly-narrowed scope. No functionality change. llvm-svn: 107828
* Do not use CXXZeroValueInitExpr for class types. Instead, useDouglas Gregor2010-07-071-2/+1
| | | | | | | | | CXXConstructExpr/CXXTemporaryObjectExpr/CXXNewExpr as appropriate. Fixes PR7556, and provides a slide codegen improvement when copy-initializing a POD class type from a value-initialized temporary. Previously, we weren't eliding the copy. llvm-svn: 107827
* Fix an issue with opencl init list checking.Nate Begeman2010-07-071-2/+7
| | | | llvm-svn: 107824
* Introduce a new routine, LookupConstructors(), and use it for allDouglas Gregor2010-07-021-16/+4
| | | | | | constructor-name lookup. llvm-svn: 107536
* Add a new routine Sema::LookupDestructor and make all destructor-lookup ↵Douglas Gregor2010-07-011-2/+2
| | | | | | calls use that routine llvm-svn: 107444
* Remove unnecessary ASTContext parameter fromDouglas Gregor2010-07-011-1/+1
| | | | | | CXXRecordDecl::getDestructor(); no functionality change. llvm-svn: 107394
* When performing copy initialization via user-defined conversions,Douglas Gregor2010-07-011-13/+3
| | | | | | don't allow two user-defined conversions. Fixes PR6595 (again). llvm-svn: 107379
* Make both old and new versions of reference binding use the new ↵Sebastian Redl2010-06-301-24/+30
| | | | | | classification functions, and updated them for N3092. llvm-svn: 107301
* Fix a comment typo.Sebastian Redl2010-06-301-1/+1
| | | | llvm-svn: 107290
* Don't complain about missing field initializers when the initializerDouglas Gregor2010-06-181-1/+1
| | | | | | list is completely empty, from Lasse Kärkkäinen! Fixes PR7413. llvm-svn: 106320
* Use MaybeCreateCXXExprWithTemporaries for potential destruction ofFariborz Jahanian2010-06-071-0/+7
| | | | | | | created temporary. Use own initialized entity for copied in block variables. llvm-svn: 105533
* PR7245: Make binding a reference to a temporary without a usable copyJeffrey Yasskin2010-06-071-3/+7
| | | | | | constructor into an extension warning into the error that C++98 requires. llvm-svn: 105529
* More refactoring.John McCall2010-06-041-27/+29
| | | | llvm-svn: 105458
* Add a new failure kind, FK_Incomplete, to InitializationSequence, toDouglas Gregor2010-05-201-1/+11
| | | | | | | | | capture failures when we try to initialize an incomplete type. Previously, we would (ab)use FK_ConversionFailed, then occasionally dereference a null pointer when trying to diagnose the failure. Fixes <rdar://problem/7959007>. llvm-svn: 104286
* Substantially alter the design of the Objective C type AST by introducingJohn McCall2010-05-151-1/+1
| | | | | | | | | | | | | | | | | | | | | ObjCObjectType, which is basically just a pair of one of {primitive-id, primitive-Class, user-defined @class} with a list of protocols. An ObjCObjectPointerType is therefore just a pointer which always points to one of these types (possibly sugared). ObjCInterfaceType is now just a kind of ObjCObjectType which happens to not carry any protocols. Alter a rather large number of use sites to use ObjCObjectType instead of ObjCInterfaceType. Store an ObjCInterfaceType as a pointer on the decl rather than hashing them in a FoldingSet. Remove some number of methods that are no longer used, at least after this patch. By simplifying ObjCObjectPointerType, we are now able to easily remove and apply pointers to Objective-C types, which is crucial for a certain kind of ObjC++ metaprogramming common in WebKit. llvm-svn: 103870
* Recognize when the named return value optimization applies in aDouglas Gregor2010-05-151-9/+39
| | | | | | | | | | "return" statement and mark the corresponding CXXConstructExpr as elidable. Teach CodeGen that eliding a temporary is different from eliding an object construction. This is just a baby step toward NRVO. llvm-svn: 103849
* Rework when and how vtables are emitted, by tracking where vtables areDouglas Gregor2010-05-131-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "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
* Merged Elaborated and QualifiedName types.Abramo Bagnara2010-05-111-2/+2
| | | | llvm-svn: 103517
* Reapply the reference-binding patch applied below, along with a fix toDouglas Gregor2010-05-071-3/+5
| | | | | | | | | | | | | | | | ensure that we complete the type when we need to look at constructors during reference binding. When determining whether the two types involved in reference binding are reference-compatible, reference-related, etc., do not complete the type of the reference itself because it is not necessary to determine well-formedness of the program. Complete the type that we are binding to, since that can affect whether we know about a derived-to-base conversion. Re-fixes PR7080. llvm-svn: 103283
* Diagnose deprecated/unavailable functions selected by overload resolution.John McCall2010-05-061-0/+4
| | | | | | Fixes rdar://problem/4232969, or at least the clang parts of it. llvm-svn: 103191
* Complain when we try to initialize an object of Objective-C class typeDouglas Gregor2010-05-031-3/+7
| | | | | | | | (which is ill-formed) with an initializer list. Also, change the fallback from an assertion to a generic error message, which is far friendlier. Fixes <rdar://problem/7730948>. llvm-svn: 102930
* Add an enum to CXXConstructExpr so we can determine if the construction ↵Anders Carlsson2010-05-021-2/+11
| | | | | | expression constructs a non-virtual or virtual base. llvm-svn: 102879
* When explicitly building a temporary object (CXXTemporaryObjectExpr),Douglas Gregor2010-04-271-1/+2
| | | | | | | | | | | keep track of whether we need to zero-initialize storage prior to calling its constructor. Previously, we were only tracking this when implicitly constructing the object (a CXXConstructExpr). Fixes Boost's value-initialization tests, which means that the Boost.Config library now passes all of its tests. llvm-svn: 102461
* Introduce Type::isStructureOrClassType(), which does the obviousDouglas Gregor2010-04-261-1/+1
| | | | | | | | thing. Audit all uses of Type::isStructure(), changing those calls to isStructureOrClassType() as needed (which is alsmost everywhere). Fixes the remaining failure in Boost.Utility/Swap. llvm-svn: 102386
* Ensure that we have completed a type before attempting initializationDouglas Gregor2010-04-261-39/+48
| | | | | | on that type. Fixes several problems in Boost.Interprocess. llvm-svn: 102339
* When copying a temporary object to initialize an entity for which theDouglas Gregor2010-04-251-2/+8
| | | | | | | temporary needs to be bound, bind the copy object. Otherwise, we won't end up calling the destructor for the copy. Fixes Boost.Optional. llvm-svn: 102290
* When we create a temporary of class type that we don't immediatelyDouglas Gregor2010-04-241-5/+46
| | | | | | | bind, check accessibility of the destructor and mark the declaration as referenced. Fixes a bunch of Boost.Regex failures. llvm-svn: 102287
* When we attempt to create a temporary object of class type, be sureDouglas Gregor2010-04-241-1/+5
| | | | | | | | | | that the type we're copying is complete. Boost.Regex now builds, although it's failing its regression tests with our favorite "Sema doesn't consider destructor as used." assertion. llvm-svn: 102271
* When we are performing copy initialization of a class type via itsDouglas Gregor2010-04-241-8/+31
| | | | | | | | | | | copy constructor, suppress user-defined conversions on the argument. Otherwise, we can end up in a recursion loop where the bind the argument of the copy constructor to another copy constructor call, whose argument is then a copy constructor call... Found by Boost.Regex which, alas, still isn't building. llvm-svn: 102269
* Actually produce base paths for CastExprs of kind CK_DerivedToBase.Anders Carlsson2010-04-241-3/+5
| | | | llvm-svn: 102259
* Pass the base specifiers through to CheckDerivedToBaseConversion. No ↵Anders Carlsson2010-04-241-1/+1
| | | | | | functionality change yet. llvm-svn: 102250
* CastExpr should not hold a pointer to the base path. More cleanup.Anders Carlsson2010-04-241-6/+6
| | | | llvm-svn: 102249
* Add an InheritancePath parameter to the ImplicitCastExpr constructor.Anders Carlsson2010-04-231-2/+4
| | | | llvm-svn: 102218
* Whenever we complain about a failed initialization of a function orDouglas Gregor2010-04-221-1/+23
| | | | | | | | | | | | | | | | | method parameter, provide a note pointing at the parameter itself so the user does not have to manually look for the function/method being called and match up parameters to arguments. For example, we now get: t.c:4:5: warning: incompatible pointer types passing 'long *' to parameter of type 'int *' [-pedantic] f(long_ptr); ^~~~~~~~ t.c:1:13: note: passing argument to parameter 'x' here void f(int *x); ^ llvm-svn: 102038
* Switch the initialization of Objective-C message parameters (as occursDouglas Gregor2010-04-211-1/+4
| | | | | | | | | during message sends) over to the new initialization code and away from the C-only CheckSingleAssignmentConstraints. The enables the use of C++ types in method parameters and message arguments, as well as unifying more initialiation code overall. llvm-svn: 102035
* Keep tack of whether a base in an InitializedEntity is an inherited virtual ↵Anders Carlsson2010-04-211-2/+6
| | | | | | base or not. Use this in CheckConstructorAccess. llvm-svn: 102020
* Pass the InitializedEntity to Sema::CheckConstructorAccess and use it to ↵Anders Carlsson2010-04-211-3/+3
| | | | | | report different diagnostics depending on which entity is being initialized. llvm-svn: 102010
* Fix comment to reflect recent code change.John Thompson2010-04-201-1/+1
| | | | llvm-svn: 101960
* reapply john's patch, he broke mainline again by changing the test.Chris Lattner2010-04-201-1/+1
| | | | llvm-svn: 101871
* revert r101863, whcih is causing Sema/altivec-init.c to fail on a tonChris Lattner2010-04-201-1/+1
| | | | | | | | | | of buildbots with: error: 'error' diagnostics expected but not seen: Line 9: too few elements in vector initialization (expected 8 elements, have 2) 1 warning and 1 error generated. llvm-svn: 101864
* Altivec vector literal initializer count mismatch error removed.John Thompson2010-04-201-1/+1
| | | | llvm-svn: 101863
* When checking the copy constructor for the optional copy during aDouglas Gregor2010-04-181-3/+19
| | | | | | | | | reference binding to an rvalue of reference-compatible type, check parameters after the first for complete parameter types and build any required default function arguments. We're effectively simulating the type-checking for a call without building the call itself. llvm-svn: 101705
* In C++98/03, when binding a reference to an rvalue ofDouglas Gregor2010-04-181-13/+73
| | | | | | | | | | | | | | | | | reference-compatible type, the implementation is permitted to make a copy of the rvalue (or many such copies, even). However, even though we don't make that copy, we are required to check for the presence of a suitable copy constructor. With this change, we do. Note that in C++0x we are not allowed to make these copies, so we test both dialects separately. Also note the FIXME in one of the C++03 tests, where we are not instantiating default function arguments for the copy constructor we pick (but do not call). The fix is obvious; eliminating the infinite recursion it causes is not. Will address that next. llvm-svn: 101704
* Do not consider explicit constructors when performing a copy to aDouglas Gregor2010-04-181-1/+2
| | | | | | | | | temporary object. This is blindingly obvious from reading C++ [over.match.ctor]p1, but somehow I'd missed it and it took DR152 to educate me. Adjust one test that was relying on this non-standard behavior. llvm-svn: 101688
OpenPOWER on IntegriCloud