summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaInit.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* PR22465: when performing list-initialization for a class type C, if we see anRichard Smith2015-02-051-16/+19
| | | | | | | | | | initializer of the form {x}, where x is of type C or a type derived from C, perform *non-list* initialization of the entity from x, but create a CXXConstructExpr that knows that we used list-initialization syntax. Plus some fixes to ensure we mangle correctly in this and related cases. llvm-svn: 228276
* Various fixes to mangling of list-initialization.Richard Smith2015-02-051-0/+3
| | | | llvm-svn: 228274
* CXX [qoi]. Prevent a crash when initializer expression isFariborz Jahanian2015-01-281-0/+2
| | | | | | | invalid when trying to create temporary copy of the invalid initializer. rdar://19109967 llvm-svn: 227378
* Implement the remaining portion of DR1467 from r227022. I may have ↵Larisse Voufo2015-01-271-33/+14
| | | | | | overlooked a few things, but this implementation comes straight from the DR resolution itself. llvm-svn: 227224
* Tweak r227115 per review feedbackBen Langmuir2015-01-261-1/+1
| | | | | | | Use getAsArrayTypeUnsafe() instead of getUnqualifiedDesugaredType() to get the underlying ArrayType. llvm-svn: 227129
* Fix assert instantiating string init of static variableBen Langmuir2015-01-261-3/+3
| | | | | | | | ... when the variable's type is a typedef of a ConstantArrayType. Just look through the typedef (and any other sugar). We only use the constant array type here to get the element count. llvm-svn: 227115
* Don't let virtual calls and dynamic casts call Sema::MarkVTableUsed().Nico Weber2015-01-261-9/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | clang currently calls MarkVTableUsed() for classes that get their virtual methods called or that participate in a dynamic_cast. This is unnecessary, since CodeGen only emits vtables when it generates constructor, destructor, and vtt code. (*) Note that Sema::MarkVTableUsed() doesn't cause the emission of a vtable. Its main user-visible effect is that it instantiates virtual member functions of template classes, to make sure that if codegen decides to write a vtable all the entries in the vtable are defined. While this shouldn't change the behavior of codegen (other than being faster), it does make clang more permissive: virtual methods of templates (in particular destructors) end up being instantiated less often. In particular, classes that have members that are smart pointers to incomplete types will now get their implicit virtual destructor instantiated less frequently. For example, this used to not compile but does now compile: template <typename T> struct OwnPtr { ~OwnPtr() { static_assert((sizeof(T) > 0), "TypeMustBeComplete"); } }; class ScriptLoader; struct Base { virtual ~Base(); }; struct Sub : public Base { virtual void someFun() const {} OwnPtr<ScriptLoader> m_loader; }; void f(Sub *s) { s->someFun(); } The more permissive behavior matches both gcc (where this is not often observable, since in practice most things with virtual methods have a key function, and Sema::DefineUsedVTables() skips vtables for classes with key functions) and cl (which is my motivation for this change) – this fixes PR20337. See this issue and the review thread for some discussions about optimizations. This is similar to r213109 in spirit. r225761 was a prerequisite for this change. Various tests relied on "a->f()" marking a's vtable as used (in the sema sense), switch these to just construct a on the stack. This forces instantiation of the implicit constructor, which will mark the vtable as used. (*) The exception is -fapple-kext mode: In this mode, qualified calls to virtual functions (`a->Base::f()`) still go through the vtable, and since the vtable pointer off this doesn't point to Base's vtable, this needs to reference Base's vtable directly. To keep this working, keep referencing the vtable for virtual calls in apple kext mode. llvm-svn: 227073
* First steps in implementing DR1467: List-initialization of aggregate from ↵Larisse Voufo2015-01-241-32/+92
| | | | | | | | | | same-type object. Only the first two items for now, changing Sections 8.5.4 [dcl.init.list] paragraph 3 and 13.3.1.7 [over.match.list] paragraph 1, so that defining class objects and character arrays using uniform initialization syntax is actually treated as list initialization and before it is treated aggregate initialization. llvm-svn: 227022
* Fix temporary lifetime extension from an initializer using braced "functional"Richard Smith2015-01-101-7/+7
| | | | | | cast notation T{...} when T is a reference type. llvm-svn: 225571
* Handle use of default member initializers before end of outermost classReid Kleckner2014-11-171-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Specifically, when we have this situation: struct A { template <typename T> struct B { int m1 = sizeof(A); }; B<int> m2; }; We can't parse m1's initializer eagerly because we need A to be complete. Therefore we wait until the end of A's class scope to parse it. However, we can trigger instantiation of B before the end of A, which will attempt to instantiate the field decls eagerly, and it would build a bad field decl instantiation that said it had an initializer but actually lacked one. Fixed by deferring instantiation of default member initializers until they are needed during constructor analysis. This addresses a long standing FIXME in the code. Fixes PR19195. Reviewed By: rsmith Differential Revision: http://reviews.llvm.org/D5690 llvm-svn: 222192
* Fix brace init of unions with unnamed struct membersReid Kleckner2014-11-121-2/+3
| | | | | | | | The check for unnamed members was intended to skip unnamed bitfields, but it ended up skipping unnamed structs. This lead to an assertion in IRGen. llvm-svn: 221818
* Pass around CorrectionCandidateCallbacks as unique_ptrs soKaelyn Takata2014-10-271-2/+2
| | | | | | TypoCorrectionConsumer can keep the callback around as long as needed. llvm-svn: 220693
* PR20844: If we fail to list-initialize a reference, map to the referenced typeRichard Smith2014-09-041-0/+13
| | | | | | | | | before retrying the initialization to produce diagnostics. Otherwise, we may fail to produce any diagnostics, and silently produce invalid AST in a -Asserts build. Also add a note to this codepath to make it more clear why we were trying to create a temporary. llvm-svn: 217197
* CodeGen: Skip unnamed bitfields when handling designated initializersDavid Majnemer2014-08-231-1/+9
| | | | | | | We would accidently initialize unnamed bitfields instead of the following field. llvm-svn: 216313
* Sema: Properly perform lookup when acting on fields for desig initsDavid Majnemer2014-08-111-88/+35
| | | | | | | | | | | | | | | | | | | | Clang used a custom implementation of lookup when handling designated initializers. The custom code was not particularly optimized and relied on standard lookup for typo-correction anyway. This custom code has to go, it doesn't properly support MSVC-style anonymous structs embedded inside other records; replace it with the typo-correction path. This has the side effect of speeding up semantic handling of the fields for a designated initializer while simplifying the code at the same time. This fixes PR20573. Differential Revision: http://reviews.llvm.org/D4839 llvm-svn: 215372
* PR18097: Support initializing an _Atomic(T) from an object of C++ class type TRichard Smith2014-07-311-12/+43
| | | | | | | or a class derived from T. We already supported this when initializing _Atomic(T) from T for most (and maybe all) other reasonable values of T. llvm-svn: 214390
* Improve diagnostic on default-initializing const variables (PR20208).Nico Weber2014-07-231-1/+22
| | | | | | | | This tweaks the diagnostic wording slighly, and adds a fixit on a note. An alternative would be to add the fixit directly on the diagnostic, see the review thread linked to from the bug for a few notes on that approach. llvm-svn: 213725
* PR20356: Fix all Sema warnings with mismatched ext_/warn_ versusRichard Smith2014-07-191-3/+3
| | | | | | | | ExtWarn/Warnings. Mostly the name of the warning was changed to match the semantics, but in the PR20356 cases, the warning was about valid code, so the diagnostic was changed from ExtWarn to Warning instead. llvm-svn: 213443
* Cleanup: remove essentially unused variable.Richard Smith2014-07-181-3/+2
| | | | llvm-svn: 213347
* SemaInit.cpp: Fix a warning with -Asserts. [-Wunused-variable]NAKAMURA Takumi2014-07-181-0/+1
| | | | llvm-svn: 213345
* PR20346: fix aggregate initialization / template instantiation bug:Richard Smith2014-07-171-0/+9
| | | | | | | | | | | | | If, during the initial parse of a template, we perform aggregate initialization and form an implicit value initialization for an array type, then when we come to instantiate the template and redo the initialization step, we would try to match the implicit value initialization up against an array *element*, not to the complete array. Remarkably, we've had this bug since ~the dawn of time, but only noticed it recently. llvm-svn: 213332
* Track the difference betweenRichard Smith2014-07-171-10/+19
| | | | | | | | | | | | -- a constructor list initialization that unpacked an initializer list into constructor arguments and -- a list initialization that created as std::initializer_list and passed it as the first argument to a constructor in the AST. Use this flag while instantiating templates to provide the right semantics for the resulting initialization. llvm-svn: 213224
* When list-initializing an object of class type, if we pick an initializer listRichard Smith2014-07-161-17/+24
| | | | | | | | | constructor (and pass it an implicitly-generated std::initializer_list object), be sure to mark the resulting construction as list-initialization. This fixes an assert in template instantiation where we previously thought we'd got direct non-list initialization without any parentheses. llvm-svn: 213201
* rewrap to 80 cols, no behavior changeNico Weber2014-07-081-1/+2
| | | | llvm-svn: 212578
* Address review feedback for r212238.Nico Weber2014-07-031-2/+1
| | | | | | | Also, forgot to say in the commit message of r212238: Library authors will see a warning about this issue if they build with -Wsystem-headers. llvm-svn: 212243
* Enable clang to continue to parse libstdc++4.6 and stlport after r210091.Nico Weber2014-07-021-2/+53
| | | | | | | | | | r210091 made initialization checking more strict in c++11 mode. LWG2193 is about changing standard libraries to still be valid under these new rules, but older libstdc++ (e.g. libstdc++4.6 in -D_GLIBCXX_DEBUG=1 mode, or stlport) do not implement that yet. So fall back to the C++03 semantics for container classes in system headers below the std namespace. llvm-svn: 212238
* The ability to use vector initializer lists is a GNU vector extensionJames Molloy2014-06-201-0/+41
| | | | | | | | | | | | | | | | | | | | | | and is unrelated to the NEON intrinsics in arm_neon.h. On little endian machines it works fine, however on big endian machines it exhibits surprising behaviour: uint32x2_t x = {42, 64}; return vget_lane_u32(x, 0); // Will return 64. Because of this, explicitly call out that it is unsupported on big endian machines. This patch will emit the following warning in big-endian mode: test.c:3:15: warning: vector initializers are a GNU extension and are not compatible with NEON intrinsics [-Wgnu] int32x4_t x = {0, 1, 2, 3}; ^ test.c:3:15: note: consider using vld1q_s32() to initialize a vector from memory, or vcombine_s32(vcreate_s32(), vcreate_s32()) to initialize from integer constants 1 warning generated. llvm-svn: 211362
* Hide the concept of diagnostic levels from lex, parse and semaAlp Toker2014-06-151-2/+1
| | | | | | | | | | | | | | | | The compilation pipeline doesn't actually need to know about the high-level concept of diagnostic mappings, and hiding the final computed level presents several simplifications and other potential benefits. The only exceptions are opportunistic checks to see whether expensive code paths can be avoided for diagnostics that are guaranteed to be ignored at a certain SourceLocation. This commit formalizes that invariant by introducing and using DiagnosticsEngine::isIgnored() in place of individual level checks throughout lex, parse and sema. llvm-svn: 211005
* Implement DR990 and DR1070. Aggregate initialization initializes uninitializedRichard Smith2014-06-031-73/+103
| | | | | | | | | elements from {}, rather than value-initializing them. This permits calling an initializer-list constructor or constructing a std::initializer_list object. (It would also permit initializing a const reference or rvalue reference if that weren't explicitly prohibited by other rules.) llvm-svn: 210091
* PR11410: Extend diagnostic to cover all cases of aggregate initialization, notRichard Smith2014-06-031-5/+5
| | | | | | | | | | just the extremely specific case of a trailing array element that couldn't be initialized because the default constructor for the element type is deleted. Also reword the diagnostic to better match our other context diagnostics and to prepare for the implementation of core issue 1070. llvm-svn: 210083
* PR11410 - Confusing diagnostic when trailing array element tries to call ↵Nikola Smiljanic2014-05-301-3/+8
| | | | | | deleted default constructor llvm-svn: 209869
* Refactoring. Remove Owned method from Sema.Nikola Smiljanic2014-05-291-60/+44
| | | | llvm-svn: 209812
* Refactoring. Remove release and take methods from ActionResult. Rename ↵Nikola Smiljanic2014-05-291-35/+35
| | | | | | takeAs to getAs. llvm-svn: 209800
* Consolidate some note diagnosticsAlp Toker2014-05-281-1/+2
| | | | | | | | | These note diags have the same message and can be unified further but for now let's just bring them together. Incidental change: Display a source range in the final attr diagnostic. llvm-svn: 209728
* [C++11] Use 'nullptr'. Sema edition.Craig Topper2014-05-261-50/+53
| | | | llvm-svn: 209613
* Tweak diagnostic wording for init list narrowingAlp Toker2014-05-171-1/+1
| | | | | | | | | The conventional form is '<action> to silence this warning'. Also call the diagnostic an 'issue' rather than a 'message' because the latter term is more widely used with reference to message expressions. llvm-svn: 209052
* Fix a bunch of mislayered clang/Lex includes from SemaAlp Toker2014-05-031-13/+12
| | | | llvm-svn: 207896
* AST: Mangle reference temporaries reliablyDavid Majnemer2014-05-011-50/+54
| | | | | | | | | | | | | | | Summary: Previously, we would generate a single name for all reference temporaries and allow LLVM to rename them for us. Instead, number the reference temporaries as we build them in Sema. Reviewers: rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D3554 llvm-svn: 207776
* Initial implementation of -modules-earch-all option, for searching for ↵John Thompson2014-04-231-1/+1
| | | | | | symbols in non-imported modules. llvm-svn: 206977
* Implement [over.match.oper]p3 properly, by filtering the non-candidates outRichard Smith2014-04-171-3/+3
| | | | | | | when building the candidate set, rather than trying to contort name lookup into handling this. llvm-svn: 206436
* [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
OpenPOWER on IntegriCloud