summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
Commit message (Collapse)AuthorAgeFilesLines
...
* Add warning for inconsistent overrides on destructor.Richard Trieu2017-03-011-5/+6
| | | | | | | | | The exisiting warning for inconsistent overrides does not include the destructor as it was noted in review that it was too noisy. Instead, add to a separate warning group that is off by default for users who want consistent warnings between methods and destructors. llvm-svn: 296572
* Allow attributes before union definitionErich Keane2017-02-282-5/+15
| | | | | | | | permits typedef union __attribute__((transparent_union)) {...} Differential Revision: https://reviews.llvm.org/D28266 llvm-svn: 296518
* [Sema] Detect more array index out of bounds when C++ overloaded operators ↵Daniel Marjamaki2017-02-281-0/+6
| | | | | | | | are used Differential Revision: https://reviews.llvm.org/D30192 llvm-svn: 296477
* C++ DR1611, 1658, 2180: implement "potentially constructed subobject" rules ↵Richard Smith2017-02-251-11/+23
| | | | | | | | | | | | | | | | | | | | | | for special member functions. Essentially, as a base class constructor does not construct virtual bases, such a constructor for an abstract class does not need the corresponding base class construction to be valid, and likewise for destructors. This creates an awkward situation: clang will sometimes generate references to the complete object and deleting destructors for an abstract class (it puts them in the construction vtable for a derived class). But we can't generate a "correct" version of these because we can't generate references to base class constructors any more (if they're template specializations, say, we might not have instantiated them and can't assume any other TU will emit a copy). Fortunately, we don't need to, since no correct program can ever invoke them, so instead emit symbols that just trap. We should stop emitting references to these symbols, but still need to emit definitions for compatibility. llvm-svn: 296275
* Factor out more commonality between handling of deletion and exception ↵Richard Smith2017-02-241-86/+128
| | | | | | specifications for special member functions. llvm-svn: 296173
* Represent pass_object_size attrs in ExtParameterInfoGeorge Burgess IV2017-02-241-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The goal of this is to fix a bug in modules where we'd merge FunctionDecls that differed in their pass_object_size attributes. Since we can overload on the presence of pass_object_size attributes, this behavior is incorrect. We don't represent `N` in `pass_object_size(N)` as part of ExtParameterInfo, since it's an error to overload solely on the value of N. This means that we have a bug if we have two modules that declare functions that differ only in their pass_object_size attrs, like so: // In module A, from a.h void foo(char *__attribute__((pass_object_size(0)))); // In module B, from b.h void foo(char *__attribute__((pass_object_size(1)))); // In module C, in main.c #include "a.h" #include "b.h" At the moment, we'll merge the foo decls, when we should instead emit a diagnostic about an invalid overload. We seem to have similar (silent) behavior if we overload only on the return type of `foo` instead; I'll try to find a good place to put a FIXME (or I'll just file a bug) soon. This patch also fixes a bug where we'd not output the proper extended parameter info for declarations with pass_object_size attrs. llvm-svn: 296076
* Factor out some common code between SpecialMemberExceptionSpecInfo and ↵Richard Smith2017-02-243-111/+101
| | | | | | | | SpecialMemberDeletionInfo. To simplify this, convert SpecialMemberOverloadResult to a value type. llvm-svn: 296073
* Simplify and pass a more useful source location when computing an exceptionRichard Smith2017-02-241-14/+3
| | | | | | specification for an implicit special member. llvm-svn: 296068
* Refactor computation of exception specification for special members to removeRichard Smith2017-02-241-361/+135
| | | | | | some of the repetition. llvm-svn: 296067
* PR32044: Fix some cases where we would confuse a transparent init-list ↵Richard Smith2017-02-231-0/+5
| | | | | | expression with an aggregate init. llvm-svn: 296033
* Add context note to diagnostics that occur while declaring an implicit ↵Richard Smith2017-02-232-39/+85
| | | | | | special member function. llvm-svn: 296020
* Fix tracking of whether the previous template instantiation stack matches ↵Richard Smith2017-02-232-3/+6
| | | | | | | | | | | | | | | | | the current one. Rather than attempting to compare whether the previous and current top of context stack are "equal" (which fails for a number of reasons, such as the context stack entries containing pointers to objects on the stack, or reaching the same "top of stack" entry through two different paths), track the depth of context stack at which we last emitted a note and invalidate it when we pop the context stack to less than that depth. This causes us to emit some missing "in instantiation of" notes and to stop emitting redundant "in instantiation of" stacks matching the previous stack in rare cases. llvm-svn: 295921
* Rename ActiveTemplateInstantiation to CodeSynthesisContext in preparation forRichard Smith2017-02-239-91/+88
| | | | | | | using it for other kinds of context (where we currently produce context notes in a highly ad-hoc manner). llvm-svn: 295919
* Improve support for 'decltype(auto)' in template template parameter matching.Richard Smith2017-02-221-0/+13
| | | | | | | | | | | | | | | A 'decltype(auto)' parameter can match any other kind of non-type template parameter, so should be usable in place of any other parameter in a template template argument. The standard is sadly extremely unclear on how this is supposed to work, but this seems like the obviously-correct result. It's less clear whether an 'auto' parameter should be able to match 'decltype(auto)', since the former cannot be used if the latter turns out to be used for a reference type, but if we disallow that then consistency suggests we should also disallow 'auto' matching 'T' for the same reason, defeating intended use cases of the feature. llvm-svn: 295866
* [OpenCL] r600 needs OpenCL kernel calling conventionJan Vesely2017-02-221-1/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D30236 llvm-svn: 295843
* [OpenMP] Generate better diagnostics for cancel and cancellation pointJonas Hahnfeld2017-02-221-14/+20
| | | | | | | | | | | | | | | checkNestingOfRegions uses CancelRegion to determine whether cancel and cancellation point are valid in the given nesting. This leads to unuseful diagnostics if CancelRegion is invalid. The given test case has produced: region cannot be closely nested inside 'parallel' region As a solution, introduce checkCancelRegion and call it first to get the expected error: one of 'for', 'parallel', 'sections' or 'taskgroup' is expected Differential Revision: https://reviews.llvm.org/D30135 llvm-svn: 295808
* Fix deduction of type of pack-expanded non-type template parameter.Richard Smith2017-02-211-50/+95
| | | | | | | | | We need to look through the PackExpansionType in the parameter type when deducing, and we need to consider the possibility of deducing arguments for packs that are not lexically mentioned in the pattern (but are nonetheless deducible) when figuring out which packs are covered by a pack deduction scope. llvm-svn: 295790
* Fix lookup through injected-class-names in implicit deduction guides in theRichard Smith2017-02-211-4/+10
| | | | | | | | | | case where the class template has a parameter pack. Checking of the template arguments expects an "as-written" template argument list, which in particular does not have any parameter packs. So flatten the packs into separate arguments before passing them in. llvm-svn: 295710
* When deducing an array bound from the length of an initializer list, don'tRichard Smith2017-02-211-3/+10
| | | | | | assume the bound has a non-dependent integral type. llvm-svn: 295698
* PR32010: Fix template argument depth mixup when forming implicit constructorRichard Smith2017-02-213-36/+44
| | | | | | | | | | | | | template deduction guides for class template argument deduction. Ensure that we have a local instantiation scope for tracking the instantiated parameters. Additionally, unusually, we're substituting at depth 1 and leaving depth 0 alone; make sure that we don't reduce template parameter depth by 2 for inner parameters in the process. (This is probably also broken for alias templates in the case where they're expanded within a dependent context, but this patch doesn't fix that.) llvm-svn: 295696
* Factor out function to determine whether we're performing a templateRichard Smith2017-02-2113-48/+41
| | | | | | | | | instantiation. In preparation for converting the template stack to a more general context stack (so we can include context notes for other kinds of context). llvm-svn: 295686
* Sema: use PropertyDecl for property selectorSaleem Abdulrasool2017-02-201-8/+14
| | | | | | | | | | | Using the constructed name for the class properties with dot syntax may yield an inappropriate selector (i.e. if it is specified via property attributes). Prefer the declaration for the selector, falling back to the constructed name otherwise. Patch by David Herzka! llvm-svn: 295683
* [Sema][ObjC] perform-selector ARC check should see @selector in parensAlex Lorenz2017-02-201-1/+2
| | | | llvm-svn: 295674
* Process attributes 'ifunc' and 'alias' when checking for redefinitionSerge Pavlov2017-02-181-0/+12
| | | | | | | | | | These attributes effectively turn a non-defining declaration into a definition, so the case when the declaration already has a body must be diagnosed properly. Differential Revision: https://reviews.llvm.org/D30032 llvm-svn: 295541
* Part of adding an improved ODR checker.Richard Trieu2017-02-181-1/+4
| | | | | | | | | Reserve a spot for ODR hash in CXXRecordDecl and in its modules storage. Default the hash value to 0 for all classes. Differential Revision: https://reviews.llvm.org/D21675 llvm-svn: 295533
* [OpenMP] Prepare Sema for initial implementation for pragma 'distribute ↵Carlo Bertolli2017-02-171-0/+32
| | | | | | | | | | | | | | | parallel for' https://reviews.llvm.org/D29922 This patch adds two fields for use in the implementation of 'distribute parallel for': The increment expression for the distribute loop. As the chunk assigned to a team is executed by multiple threads within the 'parallel for' region, the increment expression has to correspond to the value returned by the related runtime call (for_static_init). The upper bound of the innermost loop ('for' in 'distribute parallel for') is not the globalUB expression normally used for pragma 'for' when found in isolation. It is instead the upper bound of the chunk assigned to the team ('distribute' loop). In this way, we prevent teams from executing chunks assigned to other teams. The use of these two fields can be see in a related explanatory patch: https://reviews.llvm.org/D29508 llvm-svn: 295497
* Add an explicit derived class of FunctionDecl to model deduction guides ratherRichard Smith2017-02-178-63/+68
| | | | | | | | than just treating them as FunctionDecls with a funny name. No functionality change intended. llvm-svn: 295491
* Revert r295421, new ODR checker for modules, to fix build bot.Richard Trieu2017-02-171-4/+1
| | | | llvm-svn: 295427
* Add better ODR checking for modules.Richard Trieu2017-02-171-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A slightly weaker form of ODR checking than previous attempts, but hopefully won't break the modules build bot. Future work will be needed to catch all cases. When objects are imported for modules, there is a chance that a name collision will cause an ODR violation. Previously, only a small number of such violations were detected. This patch provides a stronger check based on AST nodes. The information needed to uniquely identify an object is taken from the AST and put into a one-dimensional byte stream. This stream is then hashed to give a value to represent the object, which is stored with the other object data in the module. When modules are loaded, and Decl's are merged, the hash values of the two Decl's are compared. Only Decl's with matched hash values will be merged. Mismatch hashes will generate a module error, and if possible, point to the first difference between the two objects. The transform from AST to byte stream is a modified depth first algorithm. Due to references between some AST nodes, a pure depth first algorithm could generate loops. For Stmt nodes, a straight depth first processing occurs. For Type and Decl nodes, they are replaced with an index number and only on first visit will these nodes be processed. As an optimization, boolean values are saved and stored together in reverse order at the end of the byte stream to lower the ammount of data that needs to be hashed. Compile time impact was measured at 1.5-2.0% during module building, and negligible during builds without module building. Differential Revision: https://reviews.llvm.org/D21675 llvm-svn: 295421
* Use correct fix-it location for -Wblock-capture-autoreleasingAlex Lorenz2017-02-161-2/+24
| | | | | | | | | The '__autoreleasing' keyword should be inserted after the Objective-C pointer type. rdar://30123548 llvm-svn: 295381
* Properly set up the DeclContext for parameters of implicit deduction guides;Richard Smith2017-02-161-2/+7
| | | | | | this is needed for deferred instantiation of default arguments. llvm-svn: 295379
* [OpenCL] Correct ndrange_t implementationAnastasia Stulova2017-02-162-3/+2
| | | | | | | | | | | | | | | Removed ndrange_t as Clang builtin type and added as a struct type in the OpenCL header. Use type name to do the Sema checking in enqueue_kernel and modify IR generation accordingly. Review: D28058 Patch by Dmitry Borisenkov! llvm-svn: 295311
* [OpenCL] Disallow blocks capture other blocks (v2.0, s6.12.5)Anastasia Stulova2017-02-161-0/+7
| | | | llvm-svn: 295307
* Revert r295284: Add better ODR checking for modules.Richard Trieu2017-02-161-4/+1
| | | | | | Fix modules build bot. llvm-svn: 295293
* Add better ODR checking for modules.Richard Trieu2017-02-161-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Recommit r293585 that was reverted in r293611 with new fixes. The previous issue was determined to be an overly aggressive AST visitor from forward declared objects. The visitor will now only deeply visit certain Decl's and only do a shallow information extraction from all other Decl's. When objects are imported for modules, there is a chance that a name collision will cause an ODR violation. Previously, only a small number of such violations were detected. This patch provides a stronger check based on AST nodes. The information needed to uniquely identify an object is taken from the AST and put into a one-dimensional byte stream. This stream is then hashed to give a value to represent the object, which is stored with the other object data in the module. When modules are loaded, and Decl's are merged, the hash values of the two Decl's are compared. Only Decl's with matched hash values will be merged. Mismatch hashes will generate a module error, and if possible, point to the first difference between the two objects. The transform from AST to byte stream is a modified depth first algorithm. Due to references between some AST nodes, a pure depth first algorithm could generate loops. For Stmt nodes, a straight depth first processing occurs. For Type and Decl nodes, they are replaced with an index number and only on first visit will these nodes be processed. As an optimization, boolean values are saved and stored together in reverse order at the end of the byte stream to lower the ammount of data that needs to be hashed. Compile time impact was measured at 1.5-2.0% during module building, and negligible during builds without module building. Differential Revision: https://reviews.llvm.org/D21675 llvm-svn: 295284
* Revert r295277 to fix buildbot.Richard Smith2017-02-161-93/+61
| | | | llvm-svn: 295281
* Add missing "deduced A == A" check for function template partial ordering.Richard Smith2017-02-161-61/+93
| | | | | | | | | This appears to be the only template argument deduction context where we were missing this check. Surprisingly, other implementations also appear to miss the check in this case; it may turn out that important code is relying on the widespread non-conformance here, in which case we'll need to reconsider. llvm-svn: 295277
* [Sema] Add lvalue-to-rvalue cast in direct-list-initialization of enumVedant Kumar2017-02-161-0/+2
| | | | | | | | | | | | | | | | | After r264564, we allowed direct-list-initialization of an enum from an integral value in C++1z mode, so long as that value can convert to the enum's underlying type. In this kind of initialization, we need a lvalue-to-rvalue conversion for the initializer value if it is not a rvalue. This lets us accept the following code: enum class A : unsigned {}; A foo(unsigned x) { return A{x}; } Differential Revision: https://reviews.llvm.org/D29723 llvm-svn: 295266
* [c++1z] Diagnose non-deducible template parameters in deduction guide ↵Richard Smith2017-02-162-18/+48
| | | | | | templates, per [temp.param]p11. llvm-svn: 295264
* PR24440: Do not silently discard a fold-expression appearing as the operand ↵Richard Smith2017-02-151-0/+7
| | | | | | of a cast-expression. llvm-svn: 295224
* Fix spelling mistake - paramater -> parameter. NFCI.Simon Pilgrim2017-02-151-2/+2
| | | | llvm-svn: 295183
* Removed stale comment. NFC.Serge Pavlov2017-02-151-2/+0
| | | | | | | The case of extern inline functions in GNU89 mode is now handled in `canRedefineFunction`, which has appropriate comment. llvm-svn: 295167
* [Sema] Disallow returning a __block variable via a move.Akira Hatanaka2017-02-151-3/+5
| | | | | | | | | | | | | | | r274291 made changes to prefer calling a move constructor to calling a copy constructor when returning from a function. This caused programs to crash when a __block variable in the heap was moved out and used later. This commit fixes the bug by disallowing moving out of __block variables implicitly. rdar://problem/28181080 Differential Revision: https://reviews.llvm.org/D29908 llvm-svn: 295150
* Fix assertion failure due to implicit special member lookup lacking a source ↵Richard Smith2017-02-151-4/+7
| | | | | | location. llvm-svn: 295149
* [VLA] Handle VLA size expression in a full-expression context.Tim Shen2017-02-142-2/+11
| | | | | | | | | | | | | | | | Summary: Previously the cleanups (e.g. dtor calls) are inserted into the outer scope (e.g. function body scope), instead of it's own scope. After the fix, the cleanups are inserted right after getting the size value. This fixes pr30306. Reviewers: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D24333 llvm-svn: 295123
* Canonicalize implicit deduction guide parameter types when forming a deductionRichard Smith2017-02-141-9/+19
| | | | | | | | | | | | guide from a constructor. The purpose of this change is to avoid triggering instantiation of the class when substituting back into the deduction guide if it uses a typedef member. We will still instantiate the class if the constructor (explicitly or implicitly, directly or indirectly) uses the current instantiation in a way that we can't canonicalize out, but that seems unavoidable. llvm-svn: 295016
* [c++1z] Synthesize implicit deduction guides from constructors on demand. RankRichard Smith2017-02-146-69/+462
| | | | | | | | | | | | | | | | | | | such guides below explicit ones, and ensure that references to the class's template parameters are not treated as forwarding references. We make a few tweaks to the wording in the current standard: 1) The constructor parameter list is copied faithfully to the deduction guide, without losing default arguments or a varargs ellipsis (which the standard wording loses by omission). 2) If the class template declares no constructors, we add a T() -> T<...> guide (which will only ever work if T has default arguments for all non-pack template parameters). 3) If the class template declares nothing that looks like a copy or move constructor, we add a T(T<...>) -> T<...> guide. #2 and #3 follow from the "pretend we had a class type with these constructors" philosophy for deduction guides. llvm-svn: 295007
* [CodeCompletion] Code complete the '__auto_type' keywordAlex Lorenz2017-02-131-2/+3
| | | | | | rdar://29219185 llvm-svn: 295003
* [CodeCompletion] Code complete the missing C++11 keywordsAlex Lorenz2017-02-131-11/+74
| | | | | | | | | | | | | | | | | | | | | | | | This commit adds context sensitive code completion support for the C++11 keywords that currently don't have completion results. The following keywords are supported by this patch: alignas constexpr static_assert noexcept (as a function/method qualifier) thread_local The following special identifiers are also supported: final (as a method qualifier or class qualifier) override rdar://29219185 Differential Revision: https://reviews.llvm.org/D28286 llvm-svn: 295001
* [coroutines] NFC: Refactor Sema::CoroutineBodyStmt construction.Gor Nishanov2017-02-131-78/+159
| | | | | | | | | | | | | | | | | | | Summary: Sema::CheckCompletedCoroutineBody was growing unwieldy with building all of the substatements. Also, constructors for CoroutineBodyStmt had way too many parameters. Instead, CoroutineBodyStmt now defines CtorArgs structure with all of the required construction parameters. CheckCompleteCoroutineBody delegates construction of individual substatements to short functions one per each substatement. Also, added a drive-by fix of initializing CoroutinePromise to nullptr in ScopeInfo.h. And addressed the FIXME that wanted to tail allocate extra room at the end of the CoroutineBodyStmt to hold parameter move expressions. (The comment was longer that the code that implemented tail allocation). Reviewers: rsmith, EricWF Subscribers: mehdi_amini, cfe-commits Differential Revision: https://reviews.llvm.org/D28835 llvm-svn: 294933
OpenPOWER on IntegriCloud