summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaInit.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Some comment updates and tweaks for clarity.Richard Smith2013-09-211-21/+28
| | | | llvm-svn: 191147
* Rearrange narrowing checks in initialization to be a different form of stepRichard Smith2013-09-211-35/+40
| | | | | | | | rather than a post-processing action, so we can support inserting these checks at stages other than the end of the initialization. No functionality change intended. llvm-svn: 191146
* Refactor: CheckExplicitInitList is only called to check an entire InitListExpr,Richard Smith2013-09-201-15/+20
| | | | | | | so the Index in/out parameters are pointless (always passed in as 0, always ignored by the caller). llvm-svn: 191103
* Don't build extra init lists.Eli Friedman2013-09-171-1/+1
| | | | | | | | | | AssignConvertType::IncompatibleVectors means the two types are in fact compatible. :) No testcase; I don't think the extra init list has any actual visible effect other than making the resulting AST dump look a bit strange. llvm-svn: 190845
* Fixed bug in call to CXXTemporaryObjectExpr ctor.Enea Zaffanella2013-09-071-1/+1
| | | | llvm-svn: 190249
* Fix missing source location in CXXTemporaryObjectExpr nodes.Enea Zaffanella2013-09-071-7/+15
| | | | | | | | For clarity, renamed (get/set)ParenRange as (get/set)ParenOrBraceRange in CXXConstructExpr nodes. Added testcase. llvm-svn: 190239
* Handle init lists and _Atomic fields.Eli Friedman2013-08-191-1/+5
| | | | | | Fixes PR16931. llvm-svn: 188718
* Refactor all diagnosing of TypoCorrections through a common function, inRichard Smith2013-08-171-15/+8
| | | | | | | preparation for teaching this function how to diagnose a correction that includes importing a module. llvm-svn: 188602
* ObjectiveC ARC: finishing off issuing error whenFariborz Jahanian2013-07-311-3/+9
| | | | | | | retainable pointer is passed to an audited CF function expecting CF type. // rdar://14569171 llvm-svn: 187543
* ObjectiveC ARC: Do not issue bridge cast diagnostic whenFariborz Jahanian2013-07-311-1/+2
| | | | | | | | passing a retainable object arg to a CF audited function expecting a CF object type. Issue a normal type mismatch diagnostic. This is wip // rdar://14569171 llvm-svn: 187532
* ObjectiveC arc: Introduce a new initialization kindFariborz Jahanian2013-07-311-9/+19
| | | | | | | | for parameters passed to CF audited functions to be used for better diagnostics. Current set but unused. // rdar://14569171 llvm-svn: 187508
* Sema: Minor const fixups and control flow tidying.Benjamin Kramer2013-07-241-4/+4
| | | | | | No functionality change. llvm-svn: 187047
* Restore warning to its original text whenFariborz Jahanian2013-07-111-1/+1
| | | | | | | certain familiy of methods have the wrong type. // rdar://14408244 llvm-svn: 186111
* ObjectiveC arc[qoi]: When due to change of certain methods'Fariborz Jahanian2013-07-111-0/+16
| | | | | | | | result type, a diagnostic being issued, issue a 'note' mentioning reason behind the unexpected warning. // rdar://14121570. llvm-svn: 186105
* Use SmallVectorImpl instead of SmallVector for iterators and references to ↵Craig Topper2013-07-041-3/+3
| | | | | | avoid specifying the vector size unnecessarily. llvm-svn: 185610
* PR16502: Fix a dumb bug where we might look past the last initializer in anRichard Smith2013-07-011-0/+2
| | | | | | InitListExpr. llvm-svn: 185304
* Fix nested lifetime extension when a std::initializer_list member isRichard Smith2013-06-271-3/+5
| | | | | | initialized during aggregate initialization of the surrounding structure. llvm-svn: 185117
* A bit of program simplification from r185056Larisse Voufo2013-06-271-2/+1
| | | | llvm-svn: 185058
* Fix a conversion to incomplete type bug -- The error message now ↵Larisse Voufo2013-06-271-3/+9
| | | | | | specifically states that the type is incomplete and points to the forward declaration of the incomplete type. llvm-svn: 185056
* Add a workaround for a libstdc++-4.2 <tr1/hashtable> bug. This header usesRichard Smith2013-06-201-3/+23
| | | | | | | | | | return false; in a function returning a pointer. 'false' was a null pointer constant in C++98 but is not in C++11. Punch a very small hole in the initialization rules in C++11 mode to allow this specific case in system headers. llvm-svn: 184395
* Delete dead code.Eli Friedman2013-06-181-36/+0
| | | | llvm-svn: 184154
* PR16263: Implement current direction of core issue 1376. Binding a reference toRichard Smith2013-06-151-4/+43
| | | | | | | | | | | the result of a cast-to-reference-type lifetime-extends the object to which the reference inside the cast binds. This requires us to look for subobject adjustments on both the inside and the outside of the MaterializeTemporaryExpr when looking for a temporary to lifetime-extend (which we also need for core issue 616, and possibly 1213). llvm-svn: 184024
* When copy-initializing a temporary for a reference binding, don't allow use ofRichard Smith2013-06-131-7/+5
| | | | | | explicit constructors. llvm-svn: 183879
* PR12086, PR15117Richard Smith2013-06-121-112/+97
| | | | | | | | | | | | | | | | | | | Introduce CXXStdInitializerListExpr node, representing the implicit construction of a std::initializer_list<T> object from its underlying array. The AST representation of such an expression goes from an InitListExpr with a flag set, to a CXXStdInitializerListExpr containing a MaterializeTemporaryExpr containing an InitListExpr (possibly wrapped in a CXXBindTemporaryExpr). This more detailed representation has several advantages, the most important of which is that the new MaterializeTemporaryExpr allows us to directly model lifetime extension of the underlying temporary array. Using that, this patch *drastically* simplifies the IR generation of this construct, provides IR generation support for nested global initializer_list objects, fixes several bugs where the destructors for the underlying array would accidentally not get invoked, and provides constant expression evaluation support for std::initializer_list objects. llvm-svn: 183872
* Move detection of reference members binding to temporaries from building ofRichard Smith2013-06-121-1/+27
| | | | | | | CXXCtorInitializers to the point where we perform the questionable lifetime extension. This exposed a selection of false negatives in the warning. llvm-svn: 183869
* Reapply r183721, reverted in r183776, with a fix for a bug in the former (weRichard Smith2013-06-121-5/+13
| | | | | | | | | | | | | | | | | | | | | | | were lacking ExprWithCleanups nodes in some cases where the new approach to lifetime extension needed them). Original commit message: Rework IR emission for lifetime-extended temporaries. Instead of trying to walk into the expression and dig out a single lifetime-extended entity and manually pull its cleanup outside the expression, instead keep a list of the cleanups which we'll need to emit when we get to the end of the full-expression. Also emit those cleanups early, as EH-only cleanups, to cover the case that the full-expression does not terminate normally. This allows IR generation to properly model temporary lifetime when multiple temporaries are extended by the same declaration. We have a pre-existing bug where an exception thrown from a temporary's destructor does not clean up lifetime-extended temporaries created in the same expression and extended to automatic storage duration; that is not fixed by this patch. llvm-svn: 183859
* Tweak r183791 so we don't print a note without a source location.Eli Friedman2013-06-111-2/+2
| | | | llvm-svn: 183803
* Correctly handle designated initializers which modify an array initializedEli Friedman2013-06-111-0/+58
| | | | | | | | | | with a string. This case is sort of tricky because we can't modify the StringLiteral used to represent such initializers. We are forced to decompose the string into individual characters. Fixes <rdar://problem/10465114>. llvm-svn: 183791
* Revert r183721. It caused cleanups to be delayed too long in some cases.Richard Smith2013-06-111-3/+0
| | | | | | Testcase to follow. llvm-svn: 183776
* Rework IR emission for lifetime-extended temporaries. Instead of trying to walkRichard Smith2013-06-111-0/+3
| | | | | | | | | | | | | | | | | into the expression and dig out a single lifetime-extended entity and manually pull its cleanup outside the expression, instead keep a list of the cleanups which we'll need to emit when we get to the end of the full-expression. Also emit those cleanups early, as EH-only cleanups, to cover the case that the full-expression does not terminate normally. This allows IR generation to properly model temporary lifetime when multiple temporaries are extended by the same declaration. We have a pre-existing bug where an exception thrown from a temporary's destructor does not clean up lifetime-extended temporaries created in the same expression and extended to automatic storage duration; that is not fixed by this patch. llvm-svn: 183721
* Recursively lifetime-extend into array temporaries. These can get implicitlyRichard Smith2013-06-081-4/+3
| | | | | | created through binding a reference-to-array to an initializer list. llvm-svn: 183594
* Implement DR1270: braces can be elided in all aggregate initialization, notRichard Smith2013-06-061-22/+8
| | | | | | | just copy-list-initialization in a variable declaration. This effectively reverts r142147. llvm-svn: 183397
* Silence GCC warning.Benjamin Kramer2013-06-051-0/+1
| | | | llvm-svn: 183317
* Model temporary lifetime-extension explicitly in the AST. Use this model toRichard Smith2013-06-051-4/+188
| | | | | | | | | handle temporaries which have been lifetime-extended to static storage duration within constant expressions. This correctly handles nested lifetime extension (through reference members of aggregates in aggregate initializers) but non-constant-expression emission hasn't yet been updated to do the same. llvm-svn: 183283
* Fix handling of braced-init-list as reference initializer within aggregateRichard Smith2013-05-311-5/+6
| | | | | | | initialization. Previously we would incorrectly require an extra set of braces around such initializers. llvm-svn: 182983
* Fix crash-on-invalid if list-initialization works, but we bail out whenRichard Smith2013-05-231-1/+2
| | | | | | building the resulting expression because it invokes a deleted constructor. llvm-svn: 182624
* SemaInit.cpp: give both IsStringInit() functions the same return type.Hans Wennborg2013-05-161-4/+6
| | | | | | This addresses Richard's comment on r181880. llvm-svn: 181995
* Better diagnostics for string initialization.Hans Wennborg2013-05-151-36/+131
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit improves Clang's diagnostics for string initialization. Where it would previously say: /tmp/a.c:3:9: error: array initializer must be an initializer list wchar_t s[] = "Hi"; ^ /tmp/a.c:4:6: error: array initializer must be an initializer list or string literal char t[] = L"Hi"; ^ It will now say /tmp/a.c:3:9: error: initializing wide char array with non-wide string literal wchar_t s[] = "Hi"; ^ /tmp/a.c:4:6: error: initializing char array with wide string literal char t[] = L"Hi"; ^ As a bonus, it also fixes the fact that Clang would previously reject this valid C11 code: char16_t s[] = u"hi"; char32_t t[] = U"hi"; because it would only recognize the built-in types for char16_t and char32_t, which do not exist in C. llvm-svn: 181880
* Add support for __wchar_t in -fms-extensions mode.Hans Wennborg2013-05-101-1/+1
| | | | | | | | | | | | | | | | | MSVC provides __wchar_t. This is the same as the built-in wchar_t type from C++, but it is also available with -fno-wchar and in C. The commit changes ASTContext to have two different types for this: - WCharTy is the built-in type used for wchar_t in C++ and __wchar_t. - WideCharTy is the type of a wide character literal. In C++ this is the same as WCharTy, and in C it is an integer type compatible with the type in <stddef.h>. This fixes PR15815. llvm-svn: 181587
* Grab-bag of bit-field fixes:John McCall2013-05-061-5/+10
| | | | | | | | | | | | | | - References to ObjC bit-field ivars are bit-field lvalues; fixes rdar://13794269, which got me started down this. - Introduce Expr::refersToBitField, switch a couple users to it where semantically important, and comment the difference between this and the existing API. - Discourage Expr::getBitField by making it a bit longer and less general-sounding. - Lock down on const_casts of bit-field gl-values until we hear back from the committee as to whether they're allowed. llvm-svn: 181252
* Fix representation of compound literals for C++ objects with destructors.Jordan Rose2013-05-061-5/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, this compound literal expression (a GNU extension in C++): (AggregateWithDtor){1, 2} resulted in this AST: `-CXXBindTemporaryExpr [...] 'struct Point' (CXXTemporary [...]) `-CompoundLiteralExpr [...] 'struct AggregateWithDtor' `-CXXBindTemporaryExpr [...] 'struct AggregateWithDtor' (CXXTemporary [...]) `-InitListExpr [...] 'struct AggregateWithDtor' |-IntegerLiteral [...] 'int' 1 `-IntegerLiteral [...] 'int' 2 Note the two CXXBindTemporaryExprs. The InitListExpr is really part of the CompoundLiteralExpr, not an object in its own right. By introducing a new entity initialization kind in Sema specifically for compound literals, we avoid the treatment of the inner InitListExpr as a temporary. `-CXXBindTemporaryExpr [...] 'struct Point' (CXXTemporary [...]) `-CompoundLiteralExpr [...] 'struct AggregateWithDtor' `-InitListExpr [...] 'struct AggregateWithDtor' |-IntegerLiteral [...] 'int' 1 `-IntegerLiteral [...] 'int' 2 llvm-svn: 181212
* Fix assert if __extension__ or _Generic is used when initializing a char ↵Richard Smith2013-05-061-4/+11
| | | | | | array from a string literal. llvm-svn: 181174
* Replace 'MultiExprArg()' with 'None'Dmitri Gribenko2013-05-051-7/+7
| | | | llvm-svn: 181166
* Handle parens properly when initializing a char array from a string literal.Richard Smith2013-05-051-3/+14
| | | | llvm-svn: 181159
* Replace ArrayRef<T>() with None, now that we have an implicit ArrayRef ↵Dmitri Gribenko2013-05-051-2/+2
| | | | | | | | constructor from None Patch by Robert Wilhelm. llvm-svn: 181139
* Don't build a call expression referring to a function which we're not allowedRichard Smith2013-05-041-7/+14
| | | | | | | | | to use. This makes very little difference right now (other than suppressing follow-on errors in some cases), but will matter more once we support deduced return types (we don't want expressions with undeduced return types in the AST). llvm-svn: 181107
* ArrayRef'ize InitializationSequence constructor and ↵Dmitri Gribenko2013-05-031-65/+52
| | | | | | | | InitializationSequence::Diagnose() Patch by Robert Wilhelm. llvm-svn: 181022
* C++1y: support simple variable assignments in constexpr functions.Richard Smith2013-04-261-0/+1
| | | | llvm-svn: 180603
* C++1y: Allow aggregates to have default initializers.Richard Smith2013-04-201-10/+49
| | | | | | | | | | | Add a CXXDefaultInitExpr, analogous to CXXDefaultArgExpr, and use it both in CXXCtorInitializers and in InitListExprs to represent a default initializer. There's an additional complication here: because the default initializer can refer to the initialized object via its 'this' pointer, we need to make sure that 'this' points to the right thing within the evaluation. llvm-svn: 179958
* Basic support for Microsoft property declarations andJohn McCall2013-04-161-12/+15
| | | | | | | | references thereto. Patch by Tong Shen! llvm-svn: 179585
OpenPOWER on IntegriCloud