summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaInit.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* 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
OpenPOWER on IntegriCloud