summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
Commit message (Collapse)AuthorAgeFilesLines
* [Objective-C] Add objc_subclassing_restricted attributeAlex Lorenz2016-10-282-0/+23
| | | | | | | | | | | | | | | | | | | | This patch adds an objc_subclassing_restricted attribute into clang. This attribute acts similarly to 'final' - Objective-C classes with this attribute can't be subclassed. However, @interface declarations that have objc_subclassing_restricted but don't have @implementation are allowed to inherit other @interface declarations with objc_subclassing_restricted. This is needed to describe the Swift class hierarchy in clang while making sure that the Objective-C classes cannot subclass the Swift classes. This attribute is already implemented in a fork of clang that's used for Swift (https://github.com/apple/swift-clang) and this patch moves that code to the upstream clang repository. rdar://28937548 Differential Revision: https://reviews.llvm.org/D25993 llvm-svn: 285391
* Sema: do not warn about unused const vars if main file is a headerErik Verbruggen2016-10-281-2/+5
| | | | | | | | | If we pass a header to libclang, e.g. because it's open in an editor in an IDE, warnings about unused const vars are not useful: other files that include the header might use those constants. So when -x *-header is passed as command-line option, suppress this warning. llvm-svn: 285386
* Fix a crash on invalid code.Richard Trieu2016-10-281-1/+1
| | | | | | | | | | | | The diagnostic was attempting to access the QualType of a TypeDecl by calling TypeDecl::getTypeForDecl. However, the Type pointer stored there is lazily loaded by functions in ASTContext. In most cases, the pointer is loaded and this does not cause a problem. However, when more that 50 or so unknown types are seen beforehand, this causes the Type to not be loaded, passing a null Type to the diagnostics, leading to the crash. Using ASTContext::getTypeDeclType will give a proper QualType for all cases. llvm-svn: 285370
* [coroutines] Add diagnostics for copy/move assignment operators and ↵Eric Fiselier2016-10-271-47/+78
| | | | | | | | | | | | | | functions with deduced return types. Summary: The title says it all. Additionally this patch refactors the diagnostic code into a separate function. Reviewers: GorNishanov, rsmith Subscribers: majnemer, mehdi_amini, cfe-commits Differential Revision: https://reviews.llvm.org/D25292 llvm-svn: 285331
* Expand -Wlogical-not-parentheses to also fire on `!x & A`.Nico Weber2016-10-271-11/+20
| | | | | | | | | | | | | This is a misspelling of the intended !(x & A) negated bit test that happens in practice every now and then. I ran this on Chromium and all its dependencies, and it fired 0 times -- no false or true positives, but it would've caught a bug in an in-progress change that had to be caught by a Visual Studio warning instead. https://reviews.llvm.org/D26035 llvm-svn: 285310
* [coroutines] Add allocation and deallocation substatements.Gor Nishanov2016-10-271-11/+144
| | | | | | | | | | | | | | Summary: SemaCoroutine: Add allocation / deallocation substatements. CGCoroutine/Test: Emit allocation and deallocation + test. Reviewers: rsmith Subscribers: ABataev, EricWF, llvm-commits, mehdi_amini Differential Revision: https://reviews.llvm.org/D25879 llvm-svn: 285306
* [Sema] -Wunused-variable warning for array variables should behaveAlex Lorenz2016-10-271-1/+5
| | | | | | | | | | | | | | similarly to scalar variables. This commit makes the -Wunused-variable warning behaviour more consistent: Now clang won't warn for array variables where it doesn't warn for scalar variables. rdar://24158862 Differential Revision: https://reviews.llvm.org/D25937 llvm-svn: 285289
* Mark invalid RecordDecls as completed.Erik Verbruggen2016-10-271-1/+8
| | | | | | | | | | | | | | | Sema::ActOnTag creates TagDecls for records. However, if those record declarations are invalid, and the parser is in C++ mode, it would silently drop the TagDecl (and leave it as "beingDefined"). The problem is that other code (e.g. the ASTWriter) will serialize all types, and expects them to be complete. So, leaving them open would result in failing asserts. Fixes PR20320 Differential Revision: http://reviews.llvm.org/D21176 llvm-svn: 285275
* [coroutines] Build fallthrough and set_exception statements.Eric Fiselier2016-10-273-17/+125
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch adds semantic checking and building of the fall-through `co_return;` statement as well as the `p.set_exception(std::current_exception())` call for handling uncaught exceptions. The fall-through statement is built and checked according to: > [dcl.fct.def.coroutine]/4 > The unqualified-ids return_void and return_value are looked up in the scope of class P. If > both are found, the program is ill-formed. If the unqualified-id return_void is found, flowing > off the end of a coroutine is equivalent to a co_return with no operand. Otherwise, flowing off > the end of a coroutine results in undefined behavior. Similarly the `set_exception` call is only built when that unqualified-id is found in the scope of class P. Additionally this patch adds fall-through warnings for non-void returning coroutines. Since it's surprising undefined behavior I thought it would be important to add the warning right away. Reviewers: majnemer, GorNishanov, rsmith Subscribers: mehdi_amini, cfe-commits Differential Revision: https://reviews.llvm.org/D25349 llvm-svn: 285271
* [modules] PR28812: Modules can return duplicate field decls.Vassil Vassilev2016-10-261-2/+9
| | | | | | | | | | | | | If two modules contain duplicate class definitions the lookup result can contain more than 2 elements. Sift the lookup results until we find a field decl. It is not necessary to do ODR checks in place as they done elsewhere. This should fix issues when compiling with libstdc++ 5.2 and 6.2. Patch developed in collaboration with Richard Smith! llvm-svn: 285184
* [Sema] Handle CaseStmt and DefaultStmt as SwitchCaseVitaly Buka2016-10-261-4/+2
| | | | | | | | Summary: rsmith Differential Revision: https://reviews.llvm.org/D25665 llvm-svn: 285159
* Implement name mangling proposal for exception specifications from ↵Richard Smith2016-10-262-0/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | cxx-abi-dev 2016-10-11. This has the following ABI impact: 1) Functions whose parameter or return types are non-throwing function pointer types have different manglings in c++1z mode from prior modes. This is necessary because c++1z permits overloading on the noexceptness of function pointer parameter types. A warning is issued for cases that will change manglings in c++1z mode. 2) Functions whose parameter or return types contain instantiation-dependent exception specifications change manglings in all modes. This is necessary to support overloading on / SFINAE in these exception specifications, which a careful reading of the standard indicates has essentially always been permitted. Note that, in order to be affected by these changes, the code in question must specify an exception specification on a function pointer/reference type that is written syntactically within the declaration of another function. Such declarations are very rare, and I have so far been unable to find any code that would be affected by this. (Note that such things will probably become more common in C++17, since it's a lot easier to get a noexcept function type as a function parameter / return type there.) This change does not affect the set of symbols produced by a build of clang, libc++, or libc++abi. llvm-svn: 285150
* Reapply r284265: "[Sema] Refactor context checking for availability diagnostics"Erik Pilkington2016-10-253-111/+100
| | | | | | | | The problem with the original commit was that some of Apple's headers depended on an incorrect behaviour, this commit adds a temporary workaround until those headers are fixed. llvm-svn: 285098
* Re-apply patch r279045.Kelvin Li2016-10-252-1/+197
| | | | llvm-svn: 285066
* [Sema][ObjC] Warn about implicitly autoreleasing out-parameters capturedAkira Hatanaka2016-10-241-0/+17
| | | | | | | | | | | | | | by blocks. Add a new warning "-Wblock-capture-autoreleasing". The warning warns about implicitly autoreleasing out-parameters captured by blocks which can introduce use-after-free bugs that are hard to debug. rdar://problem/15377548 Differential Revision: https://reviews.llvm.org/D25844 llvm-svn: 285031
* Add support for __builtin_os_log_format[_buffer_size]Mehdi Amini2016-10-242-74/+241
| | | | | | | | | | | | | | | | | This reverts commit r285007 and reapply r284990, with a fix for the opencl test that I broke. Original commit message follows: These new builtins support a mechanism for logging OS events, using a printf-like format string to specify the layout of data in a buffer. The _buffer_size version of the builtin can be used to determine the size of the buffer to allocate to hold the data, and then __builtin_os_log_format can write data into that buffer. This implements format checking to report mismatches between the format string and the data arguments. Most of this code was written by Chris Willmore. Differential Revision: https://reviews.llvm.org/D25888 llvm-svn: 285019
* Revert "Add support for __builtin_os_log_format[_buffer_size]"Mehdi Amini2016-10-242-240/+74
| | | | | | This reverts commit r284990, two opencl test are broken llvm-svn: 285007
* Add support for __builtin_os_log_format[_buffer_size]Mehdi Amini2016-10-242-74/+240
| | | | | | | | | | | | | | These new builtins support a mechanism for logging OS events, using a printf-like format string to specify the layout of data in a buffer. The _buffer_size version of the builtin can be used to determine the size of the buffer to allocate to hold the data, and then __builtin_os_log_format can write data into that buffer. This implements format checking to report mismatches between the format string and the data arguments. Most of this code was written by Chris Willmore. Differential Revision: https://reviews.llvm.org/D25888 llvm-svn: 284990
* [Sema] Formatting warnings should see through Objective-C message sendsAlex Lorenz2016-10-241-0/+14
| | | | | | | | | | | | This commit improves the '-Wformat' warnings by ensuring that the formatting checker can see through Objective-C message sends when we are calling an Objective-C method with an appropriate format_arg attribute. rdar://23622446 Differential Revision: https://reviews.llvm.org/D25820 llvm-svn: 284961
* [Sema][TreeTransform] Re-create DesignatedInitExpr when a field designatorAlex Lorenz2016-10-241-0/+13
| | | | | | | | | | | | | | | | | | has no field declaration. This commit fixes an invalid Winitializer-overrides warning that's shown when analyzing a second (or any after the first) instantiation of a designated initializer. This invalid warning is fixed by making sure that a DesignatedInitExpr is rebuilt by the tree transformer when it has a field designator whose FieldDecl* hasn't been yet initialized. This ensures that a different DesignatedInitExpr is processed by Sema for every instantiation, and thus the invalid warning is avoided. rdar://28768441 Differential Revision: https://reviews.llvm.org/D25777 llvm-svn: 284959
* [AVX-512] Remove masked 128/256-bit palignr builtins. We can just use a ↵Craig Topper2016-10-221-2/+0
| | | | | | select in the header file with the older unmasked versions instead. llvm-svn: 284920
* [c++1z] P0012R1: Implement a few remaining pieces: downgrade diagnostic forRichard Smith2016-10-224-36/+86
| | | | | | | | | | | | | | mismatched dynamic exception specifications in expressions from an error to a warning, since this is no longer ill-formed in C++1z. Allow reference binding of a reference-to-non-noexcept function to a noexcept function lvalue. As defect resolutions, also allow a conditional between noexcept and non-noexcept function lvalues to produce a non-noexcept function lvalue (rather than decaying to a function pointer), and allow function template argument deduction to deduce a reference to non-noexcept function when binding to a noexcept function type. llvm-svn: 284905
* Remove unnecessary distinction between Ref_Compatible andRichard Smith2016-10-213-13/+9
| | | | | | | Ref_Compatible_With_Added_Qualification. We always treated these two values the same way. llvm-svn: 284895
* DR583, DR1512: Implement a rewrite to C++'s 'composite pointer type' rules.Richard Smith2016-10-213-131/+134
| | | | | | | | | | | | | | | | | | | | | | | | | | This has two significant effects: 1) Direct relational comparisons between null pointer constants (0 and nullopt) and pointers are now ill-formed. This was always the case for C, and it appears that C++ only ever permitted by accident. For instance, cases like nullptr < &a are now rejected. 2) Comparisons and conditional operators between differently-cv-qualified pointer types now work, and produce a composite type that both source pointer types can convert to (when possible). For instance, comparison between 'int **' and 'const int **' is now valid, and uses an intermediate type of 'const int *const *'. Clang previously supported #2 as an extension. We do not accept the cases in #1 as an extension. I've tested a fair amount of code to check that this doesn't break it, but if it turns out that someone is relying on this, we can easily add it back as an extension. This is a re-commit of r284800. llvm-svn: 284890
* [Sema] Store a SourceRange for multi-token builtin typesMalcolm Parsons2016-10-212-20/+22
| | | | | | | | | | | | | | | | | | | Summary: clang-tidy's modernize-use-auto check uses the SourceRange of a TypeLoc when replacing the type with auto. This was producing the wrong result for multi-token builtin types like long long: -long long *ll = new long long(); +auto long *ll = new long long(); Reviewers: alexfh, hokein, rsmith, Prazek, aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25363 llvm-svn: 284885
* Declare H and H new/delete.Artem Belevich2016-10-211-22/+33
| | | | llvm-svn: 284879
* Remove accidentally checked in assert.Vassil Vassilev2016-10-211-3/+0
| | | | | | Thanks to Manman for spotting this. llvm-svn: 284877
* [CUDA] Use FunctionDeclAndLoc for the Sema::LocsWithCUDACallDiags hashtable.Justin Lebar2016-10-211-1/+1
| | | | | | | | | | | | Summary: NFC Reviewers: rnk Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25797 llvm-svn: 284869
* Removed unused function argument. NFC.Artem Belevich2016-10-212-2/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D25839 llvm-svn: 284843
* Revert "DR583, DR1512: Implement a rewrite to C++'s 'composite pointer type' ↵Renato Golin2016-10-213-134/+131
| | | | | | | | rules." This reverts commit r284800, as it failed all ARM/AArch64 bots. llvm-svn: 284811
* Don't try to use !Previous.empty() as a proxy for "Is this a redeclaration?" --Richard Smith2016-10-212-7/+4
| | | | | | | | | | | we don't collapse that down to a single entry if it's not a redeclaration. Instead, set the Redeclaration bit on the Declarator to indicate whether a function is a redeclaration (which may not have been linked into the redeclaration chain if it's a dependent context friend). Fixes a rejects-valid; see testcase. llvm-svn: 284802
* DR583, DR1512: Implement a rewrite to C++'s 'composite pointer type' rules.Richard Smith2016-10-213-131/+134
| | | | | | | | | | | | | | | | | | | | | | | | This has two significant effects: 1) Direct relational comparisons between null pointer constants (0 and nullopt) and pointers are now ill-formed. This was always the case for C, and it appears that C++ only ever permitted by accident. For instance, cases like nullptr < &a are now rejected. 2) Comparisons and conditional operators between differently-cv-qualified pointer types now work, and produce a composite type that both source pointer types can convert to (when possible). For instance, comparison between 'int **' and 'const int **' is now valid, and uses an intermediate type of 'const int *const *'. Clang previously supported #2 as an extension. We do not accept the cases in #1 as an extension. I've tested a fair amount of code to check that this doesn't break it, but if it turns out that someone is relying on this, we can easily add it back as an extension. llvm-svn: 284800
* Re-commit r284753, reverted in r284778, with a fix for PR30749.Richard Smith2016-10-202-51/+196
| | | | | | | | | | Original commit message: [c++1z] Teach composite pointer type computation how to compute the composite pointer type of two function pointers with different noexcept specifications. While I'm here, also teach it how to merge dynamic exception specifications. llvm-svn: 284785
* Revert r284753 "[c++1z] Teach composite pointer type computation how to ↵Hans Wennborg2016-10-202-193/+51
| | | | | | | | compute the composite" It caused PR30749. llvm-svn: 284778
* [c++1z] Fix assertion failure when using the wrong number of bindings for aRichard Smith2016-10-201-1/+3
| | | | | | struct with unnamed bitfields. llvm-svn: 284761
* [c++1z] Teach composite pointer type computation how to compute the compositeRichard Smith2016-10-202-51/+193
| | | | | | | pointer type of two function pointers with different noexcept specifications. While I'm here, also teach it how to merge dynamic exception specifications. llvm-svn: 284753
* Retire llvm::alignOf in favor of C++11 alignof.Benjamin Kramer2016-10-204-8/+8
| | | | | | No functionality change intended. llvm-svn: 284730
* Work around MSVC rejects-valid. Apparenty (some versions of) MSVC will checkRichard Smith2016-10-201-9/+8
| | | | | | | that a member is default-initializable even if it's initialized by a default member initializer. llvm-svn: 284701
* Refactor and simplify Sema::FindCompositePointerType. No functionality ↵Richard Smith2016-10-201-126/+123
| | | | | | change intended. llvm-svn: 284685
* PR26276: Fix detection of non-cast-expressions as operands of fold-expressions.Richard Smith2016-10-201-1/+3
| | | | llvm-svn: 284684
* Fix crash on noreturn conversion in unprototyped function type. Thanks to KeithRichard Smith2016-10-201-2/+2
| | | | | | Walker for spotting the bug. llvm-svn: 284673
* Extend hack to work around bad exception specifications for 'swap' members toRichard Smith2016-10-191-8/+21
| | | | | | also cover libstdc++'s std::__debug::array and std::__profile::array. llvm-svn: 284669
* Add optimization to sizeof...(X) handling: if none of parameter pack X'sRichard Smith2016-10-192-1/+105
| | | | | | | | | | | | | | | | | | | | | corresponding arguments are unexpanded pack expansions, we can compute the result without substituting them. This significantly improves the memory usage and performance of make_integer_sequence implementations that do this kind of thing: using result = integer_sequence<T, Ns ..., sizeof...(Ns) + Ns ...>; ... but note that such an implementation will still perform O(sizeof...(Ns)^2) work while building the second pack expansion (we just have a somewhat lower constant now). In principle we could get this down to linear time by caching whether the number of expansions of a pack is constant, or checking whether we're within an alias template before scanning the pack for pack expansions (since that's the only case in which we do substitutions within a dependent context at the moment), but this patch doesn't attempt that. llvm-svn: 284653
* [CUDA] When we emit an error that might have been deferred, also print a ↵Justin Lebar2016-10-191-44/+98
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | callstack. Summary: Previously, when you did something not allowed in a host+device function and then caused it to be codegen'ed, we would print out an error telling you that you did something bad, but we wouldn't tell you how we decided that the function needed to be codegen'ed. This change causes us to print out a callstack when emitting deferred errors. This is immensely helpful when debugging highly-templated code, where it's often unclear how a function became known-emitted. We only print the callstack once per function, after we print the all deferred errors. This patch also switches all of our hashtables to using canonical FunctionDecls instead of regular FunctionDecls. This prevents a number of bugs, some of which are caught by tests added here, in which we assume that two FDs for the same function have the same pointer value. Reviewers: rnk Subscribers: cfe-commits, tra Differential Revision: https://reviews.llvm.org/D25704 llvm-svn: 284647
* [CUDA] Emit errors for wrong-side calls made on the same line as ↵Justin Lebar2016-10-191-4/+6
| | | | | | | | | | | | | | | | | | | | | | | non-wrong-side calls. Summary: This fixes two related bugs: 1) Previously, if you had a non-wrong side call at some source code location L, we wouldn't emit errors for wrong-side calls that appeared at L. 2) We'd only emit one wrong-side error per source code location, when we actually want to emit it twice if we hit this line more than once due to e.g. template instantiation. Reviewers: tra Subscribers: rnk, cfe-commits Differential Revision: https://reviews.llvm.org/D25702 llvm-svn: 284643
* [mips][msa] Range check MSA intrinsics with immediatesSimon Dardis2016-10-191-4/+194
| | | | | | | | | | | | | | | | This patch teaches clang to range check immediates for MIPS MSA instrinsics. This checking is done strictly in comparison to some existing GCC implementations. E.g. msa_andvi_b(var, 257) does not result in andvi $wX, 1. Similarily msa_ldi_b takes a range of -128 to 127. As part of this effort, correct the existing MSA test as it has both illegal types and immediates. Reviewers: vkalintiris Differential Revision: https://reviews.llvm.org/D25017 llvm-svn: 284620
* [Sema] Gcc compatibility of vector shiftAndrey Bokhanko2016-10-191-0/+10
| | | | | | | | | | | Gcc prints error if elements of left and right parts of a shift have different sizes. This patch is provided the GCC compatibility. Patch by Vladimir Yakovlev. Differential Revision: https://reviews.llvm.org/D24669 llvm-svn: 284579
* [modules] Do not report missing definitions of demoted constexpr variable ↵Vassil Vassilev2016-10-191-1/+5
| | | | | | | | | | | | | | templates. This is a followup to regression introduced in r284284. This should fix our libstdc++ modules builds. https://reviews.llvm.org/D25678 Reviewed by Richard Smith! llvm-svn: 284577
* Resolve exception specifications when selecting an overloaded operator.Richard Smith2016-10-191-0/+2
| | | | llvm-svn: 284556
* DR1330: instantiate exception-specifications when "needed". We previously didRichard Smith2016-10-182-6/+28
| | | | | | | | | | | | | | | | | | | | not instantiate exception specifications of functions if they were only used in unevaluated contexts (other than 'noexcept' expressions). In C++17 onwards, this becomes essential since the exception specification is now part of the function's type. Note that this means that constructs like the following no longer work: struct A { static T f() noexcept(...); decltype(f()) *p; }; ... because the decltype expression now needs the exception specification of 'f', which has not yet been parsed. llvm-svn: 284549
OpenPOWER on IntegriCloud