summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaInit.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* PR12670: Support for initializing an array of non-aggregate class type from anRichard Smith2012-07-071-41/+34
| | | | | | | initializer list. Patch by Olivier Goffart, with extra testcases by Meador Inge and Daniel Lunow. llvm-svn: 159896
* PR13273: When performing list-initialization with an empty initializer list,Richard Smith2012-07-051-109/+102
| | | | | | | | | | | actually perform value initialization rather than trying to fake it with a call to the default constructor. Fixes various bugs related to the previously-missing zero-initialization in this case. I've also moved this and the other list initialization 'special case' from TryConstructorInitialization into TryListInitialization where they belong. llvm-svn: 159733
* Still more Doxygen documentation fixes:James Dennett2012-06-141-1/+1
| | | | | | | | * Escape #, < and @ symbols where Doxygen would try to interpret them; * Fix several function param documentation where names had got out of sync; * Delete param documentation referring to parameters that no longer exist. llvm-svn: 158472
* Revert Decl's iterators back to pointer value_type rather than reference ↵David Blaikie2012-06-061-22/+22
| | | | | | | | | | | | | | value_type In addition, I've made the pointer and reference typedef 'void' rather than T* just so they can't get misused. I would've omitted them entirely but std::distance likes them to be there even if it doesn't use them. This rolls back r155808 and r155869. Review by Doug Gregor incorporating feedback from Chandler Carruth. llvm-svn: 158104
* Add a warning for when an array-to-pointer decay is performed on an arrayRichard Smith2012-06-041-0/+49
| | | | | | | | | | | | | | | temporary or an array subobject of a class temporary, and the resulting value is used to initialize a pointer which outlives the temporary. Such a pointer is always left dangling after the initialization completes and the array's lifetime ends. In order to detect this situation, this change also adds an LValueClassification of LV_ArrayTemporary for temporaries of array type which aren't subobjects of class temporaries. These occur in C++11 T{...} and GNU C++ (T){...} expressions, when T is an array type. Previously we treated the former as a generic prvalue and the latter as a class temporary. llvm-svn: 157955
* A union can have a constexpr defaulted default constructor, if it has anRichard Smith2012-05-071-5/+4
| | | | | | | | | in-class initializer for one of its fields. Value-initialization of such a type should use the in-class initializer! The former was just a bug, the latter is a (reported) standard defect. llvm-svn: 156274
* Move Sema::RequireCompleteType() and Sema::RequireCompleteExprType()Douglas Gregor2012-05-041-3/+3
| | | | | | | | | | | off PartialDiagnostic. PartialDiagnostic is rather heavyweight for something that is in the critical path and is rarely used. So, switch over to an abstract-class-based callback mechanism that delays most of the work until a diagnostic is actually produced. Good for ~11k code size reduction in the compiler and 1% speedup in -fsyntax-only on the code in <rdar://problem/11004361>. llvm-svn: 156176
* Remove the ref/value inconsistency in filter_decl_iterator.David Blaikie2012-04-301-23/+23
| | | | | | | | | | | | | filter_decl_iterator had a weird mismatch where both op* and op-> returned T* making it difficult to generalize this filtering behavior into a reusable library of any kind. This change errs on the side of value, making op-> return T* and op* return T&. (reviewed by Richard Smith) llvm-svn: 155808
* Add missing -Wc++98-compat warnings for initializer list initializations whichRichard Smith2012-04-191-0/+15
| | | | | | initialize references, create std::initializer_list objects, or call constructors. llvm-svn: 155105
* When we determine that an initialization sequence failed due to anDouglas Gregor2012-04-101-3/+3
| | | | | | | | incomplete type, keep track of the actual type that was incomplete. Otherwise, we might fail to produce a diagnostic. Fixes PR12498. llvm-svn: 154432
* Fix several problems with protected access control:John McCall2012-04-071-1/+1
| | | | | | | | | | | | | | | | | | | | | - The [class.protected] restriction is non-trivial for any instance member, even if the access lacks an object (for example, if it's a pointer-to-member constant). In this case, it is equivalent to requiring the naming class to equal the context class. - The [class.protected] restriction applies to accesses to constructors and destructors. A protected constructor or destructor can only be used to create or destroy a base subobject, as a direct result. - Several places were dropping or misapplying object information. The standard could really be much clearer about what the object type is supposed to be in some of these accesses. Usually it's easy enough to find a reasonable answer, but still, the standard makes a very confident statement about accesses to instance members only being possible in either pointer-to-member literals or member access expressions, which just completely ignores concepts like constructor and destructor calls, using declarations, unevaluated field references, etc. llvm-svn: 154248
* Dependent-sequence initialization of a single element can be directDouglas Gregor2012-04-041-1/+2
| | | | | | list-initialization. Loosen an over-eager assertion to fix PR12453. llvm-svn: 153995
* Silence -Wunused-variable in -Asserts buildMatt Beaumont-Gay2012-04-021-0/+1
| | | | llvm-svn: 153885
* Properly handle explicit constructors in list-initialization. Fixes PR12120.Sebastian Redl2012-04-011-2/+27
| | | | llvm-svn: 153849
* PR10217: Provide diagnostics explaining why an implicitly-deleted specialRichard Smith2012-03-301-38/+10
| | | | | | member function is deleted. llvm-svn: 153773
* Teach APValue printer to print boolean 0 and 1 as 'false' and 'true'. Fix upRichard Smith2012-03-231-2/+4
| | | | | | some calling code to actually pass in a non-null type, to avoid a crash. llvm-svn: 153358
* Unify naming of LangOptions variable/get function across the Clang stack ↵David Blaikie2012-03-111-42/+42
| | | | | | | | | | (Lex to AST). The member variable is always "LangOpts" and the member function is always "getLangOpts". Reviewed by Chris Lattner llvm-svn: 152536
* Remove BlockDeclRefExpr and introduce a bit on DeclRefExpr toJohn McCall2012-03-101-8/+3
| | | | | | | | track whether the referenced declaration comes from an enclosing local context. I'm amenable to suggestions about the exact meaning of this bit. llvm-svn: 152491
* [AST/Sema/libclang] Replace getSourceRange().getBegin() with getLocStart().Daniel Dunbar2012-03-091-16/+16
| | | | | | | | | - getSourceRange().getBegin() is about as awesome a pattern as .copy().size(). I already killed the hot paths so this doesn't seem to impact performance on my tests-of-the-day, but it is a much more sensible (and shorter) pattern. llvm-svn: 152419
* Turn explicit construction of temporaries using initializer list syntax into ↵Sebastian Redl2012-03-081-4/+8
| | | | | | CXXTemporaryObjectExprs, not just CXXConstructExprs, which have a worrying tendency to vanish. Fixes PR12167. llvm-svn: 152340
* Be smarter in discovering list-initialization of temporaries. Fixes PR12182.Sebastian Redl2012-03-071-1/+1
| | | | llvm-svn: 152231
* If the element type of an initializer list has a destructor, make sure we ↵Sebastian Redl2012-03-051-0/+13
| | | | | | check it. Fixes PR12178. llvm-svn: 152048
* Tentatively fix PR12117. The test case from the bug now passes, and all ↵Sebastian Redl2012-02-291-8/+11
| | | | | | existing tests still pass, but there may still be corner cases. llvm-svn: 151716
* ArrayRef'ize various functions in the AST/Parser/Sema.Ahmed Charles2012-02-251-19/+22
| | | | llvm-svn: 151447
* Implement C++11 [over.match.copy]p1b2, which allows the use ofDouglas Gregor2012-02-241-9/+35
| | | | | | | | | | | explicit conversion functions to initialize the argument to a copy/move constructor that itself is the subject of direct initialization. Since we don't have that much context in overload resolution, we end up threading more flags :(. Fixes <rdar://problem/10903741> / PR10456. llvm-svn: 151409
* Sink variable into assertMatt Beaumont-Gay2012-02-241-2/+1
| | | | llvm-svn: 151356
* Kill a spurious use of hasTrivialDefaultConstructor()Douglas Gregor2012-02-241-2/+1
| | | | llvm-svn: 151353
* Replace the std::map in the init list checker with a DenseMap to reduce ↵Benjamin Kramer2012-02-231-3/+3
| | | | | | malloc thrashing. llvm-svn: 151254
* Try to handle qualifiers more consistently for array InitListExprs. Fixes ↵Eli Friedman2012-02-231-2/+7
| | | | | | | | <rdar://problem/10907510>, and makes the ASTs a bit more self-consistent. (I've chosen to keep the qualifiers, but it isn't a strong preference; if anyone prefers removing them, please yell.) llvm-svn: 151229
* Add a testcase for using objects with list-constructors, and fix a Sema ↵Sebastian Redl2012-02-191-5/+17
| | | | | | crash by repeating an old hack. llvm-svn: 150925
* Fix a crash for nested initializer list initialization. Still does the wrong ↵Sebastian Redl2012-02-191-10/+19
| | | | | | thing in CodeGen, in that it never destructs anything. llvm-svn: 150922
* Basic code generation support for std::initializer_list.Sebastian Redl2012-02-171-0/+1
| | | | | | | | | | | | | | | | | | | | | | | We now generate temporary arrays to back std::initializer_list objects initialized with braces. The initializer_list is then made to point at the array. We support both ptr+size and start+end forms, although the latter is untested. Array lifetime is correct for temporary std::initializer_lists (e.g. call arguments) and local variables. It is untested for new expressions and member initializers. Things left to do: Massively increase the amount of testing. I need to write tests for start+end init lists, temporary objects created as a side effect of initializing init list objects, new expressions, member initialization, creation of temporary objects (e.g. std::vector) for initializer lists, and probably more. Get lifetime "right" for member initializers and new expressions. Not that either are very useful. Implement list-initialization of array new expressions. llvm-svn: 150803
* Support GCC's bug^Wextension allowing class array members to be initalized by aRichard Smith2012-02-151-0/+29
| | | | | | parenthesized braced-init-list in the base/member initialization list. llvm-svn: 150625
* When overload resolution picks an implicitly-deleted special memberDouglas Gregor2012-02-151-6/+42
| | | | | | | | | function, provide a specialized diagnostic that indicates the kind of special member function (default constructor, copy assignment operator, etc.) and that it was implicitly deleted. Add a hook where we can provide more detailed information later. llvm-svn: 150611
* Introduce a new initialization entity for lambda captures, andDouglas Gregor2012-02-151-0/+11
| | | | | | specialize location information and diagnostics for this entity. llvm-svn: 150588
* PR11650: Implement resolution of core issue 1301. Value initialization can't beRichard Smith2012-02-141-15/+31
| | | | | | | used to construct an object of union type with a deleted default constructor (plus fixes for some related value-initialization corner cases). llvm-svn: 150502
* Change the way we store initialization kinds so that all direct inits can ↵Sebastian Redl2012-02-121-5/+7
| | | | | | distinguish between list and parens form. This allows us to correctly diagnose the last test cases from litb. llvm-svn: 150343
* Employ DirectList initialized entities to properly sort through some ↵Sebastian Redl2012-02-121-12/+21
| | | | | | initialization edge cases. llvm-svn: 150342
* Represent C++ direct initializers as ParenListExprs before semantic analysisSebastian Redl2012-02-111-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | instead of having a special-purpose function. - ActOnCXXDirectInitializer, which was mostly duplication of AddInitializerToDecl (leading e.g. to PR10620, which Eli fixed a few days ago), is dropped completely. - MultiInitializer, which was an ugly hack I added, is dropped again. - We now have the infrastructure in place to distinguish between int x = {1}; int x({1}); int x{1}; -- VarDecl now has getInitStyle(), which indicates which of the above was used. -- CXXConstructExpr now has a flag to indicate that it represents list- initialization, although this is not yet used. - InstantiateInitializer was renamed to SubstInitializer and simplified. - ActOnParenOrParenListExpr has been replaced by ActOnParenListExpr, which always produces a ParenListExpr. Placed that so far failed to convert that back to a ParenExpr containing comma operators have been fixed. I'm pretty sure I could have made a crashing test case before this. The end result is a (I hope) considerably cleaner design of initializers. More importantly, the fact that I can now distinguish between the various initialization kinds means that I can get the tricky generalized initializer test cases Johannes Schaub supplied to work. (This is not yet done.) This commit passed self-host, with the resulting compiler passing the tests. I hope it doesn't break more complicated code. It's a pretty big change, but one that I feel is necessary. llvm-svn: 150318
* Implement core issue 5: a temporary created for copy-initialization has aRichard Smith2012-02-111-4/+6
| | | | | | | cv-unqualified type. This is essential in order to allow move-only objects of const-qualified types to be copy-initialized via a converting constructor. llvm-svn: 150309
* Switching to using dyn_cast_or_null, and fixing line endings in the test case.Aaron Ballman2012-02-091-2/+2
| | | | llvm-svn: 150209
* Attempting to initialize a union member that does not exist no longer crashes.Aaron Ballman2012-02-091-1/+2
| | | | | | Patch by Remi Gacogne llvm-svn: 150144
* Basic: import SmallString<> into clang namespaceDylan Noblesmith2012-02-051-1/+1
| | | | | | | (I was going to fix the TODO about DenseMap too, but that would break self-host right now. See PR11922.) llvm-svn: 149799
* A useful approximation of initializer list constructors.Sebastian Redl2012-02-041-18/+43
| | | | llvm-svn: 149792
* Factor out the actual overload resolution from TryConstructorInitialization, ↵Sebastian Redl2012-02-041-53/+70
| | | | | | since it needs to be used again for list constructor resolution. llvm-svn: 149791
* Don't unwrap initializer lists before calling TryConstructorInitialization, ↵Sebastian Redl2012-02-041-19/+30
| | | | | | instead doing a little more work inside. This should make finding initializer list constructors easier, as well as fix one place where the ({}) vs {} issue was probably poorly handled. llvm-svn: 149790
* Move a method from IdentifierTable.h out of line and remove the SmallString ↵Benjamin Kramer2012-02-041-0/+1
| | | | | | | | include. Fix all the transitive include users. llvm-svn: 149783
* In C++11 mode, when an integral constant expression is desired and we have aRichard Smith2012-02-041-15/+19
| | | | | | | | | | | | | | | | | | value of class type, look for a unique conversion operator converting to integral or unscoped enumeration type and use that. Implements [expr.const]p5. Sema::VerifyIntegerConstantExpression now performs the conversion and returns the converted result. Some important callers of Expr::isIntegralConstantExpr have been switched over to using it (including all of those required for C++11 conformance); this switch brings a side-benefit of improved diagnostics and, in several cases, simpler code. However, some language extensions and attributes have not been moved across and will not perform implicit conversions on constant expressions of literal class type where an ICE is required. In passing, fix static_assert to perform a contextual conversion to bool on its argument. llvm-svn: 149776
* Split Sema::MarkDeclarationReferenced into multiple functions; the ↵Eli Friedman2012-02-021-5/+5
| | | | | | additional entry points are needed to implement C++11 odr-use marking correctly. No functional change in this patch; I'll actually make the change which fixes the odr-use marking in a followup patch. llvm-svn: 149586
* Make the callback object to Sema::CorrectTypo mandatory.Kaelyn Uhrain2012-01-311-1/+1
| | | | llvm-svn: 149451
OpenPOWER on IntegriCloud