summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaInit.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [C++11] Replacing CXXRecordDecl iterators bases_begin() and bases_end() with ↵Aaron Ballman2014-03-131-4/+2
| | | | | | iterator_range bases(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203803
* [C++11] Add 'override' keyword to virtual methods that override their base ↵Craig Topper2014-03-121-1/+1
| | | | | | class. llvm-svn: 203640
* Reverting llvm::distance changes to use std::distance with iterators ↵Aaron Ballman2014-03-101-1/+1
| | | | | | | | instead, per post-commit review feedback. Replacing llvm::copy changes with SmallVector range-based construction which is a considerably cleaner approach. llvm-svn: 203461
* [C++11] Replacing RecordDecl iterators field_begin() and field_end() with ↵Aaron Ballman2014-03-081-20/+9
| | | | | | iterator_range fields(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203355
* Correctly set brace range for CXXConstructExprs formed by list initialization.Peter Collingbourne2014-02-221-6/+9
| | | | | | Differential Revision: http://llvm-reviews.chandlerc.com/D2711 llvm-svn: 201926
* Rename getResultType() on function and method declarations to getReturnType()Alp Toker2014-01-251-2/+2
| | | | | | | | | | | | | | | A return type is the declared or deduced part of the function type specified in the declaration. A result type is the (potentially adjusted) type of the value of an expression that calls the function. Rule of thumb: * Declarations have return types and parameters. * Expressions have result types and arguments. llvm-svn: 200082
* Removing some more unnecessary manual quotes from diagnostics.Aaron Ballman2014-01-031-1/+1
| | | | llvm-svn: 198420
* Allow Objective-C pointer conversions following an explicit user conversion.Douglas Gregor2013-12-181-4/+8
| | | | | | Finishes the work started in r194224, and fixes <rdar://problem/15494681>. llvm-svn: 197609
* Objective-C. After providing a fix-it for aFariborz Jahanian2013-12-181-5/+8
| | | | | | | | cstring, converted to NSString, produce the matching AST for it. This also required some refactoring of the previous code. // rdar://14106083 llvm-svn: 197605
* ObjectiveC. Further improvements of useFariborz Jahanian2013-12-161-3/+5
| | | | | | | | | | of objc_bridge_related attribute; eliminate unnecessary diagnostics which is issued elsewhere, fixit now produces a valid AST tree per convention. This results in some simplification in handling of this attribute as well. // rdar://15499111 llvm-svn: 197436
* 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
OpenPOWER on IntegriCloud