summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaInit.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix the CodeGen half of PR5911 by changing reference initialization toChandler Carruth2010-01-121-8/+12
| | | | | | | correctly look through arrays to see cv-qualifiers. Also enhances the routine for doing this to preserve more type sugaring for diagnostics. llvm-svn: 93252
* So I was sitting around, trying vainly to think of something to commit, and thenJohn McCall2010-01-121-7/+12
| | | | | | | | I said to myself, self, why don't you go add a couple of parameters to a method and then fail to use them, and I thought that sounded like a pretty good idea, so I did it. llvm-svn: 93233
* Introduce a specific representation for the ambiguous implicit conversionJohn McCall2010-01-121-6/+11
| | | | | | | sequence. Lots of small relevant changes. Fixes some serious problems with ambiguous conversions; also possibly improves associated diagnostics. llvm-svn: 93214
* Change the printing of OR_Deleted overload results to print all the candidates,John McCall2010-01-081-7/+8
| | | | | | | | | | | | | | | not just the viable ones. This is reasonable because the most common use of deleted functions is to exclude some implicit conversion during calls; users therefore will want to figure out why some other options were excluded. Started sorting overload results. Right now it just sorts by location in the translation unit (after putting viable functions first), but we can do better than that. Changed bool OnlyViable parameter to PrintOverloadCandidates to an enum for better self-documentation. llvm-svn: 92990
* Whenever we emit a typo-correction diagnostic, also emit a noteDouglas Gregor2010-01-071-0/+3
| | | | | | | pointing to the declaration that we found that has that name (if it is unique). llvm-svn: 92877
* Move the allocation of designators in DesignatedInitExpr to theDouglas Gregor2010-01-061-1/+1
| | | | | | ASTContext. Fixes <rdar://problem/7495428>. llvm-svn: 92867
* Typo correction for C99 designated field initializers, e.g.,Douglas Gregor2010-01-011-15/+53
| | | | | | | | | | test/FixIt/typo.c:19:4: error: field designator 'bunds' does not refer to any field in type 'struct Window'; did you mean 'bounds'? .bunds. ^~~~~ bounds llvm-svn: 92376
* Switch parameter-passing for calls via function pointers (where weDouglas Gregor2009-12-221-1/+5
| | | | | | don't have a FunctionDecl) over to InitializationSequence. llvm-svn: 91906
* Switch InitializedEntity from TypeLoc down to just QualTypes, since we don't ↵Douglas Gregor2009-12-221-73/+36
| | | | | | use the location information but we did spend a bunch of time building faked-up TypeLocs llvm-svn: 91905
* Switch initialization of parameters in a call over toDouglas Gregor2009-12-221-4/+19
| | | | | | | | | | | InitializationSequence (when a FunctionDecl is present). This required a few small fixes to initialization sequences: - Make sure to use the adjusted parameter type for initialization of function parameters. - Implement transparent union calling semantics in C llvm-svn: 91902
* Zap CheckInitializerTypes.Eli Friedman2009-12-221-112/+0
| | | | llvm-svn: 91884
* Switch compound literals over to InitializationSequence.Eli Friedman2009-12-221-1/+1
| | | | llvm-svn: 91882
* Switch file-scope assignment initialization over to InitializationSequence.Eli Friedman2009-12-221-1/+5
| | | | llvm-svn: 91881
* Eliminate the ASTContext argument to CXXConstructorDecl::isCopyConstructor, ↵Douglas Gregor2009-12-221-1/+1
| | | | | | since the context is available in the Decl llvm-svn: 91862
* When filling in value initializations within an initializer list, beDouglas Gregor2009-12-221-65/+86
| | | | | | | sure to fill in the initialized member of a union when a member was explicitly designated. Fixes PR5843. llvm-svn: 91858
* Fix review comment; no visible change.Eli Friedman2009-12-201-28/+29
| | | | llvm-svn: 91797
* Switch default-initialization of variables of class type (or array thereof) ↵Douglas Gregor2009-12-201-1/+2
| | | | | | over to InitializationSequence. I could swear that this fixes a PR somewhere, but I couldn't figure out which one llvm-svn: 91796
* Initialization improvements: addition of string initialization and a fewEli Friedman2009-12-191-11/+32
| | | | | | | | small bug fixes in SemaInit, switch over SemaDecl to use it more often, and change a bunch of diagnostics which are different with the new initialization code. llvm-svn: 91767
* Switch more of Sema::CheckInitializerTypes over toDouglas Gregor2009-12-191-80/+43
| | | | | | | | | | InitializationSequence. Specially, switch initialization of a C++ class type (either copy- or direct-initialization). Also, make sure that we create an elidable copy-construction when performing copy initialization of a C++ class variable. Fixes PR5826. llvm-svn: 91750
* Switch the initialization required by return statements over to theDouglas Gregor2009-12-181-32/+267
| | | | | | | | | | | | | | | | | | | | | | | | | | | | new InitializationSequence. This fixes some bugs (e.g., PR5808), changed some diagnostics, and caused more churn than expected. What's new: - InitializationSequence now has a "C conversion sequence" category and step kind, which falls back to - Changed the diagnostics for returns to always have the result type of the function first and the type of the expression second. CheckSingleAssignmentConstraints to peform checking in C. - Improved ASTs for initialization of return values. The ASTs now capture all of the temporaries we need to create, but intentionally do not bind the tempoary that is actually returned, so that it won't get destroyed twice. - Make sure to perform an (elidable!) copy of the class object that is returned from a class. - Fix copy elision in CodeGen to properly see through the subexpressions that occur with elidable copies. - Give "new" its own entity kind; as with return values and thrown objects, we don't bind the expression so we don't call a destructor for it. Note that, with this patch, I've broken returning move-only types in C++0x. We'll fix it later, when we tackle NRVO. llvm-svn: 91669
* When value-initializing a class with no user-defined constructors butDouglas Gregor2009-12-161-10/+34
| | | | | | | with a non-trivial default constructor, zero-initialize the storage and then call the default constructor. Fixes PR5800. llvm-svn: 91548
* In Sema::CheckInitializerTypes, replace a use of CheckReferenceInit with an ↵Douglas Gregor2009-12-161-5/+11
| | | | | | InitializationSequence llvm-svn: 91542
* Eliminate Sema::CheckValueInitialization; its callers now useDouglas Gregor2009-12-161-93/+120
| | | | | | | | | | | | | | InitializationSequence to perform the actual initialization. Also, introduced the notion of a tree of initialized entities, so that we can know where an initialization began when dealing with nested initializations (as occur when performing list initialization). This will, eventually, be useful for producing better diagnostics when list initialization fails, because we can show the path from the top-level object being initialized down to the actual subobject where initialization failed. llvm-svn: 91516
* Fix semantic diagnostics that embed English works, from Nicola Gigante!Douglas Gregor2009-12-161-7/+7
| | | | llvm-svn: 91503
* Switch the C++ new expression over to InitializationSequence, ratherDouglas Gregor2009-12-161-25/+122
| | | | | | | | | | | | | | | | | | | | | than using its own partial implementation of initialization. Switched CheckInitializerTypes over to InitializedEntity/InitializationKind, to help move us closer to InitializationSequence. Added InitializedEntity::getName() to retrieve the name of the entity, for diagnostics that care about such things. Implemented support for default initialization in InitializationSequence. Clean up the determination of the "source expressions" for an initialization sequence in InitializationSequence::Perform. Taught CXXConstructExpr to store more location information. llvm-svn: 91492
* Implement value initialization in InitializationSequence; untestedDouglas Gregor2009-12-151-10/+56
| | | | | | WIP, yet again. llvm-svn: 91368
* Minor cleanups for constructor initialization in InitializationSequenceDouglas Gregor2009-12-141-2/+2
| | | | llvm-svn: 91325
* Constructor initialization for InitializationSequence. Untested WIP.Douglas Gregor2009-12-141-1/+144
| | | | llvm-svn: 91323
* Implement user-defined conversions in InitializationSequence. WPI thatDouglas Gregor2009-12-141-2/+120
| | | | | | isn't turned on anyway yet, so it cannot be tested. llvm-svn: 91294
* Silence some release build warnings.Chandler Carruth2009-12-131-0/+1
| | | | llvm-svn: 91234
* Un-namespace-qualify llvm_unreachable. It's a macro, so the qualification gaveJeffrey Yasskin2009-12-121-2/+2
| | | | | | no extra safety anyway. llvm-svn: 91207
* Fix a recent regression from the initialization changes.Eli Friedman2009-12-111-9/+12
| | | | llvm-svn: 91097
* Move initialization via initializer list over to InitializationSequences.Douglas Gregor2009-12-101-8/+121
| | | | llvm-svn: 91050
* Reimplement reference initialization (C++ [dcl.init.ref]) using theDouglas Gregor2009-12-091-4/+966
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* remove some extraneous syntax: sourceloc implicitly converts to sourcerange.Chris Lattner2009-12-061-2/+2
| | | | llvm-svn: 90710
* Deduce a ConstantArrayType from a value-dependent initializer listDouglas Gregor2009-11-191-3/+25
| | | | | | | rather than punting to a DependentSizedArrayType, tightening up our type checking for template definitions. Thanks, John! llvm-svn: 89407
* Cope with an amusingly little anomaly with dependent types andDouglas Gregor2009-11-191-1/+22
| | | | | | | | | | | | | | | | | | incomplete array initialization, where we have the following in a template: int a[] = { 1, 2, something-value-dependent }; // ... sizeof(a); The type of "a" appears to be a non-dependent IncompleteArrayType, but treating it as such makes the sizeof(a) fail at template definition time. We now correctly handle this by morphing the IncompleteArrayType into a DependentSizedArrayType with a NULL expression, indicating that its size has no corresponding expression (and, therefore, the type is distinct from others). llvm-svn: 89366
* First part of changes to eliminate problems with cv-qualifiers andDouglas Gregor2009-11-161-1/+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
* Remove the ConstantArrayType subtypes. This information is preserved in theJohn McCall2009-10-161-3/+3
| | | | | | | | | | TypeLoc records for declarations; it should not be necessary to represent it directly in the type system. Please complain if you were using these classes and feel you can't replicate previous functionality using the TypeLoc API. llvm-svn: 84222
* Improve diagnostic location information when checking the initialization of ↵Douglas Gregor2009-09-231-1/+2
| | | | | | a reference llvm-svn: 82666
* Change all the Type::getAsFoo() methods to specializations of Type::getAs().John McCall2009-09-211-5/+5
| | | | | | | | | | | Several of the existing methods were identical to their respective specializations, and so have been removed entirely. Several more 'leaf' optimizations were introduced. The getAsFoo() methods which imposed extra conditions, like getAsObjCInterfacePointerType(), have been left in place. llvm-svn: 82501
* Issue good diagnostics when initialization failes due toFariborz Jahanian2009-09-151-5/+17
| | | | | | ambiguity in type conversion function selection. llvm-svn: 81898
* Improve handling of initialization by constructor, by ensuring thatDouglas Gregor2009-09-091-12/+32
| | | | | | | | such initializations properly convert constructor arguments and fill in default arguments where necessary. This also makes the ownership model more clear. llvm-svn: 81394
* Remove tabs, and whitespace cleanups.Mike Stump2009-09-091-150/+150
| | | | llvm-svn: 81346
* BuildCXXConstructExpr now takes a MultiExprArg.Anders Carlsson2009-09-071-1/+2
| | | | llvm-svn: 81160
* Pass the ConstructLoc to BuildCXXConstructExpr.Anders Carlsson2009-09-051-1/+2
| | | | llvm-svn: 81068
* Add an InOverloadResolution flag to TryCopyInitialization.Anders Carlsson2009-08-271-1/+2
| | | | llvm-svn: 80261
* Remove more default arguments.Anders Carlsson2009-08-271-2/+8
| | | | llvm-svn: 80260
* Remove default argument from TryCopyInitialization.Anders Carlsson2009-08-271-1/+4
| | | | llvm-svn: 80256
* BuildCXXConstructExpr now returns an OwningExprResult.Anders Carlsson2009-08-251-1/+7
| | | | llvm-svn: 79975
OpenPOWER on IntegriCloud