summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaInit.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* AddInitializerToDecl can't take a FullExprArg. Make it take an ExprArg, and ↵Anders Carlsson2009-08-161-4/+1
| | | | | | create the CXXExprWithTemporaries before setting the initializer on the VarDecl. llvm-svn: 79176
* BuildCXXConstructExpr doesn't need to take an ASTContext.Anders Carlsson2009-08-151-2/+1
| | | | llvm-svn: 79149
* Take 2 on AltiVec-style vector initializers. Nate Begeman2009-08-101-7/+38
| | | | | | | | | | | | Fixes PR4704 problems Addresses Eli's patch feedback re: ugly cast code Updates all postfix operators to remove ParenListExprs. While this is awful, no better solution (say, in the parser) is obvious to me. Better solutions welcome. llvm-svn: 78621
* Revert r78535, it is causing a number of failures to build projects.Daniel Dunbar2009-08-101-38/+7
| | | | | | | | | | | | | | | | | | | | | | | | --- Reverse-merging r78535 into '.': D test/Sema/altivec-init.c U include/clang/Basic/DiagnosticSemaKinds.td U include/clang/AST/Expr.h U include/clang/AST/StmtNodes.def U include/clang/Parse/Parser.h U include/clang/Parse/Action.h U tools/clang-cc/clang-cc.cpp U lib/Frontend/PrintParserCallbacks.cpp U lib/CodeGen/CGExprScalar.cpp U lib/Sema/SemaInit.cpp U lib/Sema/Sema.h U lib/Sema/SemaExpr.cpp U lib/Sema/SemaTemplateInstantiateExpr.cpp U lib/AST/StmtProfile.cpp U lib/AST/Expr.cpp U lib/AST/StmtPrinter.cpp U lib/Parse/ParseExpr.cpp U lib/Parse/ParseExprCXX.cpp llvm-svn: 78551
* AltiVec-style vector initializer syntax, vec4 a = (vec4)(a, b, c, d);Nate Begeman2009-08-091-7/+38
| | | | | | | | In addition to being defined by the AltiVec PIM, this is also the vector initializer syntax used by OpenCL, so that vector literals are compatible with macro arguments. llvm-svn: 78535
* Set and use Elidable in elimination of copy ctors.Fariborz Jahanian2009-08-061-2/+3
| | | | llvm-svn: 78331
* Handle destruction of temporaries used in default argumentFariborz Jahanian2009-08-051-0/+1
| | | | | | construction of constructor calls. llvm-svn: 78222
* Patch to improve ir-gen for constructors with default argumentFariborz Jahanian2009-08-051-2/+2
| | | | | | expressions and a test case. llvm-svn: 78213
* Canonicalize else.Mike Stump2009-08-041-4/+3
| | | | llvm-svn: 78102
* Change uses of:Ted Kremenek2009-07-291-10/+10
| | | | | | | | | | | | | | | | | | | | Type::getAsReferenceType() -> Type::getAs<ReferenceType>() Type::getAsRecordType() -> Type::getAs<RecordType>() Type::getAsPointerType() -> Type::getAs<PointerType>() Type::getAsBlockPointerType() -> Type::getAs<BlockPointerType>() Type::getAsLValueReferenceType() -> Type::getAs<LValueReferenceType>() Type::getAsRValueReferenceType() -> Type::getAs<RValueReferenceType>() Type::getAsMemberPointerType() -> Type::getAs<MemberPointerType>() Type::getAsReferenceType() -> Type::getAs<ReferenceType>() Type::getAsTagType() -> Type::getAs<TagType>() And remove Type::getAsReferenceType(), etc. This change is similar to one I made a couple weeks ago, but that was partly reverted pending some additional design discussion. With Doug's pending smart pointer changes for Types, it seemed natural to take this approach. llvm-svn: 77510
* Per offline discussion with Steve Naroff, add back Type::getAsXXXType() methodsTed Kremenek2009-07-171-10/+10
| | | | | | | | | until Doug Gregor's Type smart pointer code lands (or more discussion occurs). These methods just call the new Type::getAs<XXX> methods, so we still have reduced implementation redundancy. Having explicit getAsXXXType() methods makes it easier to set breakpoints in the debugger. llvm-svn: 76193
* Replaced Type::getAsLValueReferenceType(), Type::getAsRValueReferenceType(), ↵Ted Kremenek2009-07-171-10/+10
| | | | | | Type::getAsMemberPointerType(), Type::getAsTagType(), and Type::getAsRecordType() with their Type::getAs<XXX> equivalents. llvm-svn: 76139
* Extra vector element initializers in OpenCL is an error, not a warning.Nate Begeman2009-07-071-0/+4
| | | | llvm-svn: 74951
* Keep track of the Expr used to describe the size of an array type,Douglas Gregor2009-07-061-2/+3
| | | | | | from Enea Zaffanella! llvm-svn: 74831
* De-ASTContext-ify DeclContext.Argyrios Kyrtzidis2009-06-301-15/+14
| | | | | | | Remove ASTContext parameter from DeclContext's methods. This change cascaded down to other Decl's methods and changes to call sites started "escalating". Timings using pre-tokenized "cocoa.h" showed only a ~1% increase in time run between and after this commit. llvm-svn: 74506
* Improve error recovery in C++: when we hit 'implicit int' cases in C++,Chris Lattner2009-06-261-5/+4
| | | | | | | | | | these are usually because the parser was thoroughly confused. In addition to typing the value being declared as an int and hoping for the best, we mark the value as invalid so we don't get chains of errors when it is used downstream. In C, implicit int actually is valid, so typing the thing as int is good and marking it invalid is bad. :) llvm-svn: 74266
* Allow initializing a vector with a vector in addition to allowing a list Eli Friedman2009-06-131-1/+1
| | | | | | of the elements. Issue reported on cfe-dev by Mattias Holm. llvm-svn: 73292
* Fix for PR4285: allow intializing a const wchar_t array with a wide Eli Friedman2009-05-311-8/+10
| | | | | | string. llvm-svn: 72663
* Remove VarDecl from CXXConstructExpr.Anders Carlsson2009-05-301-2/+2
| | | | llvm-svn: 72633
* Remove VarDecl from CheckInitializerTypes now that CXXConstructExpr doesn't ↵Anders Carlsson2009-05-301-6/+3
| | | | | | need to take a VarDecl anymore. (It still does, but it won't for long) llvm-svn: 72630
* Make sure we don't give the wrong warning, and make sure not to set Eli Friedman2009-05-291-6/+9
| | | | | | | hadError (suppressing future diagnostics) if we didn't print an error. llvm-svn: 72588
* Add an assertion so that we don't accidentally build constant arrays of Eli Friedman2009-05-291-1/+1
| | | | | | VLAs. llvm-svn: 72587
* Revert r72575, which isn't really right, and fix up other code to Eli Friedman2009-05-291-20/+20
| | | | | | handle the construct in question correctly. llvm-svn: 72581
* Avoid dumping during semantic analysis when checking array types whenMike Stump2009-05-291-15/+16
| | | | | | a vla is used. llvm-svn: 72575
OpenPOWER on IntegriCloud