summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaInit.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Objective-C. Provide fixit's for objc_bride_relatedFariborz Jahanian2013-12-101-1/+1
| | | | | | | attributed CF to ObjC type conversions. // rdar://15499111 llvm-svn: 196935
* ObjectiveC. Continuing implementation of objc_bridge_relatedFariborz Jahanian2013-12-071-0/+3
| | | | | | | | | attribute in sema and issuing a variety of diagnostics lazily for misuse of this attribute (and what to do) when converting from CF types to ObjectiveC types (and vice versa). // rdar://15499111 llvm-svn: 196629
* Correct hyphenations in comments and assert messagesAlp Toker2013-12-051-2/+2
| | | | | | | This patch tries to avoid unrelated changes other than fixing a few hyphen-related ambiguities in nearby lines. llvm-svn: 196466
* Fix init-captures for generic lambdas.Faisal Vali2013-12-051-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For an init capture, process the initialization expression right away. For lambda init-captures such as the following: const int x = 10; auto L = [i = x+1](int a) { return [j = x+2, &k = x](char b) { }; }; keep in mind that each lambda init-capture has to have: - its initialization expression executed in the context of the enclosing/parent decl-context. - but the variable itself has to be 'injected' into the decl-context of its lambda's call-operator (which has not yet been created). Each init-expression is a full-expression that has to get Sema-analyzed (for capturing etc.) before its lambda's call-operator's decl-context, scope & scopeinfo are pushed on their respective stacks. Thus if any variable is odr-used in the init-capture it will correctly get captured in the enclosing lambda, if one exists. The init-variables above are created later once the lambdascope and call-operators decl-context is pushed onto its respective stack. Since the lambda init-capture's initializer expression occurs in the context of the enclosing function or lambda, therefore we can not wait till a lambda scope has been pushed on before deciding whether the variable needs to be captured. We also need to process all lvalue-to-rvalue conversions and discarded-value conversions, so that we can avoid capturing certain constant variables. For e.g., void test() { const int x = 10; auto L = [&z = x](char a) { <-- don't capture by the current lambda return [y = x](int i) { <-- don't capture by enclosing lambda return y; } }; If x was not const, the second use would require 'L' to capture, and that would be an error. Make sure TranformLambdaExpr is also aware of this. Patch approved by Richard (Thanks!!) http://llvm-reviews.chandlerc.com/D2092 llvm-svn: 196454
* PR18013: Don't assert diagnosing a bad std::initializer_list construction.Richard Smith2013-11-211-7/+25
| | | | llvm-svn: 195384
* Rename an extension warning to ext_...Richard Smith2013-11-191-1/+3
| | | | llvm-svn: 195095
* Rather than duplicating extension diagnostics to allow them to cause aRichard Smith2013-11-121-15/+9
| | | | | | | | | | substitution failure, allow a flag to be set on the Diagnostic object, to mark it as 'causes substitution failure'. Refactor Diagnostic.td and the tablegen to use an enum for SFINAE behavior rather than a bunch of flags. llvm-svn: 194444
* s/DebugPrint/dump/gDouglas Gregor2013-11-081-2/+2
| | | | llvm-svn: 194242
* Gracefully (and correctly) handle init of multiple union membersMatthew Curtis2013-10-031-1/+22
| | | | | | | | | | | | | | | We now emit warnings when doing so and code generation is consistent with GCC. Note that the C99 spec is unclear as to the precise behavior. See also ... Bug: http://llvm.org/bugs/show_bug.cgi?id=16644 and cfe-dev discussion: http://lists.cs.uiuc.edu/pipermail/cfe-dev/2013-September/031918.html llvm-svn: 191890
* PR17295: Do not allow explicit conversion functions to be used in cases whereRichard Smith2013-09-211-0/+35
| | | | | | | | | | an additional conversion (other than a qualification conversion) would be required after the explicit conversion. Conversely, do allow explicit conversion functions to be used when initializing a temporary for a reference binding in direct-list-initialization. llvm-svn: 191150
* 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
OpenPOWER on IntegriCloud