summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaInit.cpp
Commit message (Collapse)AuthorAgeFilesLines
* 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
* Force a load when creating a reference to a temporary copied from a bitfield.Jordan Rose2013-04-111-9/+90
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For this source: const int &ref = someStruct.bitfield; We used to generate this AST: DeclStmt [...] `-VarDecl [...] ref 'const int &' `-MaterializeTemporaryExpr [...] 'const int' lvalue `-ImplicitCastExpr [...] 'const int' lvalue <NoOp> `-MemberExpr [...] 'int' lvalue bitfield .bitfield [...] `-DeclRefExpr [...] 'struct X' lvalue ParmVar [...] 'someStruct' 'struct X' Notice the lvalue inside the MaterializeTemporaryExpr, which is very confusing (and caused an assertion to fire in the analyzer - PR15694). We now generate this: DeclStmt [...] `-VarDecl [...] ref 'const int &' `-MaterializeTemporaryExpr [...] 'const int' lvalue `-ImplicitCastExpr [...] 'int' <LValueToRValue> `-MemberExpr [...] 'int' lvalue bitfield .bitfield [...] `-DeclRefExpr [...] 'struct X' lvalue ParmVar [...] 'someStruct' 'struct X' Which makes a lot more sense. This allows us to remove code in both CodeGen and AST that hacked around this special case. The commit also makes Clang accept this (legal) C++11 code: int &&ref = std::move(someStruct).bitfield PR15694 / <rdar://problem/13600396> llvm-svn: 179250
* <rdar://problem/13278115> Improve diagnostic when failing to bind an rvalue ↵Douglas Gregor2013-03-261-0/+8
| | | | | | reference to an lvalue of compatible type. llvm-svn: 178095
* <rdar://problem/13395022> Strip references when extracting an ↵Douglas Gregor2013-03-251-2/+2
| | | | | | initializer_list's element type during application of an initialization sequence. llvm-svn: 177944
* Add a clarifying note when a return statement is rejected becauseJohn McCall2013-03-191-6/+22
| | | | | | | | we expect a related result type. rdar://12493140 llvm-svn: 177378
* Bring inheriting constructor implementation up-to-date with current defectRichard Smith2013-03-181-3/+6
| | | | | | | | | reports, and implement implicit definition of inheriting constructors. Remaining missing features: inheriting constructor templates, implicit exception specifications for inheriting constructors, inheriting constructors from dependent bases. llvm-svn: 177320
* Replace TypeLoc llvm::cast support to be well-defined.David Blaikie2013-02-181-3/+3
| | | | | | | | | | | | | | The TypeLoc hierarchy used the llvm::cast machinery to perform undefined behavior by casting pointers/references to TypeLoc objects to derived types and then using the derived copy constructors (or even returning pointers to derived types that actually point to the original TypeLoc object). Some context is in this thread: http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-December/056804.html Though it's spread over a few months which can be hard to read in the mail archive. llvm-svn: 175462
OpenPOWER on IntegriCloud