summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
Commit message (Collapse)AuthorAgeFilesLines
* Merging r347261:Tom Stellard2018-11-281-1/+4
| | | | | | | | | | | | | | | | | | | | ------------------------------------------------------------------------ r347261 | vedantk | 2018-11-19 12:10:21 -0800 (Mon, 19 Nov 2018) | 11 lines [Sema] Fix PR38987: keep end location of a direct initializer list If PerformConstructorInitialization of a direct initializer list constructor is called while instantiating a template, it has brace locations in its BraceLoc arguments but not in the Kind argument. This reverts the hunk https://reviews.llvm.org/D41921#inline-468844. Patch by Orivej Desh! Differential Revision: https://reviews.llvm.org/D53231 ------------------------------------------------------------------------ llvm-svn: 347797
* Merging r341778:Tom Stellard2018-10-263-9/+7
| | | | | | | | | | | | | | ------------------------------------------------------------------------ r341778 | rsmith | 2018-09-09 23:35:32 -0700 (Sun, 09 Sep 2018) | 5 lines PR33222: Require the declared return type not the actual return type to match when checking for redeclaration of a function template. This properly handles differences in deduced return types, particularly when performing redeclaration checks for a friend function template. ------------------------------------------------------------------------ llvm-svn: 345412
* Merging r341775:Tom Stellard2018-10-261-19/+60
| | | | | | | | | | | ------------------------------------------------------------------------ r341775 | rsmith | 2018-09-09 22:32:13 -0700 (Sun, 09 Sep 2018) | 2 lines Part of PR33222: defer enforcing return type mismatch for dependent friend function declarations of class templates. ------------------------------------------------------------------------ llvm-svn: 345409
* Merging r339372, r339373, r339374, and r339379Hans Wennborg2018-08-211-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ------------------------------------------------------------------------ r339372 | steveire | 2018-08-09 22:05:03 +0200 (Thu, 09 Aug 2018) | 5 lines Add getBeginLoc API to replace getLocStart Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D50346 ------------------------------------------------------------------------ ------------------------------------------------------------------------ r339373 | steveire | 2018-08-09 22:05:18 +0200 (Thu, 09 Aug 2018) | 7 lines Add getBeginLoc API to replace getStartLoc Reviewers: teemperor! Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D50347 ------------------------------------------------------------------------ ------------------------------------------------------------------------ r339374 | steveire | 2018-08-09 22:05:47 +0200 (Thu, 09 Aug 2018) | 5 lines Add getEndLoc API to replace getLocEnd Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D50348 ------------------------------------------------------------------------ ------------------------------------------------------------------------ r339379 | steveire | 2018-08-09 22:21:09 +0200 (Thu, 09 Aug 2018) | 1 line Fix build ------------------------------------------------------------------------ llvm-svn: 340332
* Merging r340101:Reid Kleckner2018-08-171-0/+4
| | | | | | | | | | | | | | | | | | | | | | | ------------------------------------------------------------------------ r340101 | rnk | 2018-08-17 15:11:31 -0700 (Fri, 17 Aug 2018) | 14 lines Don't warn on returning the address of a label from a statement expression Summary: There isn't anything inherently wrong with returning a label from a statement expression. In practice, the Linux kernel uses this pattern to materialize PCs. Fixes PR38569 Reviewers: niravd, rsmith, nickdesaulniers Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D50805 ------------------------------------------------------------------------ llvm-svn: 340103
* Backport r339704 to 7.0 for PR38598Hans Wennborg2018-08-171-23/+4
| | | | | | | | | | | | | | | > Author: abataev > Date: Tue Aug 14 11:31:20 2018 > New Revision: 339704 > > URL: http://llvm.org/viewvc/llvm-project?rev=339704&view=rev > Log: > [OPENMP] Fix processing of declare target construct. > > The attribute marked as inheritable since OpenMP 5.0 supports it + > additional fixes to support new functionality. llvm-svn: 339998
* Merging r339603:Hans Wennborg2018-08-161-84/+185
| | | | | | | | | | | | | ------------------------------------------------------------------------ r339603 | abataev | 2018-08-13 21:04:24 +0200 (Mon, 13 Aug 2018) | 4 lines [OPENMP] Fix emission of the loop doacross constructs. The number of loops associated with the OpenMP loop constructs should not be considered as the number loops to collapse. ------------------------------------------------------------------------ llvm-svn: 339851
* Merging r339597:Hans Wennborg2018-08-141-4/+14
| | | | | | | | | | | | | | | | ------------------------------------------------------------------------ r339597 | erichkeane | 2018-08-13 20:33:20 +0200 (Mon, 13 Aug 2018) | 7 lines Enforce instantiation of template multiversion functions Multiversioned member functions inside of a template type were not properly being emitted. The solution to this is to simply ensure that their bodies are correctly evaluated/assigned during template instantiation. ------------------------------------------------------------------------ llvm-svn: 339663
* Merging r338934:Hans Wennborg2018-08-141-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ------------------------------------------------------------------------ r338934 | vsapsai | 2018-08-04 01:12:37 +0200 (Sat, 04 Aug 2018) | 29 lines [Preprocessor] Allow libc++ to detect when aligned allocation is unavailable. Libc++ needs to know when aligned allocation is supported by clang, but is otherwise unavailable at link time. Otherwise, libc++ will incorrectly end up generating calls to `__builtin_operator_new`/`__builtin_operator_delete` with alignment arguments. This patch implements the following changes: * The `__cpp_aligned_new` feature test macro to no longer be defined when aligned allocation is otherwise enabled but unavailable. * The Darwin driver no longer passes `-faligned-alloc-unavailable` when the user manually specifies `-faligned-allocation` or `-fno-aligned-allocation`. * Instead of a warning Clang now generates a hard error when an aligned allocation or deallocation function is referenced but unavailable. Patch by Eric Fiselier. Reviewers: rsmith, vsapsai, erik.pilkington, ahatanak, dexonsmith Reviewed By: rsmith Subscribers: Quuxplusone, cfe-commits Differential Revision: https://reviews.llvm.org/D45015 ------------------------------------------------------------------------ llvm-svn: 339660
* Merging r339210:Hans Wennborg2018-08-081-2/+8
| | | | | | | | | | | ------------------------------------------------------------------------ r339210 | rsmith | 2018-08-08 02:42:42 +0200 (Wed, 08 Aug 2018) | 2 lines PR38286: Don't crash when attempting to define a constructor for an incomplete class template. ------------------------------------------------------------------------ llvm-svn: 339236
* Merging r338749:Hans Wennborg2018-08-031-1/+5
| | | | | | | | | | | | | | | ------------------------------------------------------------------------ r338749 | mstorsjo | 2018-08-02 20:12:08 +0200 (Thu, 02 Aug 2018) | 6 lines Work around more GCC miscompiles exposed by r338464. This is the same fix as in r338478, for another occurrance of the same pattern from r338464. See gcc.gnu.org/PR86769 for details of the bug. ------------------------------------------------------------------------ llvm-svn: 338845
* Work around GCC miscompile exposed by r338464.Richard Smith2018-08-011-2/+5
| | | | | | See gcc.gnu.org/PR86769 for details of the bug. llvm-svn: 338478
* Speculative fix for buildbot failures after r338464.Richard Smith2018-08-011-1/+2
| | | | llvm-svn: 338473
* Avoid exposing name for range-based for '__range' variables in lifetime ↵Richard Smith2018-08-011-3/+5
| | | | | | warnings. llvm-svn: 338467
* [P0936R0] add [[clang::lifetimebound]] attributeRichard Smith2018-08-014-74/+202
| | | | | | | | | | | | | | | | | | | This patch adds support for a new attribute, [[clang::lifetimebound]], that indicates that the lifetime of a function result is related to one of the function arguments. When walking an initializer to make sure that the lifetime of the initial value is at least as long as the lifetime of the initialized object, we step through parameters (including the implicit object parameter of a non-static member function) that are marked with this attribute. There's nowhere to write an attribute on the implicit object parameter, so in lieu of that, it may be applied to a function type (where it appears immediately after the cv-qualifiers and ref-qualifier, which is as close to a declaration of the implicit object parameter as we have). I'm currently modeling this in the AST as the attribute appertaining to the function type. Differential Revision: https://reviews.llvm.org/D49922 llvm-svn: 338464
* [OpenCL] Forbid size dependent types used as kernel argumentsAlexey Sotkin2018-07-311-3/+43
| | | | | | | | | | | | | | | | | | | | Summary: Size_t, intptr_t, uintptr_t and ptrdiff_t cannot be used as kernel arguments, according to OpenCL Specification s6.9k: The size in bytes of these types are implementation-defined and in addition can also be different for the OpenCL device and the host processor making it difficult to allocate buffer objects to be passed as arguments to a kernel declared as pointer to these types. Patch by: Andrew Savonichev Reviewers: Anastasia, yaxunl Subscribers: yaxunl, Anastasia, cfe-commits Differential Revision: https://reviews.llvm.org/D49725 llvm-svn: 338432
* [OpenCL] Check for invalid kernel arguments in array typesAlexey Sotkin2018-07-311-5/+27
| | | | | | | | | | | | | | | | Summary: OpenCL specification forbids use of several types as kernel arguments. This patch improves existing diagnostic to look through arrays. Patch by: Andrew Savonichev Reviewers: Anastasia, yaxunl Subscribers: yaxunl, Anastasia, cfe-commits Differential Revision: https://reviews.llvm.org/D49723 llvm-svn: 338427
* Remove trailing spaceFangrui Song2018-07-3034-1509/+1509
| | | | | | sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} llvm-svn: 338291
* [CodeComplete] Fix the crash in code completion on access checkingIlya Biryukov2018-07-301-28/+2
| | | | | | | | | Started crashing in r337453. See the added test case for the crash repro. The fix reverts part of r337453 that causes the crash and does not actually break anything when reverted. llvm-svn: 338255
* PR38355 Prevent infinite recursion when checking initializer lifetime ifRichard Smith2018-07-301-1/+2
| | | | | | an initializer is self-referential. llvm-svn: 338230
* [Sema][ObjC] Warn when a method declared in a protocol takes aAkira Hatanaka2018-07-281-7/+41
| | | | | | | | | | | non-escaping parameter but the implementation's method takes an escaping parameter. rdar://problem/39548196 Differential Revision: https://reviews.llvm.org/D49119 llvm-svn: 338189
* [CUDA][HIP] Allow function-scope static const variableYaxun Liu2018-07-281-8/+19
| | | | | | | | | | | | | | | | | | | | | | CUDA 8.0 E.3.9.4 says: Within the body of a __device__ or __global__ function, only __shared__ variables or variables without any device memory qualifiers may be declared with static storage class. It is unclear how a function-scope non-const static variable without device memory qualifier is implemented, therefore only static const variable without device memory qualifier is allowed, which can be emitted as a global variable in constant address space. Currently clang only allows function-scope static variable with __shared__ qualifier. This patch also allows function-scope static const variable without device memory qualifier and emits it as a global variable in constant address space. Differential Revision: https://reviews.llvm.org/D49931 llvm-svn: 338188
* Compile SemaTemplate.cpp with /bigobj on MSVCErik Pilkington2018-07-281-0/+1
| | | | | | This should fix some bot failures introduced by r338165. llvm-svn: 338186
* [Sema] Use a TreeTransform to extract deduction guide parameter typesErik Pilkington2018-07-271-15/+25
| | | | | | | | | | | | | | | Previously, we just canonicalized the type, but this lead to crashes with parameter types that referred to ParmVarDecls of the constructor. There may be more cases that this TreeTransform needs to handle though, such as a constructor parameter type referring to a member in an unevaluated context. Canonicalization doesn't address these cases either though, so we can address them as-needed in follow-up commits. rdar://41330135 Differential revision: https://reviews.llvm.org/D49439 llvm-svn: 338165
* Add missing temporary materialization conversion on left-hand side of .Richard Smith2018-07-274-22/+26
| | | | | | | | | in some member function calls. Specifically, when calling a conversion function, we would fail to create the AST node representing materialization of the class object. llvm-svn: 338135
* [AST] Sink 'part of explicit cast' down into ImplicitCastExprRoman Lebedev2018-07-271-2/+2
| | | | | | | | | | | | | | | | | | | | | | | Summary: As discussed in IRC with @rsmith, it is slightly not good to keep that in the `CastExpr` itself: Given the explicit cast, which is represented in AST as an `ExplicitCastExpr` + `ImplicitCastExpr`'s, only the `ImplicitCastExpr`'s will be marked as `PartOfExplicitCast`, but not the `ExplicitCastExpr` itself. Thus, it is only ever `true` for `ImplicitCastExpr`'s, so we don't need to write/read/dump it for `ExplicitCastExpr`'s. We don't need to worry that we write the `PartOfExplicitCast` in PCH after `CastExpr::path_iterator`, since the `ExprImplicitCastAbbrev` is only used when the `NumBaseSpecs == 0`, i.e. there is no 'path'. Reviewers: rsmith, rjmccall, erichkeane, aaron.ballman Reviewed By: rsmith, erichkeane Subscribers: vsk, cfe-commits, rsmith Tags: #clang Differential Revision: https://reviews.llvm.org/D49838 llvm-svn: 338108
* [Sema] Fix a crash by completing a type before using itErik Pilkington2018-07-261-0/+1
| | | | | | | | | | Only apply this exception on a type that we're able to check. rdar://41903969 Differential revision: https://reviews.llvm.org/D49868 llvm-svn: 338089
* [MS] Add L__FUNCSIG__ for compatibilityReid Kleckner2018-07-261-2/+3
| | | | | | | | | | Clang already has L__FUNCTION__ as a workaround for dealing with pre-processor code that expects to be able to do L##__FUNCTION__ in a macro. This patch implements the same logic for __FUNCSIG__. Fixes PR38295. llvm-svn: 338083
* [ARM64] [Windows] Follow MS X86_64 C++ ABI when passing structsSanjin Sijaric2018-07-261-1/+1
| | | | | | | | | | | | | | | | | Summary: Microsoft's C++ object model for ARM64 is the same as that for X86_64. For example, small structs with non-trivial copy constructors or virtual function tables are passed indirectly. Currently, they are passed in registers when compiled with clang. Reviewers: rnk, mstorsjo, TomTan, haripul, javed.absar Reviewed By: rnk, mstorsjo Subscribers: kristof.beyls, chrib, llvm-commits, cfe-commits Differential Revision: https://reviews.llvm.org/D49770 llvm-svn: 338076
* Refactor checking of switch conditions and case values.Richard Smith2018-07-263-131/+122
| | | | | | | | | | | | | | | | | | | Check each case value in turn while parsing it, performing the conversion to the switch type within the context of the expression itself. This will become necessary in order to properly handle cleanups for temporaries created as part of the case label (in an upcoming patch). For now it's just good hygiene. This necessitates moving the checking for the switch condition itself to earlier, so that the destination type is available when checking the case labels. As a nice side-effect, we get slightly improved diagnostic quality and error recovery by separating the case expression checking from the case statement checking and from tracking whether there are discarded case labels. llvm-svn: 338056
* [Sema][ObjC] Do not propagate the nullability specifier on the receiverAkira Hatanaka2018-07-261-0/+5
| | | | | | | | | | | | | | | | | | to the result type of a message send if the result type cannot have a nullability specifier. Previously, clang would print the following message when the code in nullability.m was compiled: "incompatible integer to pointer conversion initializing 'int *' with an expression of type 'int _Nullable'" This is wrong as 'int' isn't supposed to have any nullability specifiers. rdar://problem/40830514 llvm-svn: 338048
* [RISCV] Add support for interrupt attributeAna Pazos2018-07-261-0/+62
| | | | | | | | | | | | | | | | | | | Summary: Clang supports the GNU style ``__attribute__((interrupt))`` attribute on RISCV targets. Permissible values for this parameter are user, supervisor, and machine. If there is no parameter, then it defaults to machine. Reference: https://gcc.gnu.org/onlinedocs/gcc/RISC-V-Function-Attributes.html Based on initial patch by Zhaoshi Zheng. Reviewers: asb, aaron.ballman Reviewed By: asb, aaron.ballman Subscribers: rkruppe, the_o, aaron.ballman, MartinMosbeck, brucehoult, rbar, johnrusso, simoncook, sabuasal, niosHD, kito-cheng, shiva0217, zzheng, edward-jones, mgrang, rogfer01, cfe-commits Differential Revision: https://reviews.llvm.org/D48412 llvm-svn: 338045
* [clang:sema] de-duplicate getDepthAndIndex helpersNick Desaulniers2018-07-253-49/+0
| | | | | | | | | | | | | | | | | | | Summary: Continuing off of: https://reviews.llvm.org/D38382 Fixes: https://bugs.llvm.org/show_bug.cgi?id=12176 Reviewers: srhines, pirama, vsk Reviewed By: vsk Subscribers: cfe-commits, vsk, maitesin Differential Revision: https://reviews.llvm.org/D49760 llvm-svn: 337944
* [OPENMP] Fix PR38256: Fix locations of the artificial conditional op.Alexey Bataev2018-07-251-1/+2
| | | | | | | Fixed the source locations of the conditional op so that they don'r crash coverage pass. llvm-svn: 337928
* [Sema] Mark implicitly-inserted ICE's as being part of explicit cast (PR38166)Roman Lebedev2018-07-241-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: As discussed in [[ https://bugs.llvm.org/show_bug.cgi?id=38166 | PR38166 ]], we need to be able to distinqush whether the cast we are visiting is actually a cast, or part of an `ExplicitCast`. There are at least four ways to get there: 1. Introduce a new `CastKind`, and use it instead of `IntegralCast` if we are in `ExplicitCast`. Would work, but does not scale - what if we will need more of these cast kinds? 2. Introduce a flag in `CastExprBits`, whether this cast is part of `ExplicitCast` or not. Would work, but it isn't immediately clear where it needs to be set. 2. Fix `ScalarExprEmitter::VisitCastExpr()` to visit these `NoOp` casts. As pointed out by @rsmith, CodeGenFunction::EmitMaterializeTemporaryExpr calls skipRValueSubobjectAdjustments, which steps over the CK_NoOp cast`, which explains why we currently don't visit those. This is probably impossible, as @efriedma points out, that is intentional as per `[class.temporary]` in the standard 3. And the simplest one, just record which NoOp casts we skip. It just kinda works as-is afterwards. But, the approach with a flag is the least intrusive one, and is probably the best one overall. Reviewers: rsmith, rjmccall, majnemer, efriedma Reviewed By: rsmith Subscribers: cfe-commits, aaron.ballman, vsk, llvm-commits, rsmith Differential Revision: https://reviews.llvm.org/D49508 llvm-svn: 337815
* Fix unused variable warnings; NFCGeorge Burgess IV2018-07-241-2/+2
| | | | | | | Looks like MTE was previously used for its SourceLoc, but we're now using a seperate SourceLocation here. llvm-svn: 337796
* Warn if a local variable's initializer retains a pointer/reference to aRichard Smith2018-07-241-73/+37
| | | | | | non-lifetime-extended temporary object. llvm-svn: 337790
* Support lifetime-extension of conditional temporaries.Richard Smith2018-07-231-8/+1
| | | | llvm-svn: 337767
* [Sema] Fix crash on BlockExprs in a default member initializersErik Pilkington2018-07-231-0/+5
| | | | | | | | | | | | Clang would crash when instantiating a BlockDecl that appeared in a default-member-initializer of a class template. Fix this by deferring the instantiation until we instantate the BlockExpr. rdar://41200624 Differential revision: https://reviews.llvm.org/D49688 llvm-svn: 337766
* Do not try to perform lifetime-extension through conditionalRichard Smith2018-07-231-20/+39
| | | | | | | | | expressions. CodeGen can't cope with that yet. Instead, produce a "not supported" warning for now and don't extend lifetime. llvm-svn: 337744
* Fold -Wreturn-stack-address into general initialization lifetimeRichard Smith2018-07-232-527/+318
| | | | | | checking. llvm-svn: 337743
* Update to -r337585, allow scoped enum inits in -pedanticErich Keane2018-07-231-0/+3
| | | | llvm-svn: 337738
* Separate out the initialization kind for a statement expression resultRichard Smith2018-07-232-6/+25
| | | | | | | | | | from that for a return value. No functionality change intended: I don't believe any of the diagnostics affected by this patch are reachable when initializing the result of statement expression. llvm-svn: 337728
* Fold dangling-field warning into general initialization lifetime checks.Richard Smith2018-07-232-134/+177
| | | | | | | This reinstates r337627, reverted in r337671, with a fix to correctly handle the lvalueness of array subscript expressions on pointers. llvm-svn: 337726
* [Sema] Don't emit -Wmemset-transposed-args for memset(p,0,0)Erik Pilkington2018-07-231-3/+6
| | | | | | Thanks to Arthur O'Dwyer for the suggestion! llvm-svn: 337706
* Revert "Fold dangling-field warning into general initialization lifetime ↵Ilya Biryukov2018-07-232-170/+131
| | | | | | | | | | | | | | | | checks." This reverts commit r337627. After the change, clang started producing invalid warning on the following code: struct foo { foo(char *x) : x_(&x[10]) {} private: char *x_; }; 1.cpp:2:21: warning: initializing pointer member 'x_' with the stack address of parameter 'x' [-Wdangling-field] llvm-svn: 337671
* PR38257: don't perform ADL when instantiating a unary & operator that turns outRichard Smith2018-07-222-4/+6
| | | | | | to be forming a pointer-to-member. llvm-svn: 337653
* Fold dangling-field warning into general initialization lifetime checks.Richard Smith2018-07-202-131/+170
| | | | llvm-svn: 337627
* Implement cpu_dispatch/cpu_specific MultiversioningErich Keane2018-07-206-152/+474
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As documented here: https://software.intel.com/en-us/node/682969 and https://software.intel.com/en-us/node/523346. cpu_dispatch multiversioning is an ICC feature that provides for function multiversioning. This feature is implemented with two attributes: First, cpu_specific, which specifies the individual function versions. Second, cpu_dispatch, which specifies the location of the resolver function and the list of resolvable functions. This is valuable since it provides a mechanism where the resolver's TU can be specified in one location, and the individual implementions each in their own translation units. The goal of this patch is to be source-compatible with ICC, so this implementation diverges from the ICC implementation in a few ways: 1- Linux x86/64 only: This implementation uses ifuncs in order to properly dispatch functions. This is is a valuable performance benefit over the ICC implementation. A future patch will be provided to enable this feature on Windows, but it will obviously more closely fit ICC's implementation. 2- CPU Identification functions: ICC uses a set of custom functions to identify the feature list of the host processor. This patch uses the cpu_supports functionality in order to better align with 'target' multiversioning. 1- cpu_dispatch function def/decl: ICC's cpu_dispatch requires that the function marked cpu_dispatch be an empty definition. This patch supports that as well, however declarations are also permitted, since the linker will solve the issue of multiple emissions. Differential Revision: https://reviews.llvm.org/D47474 llvm-svn: 337552
* Sema: Fix explicit address space cast in C++Yaxun Liu2018-07-202-0/+17
| | | | | | | | | | | | | | | | | | | | | Currently clang does not allow implicit cast of a pointer to a pointer type in different address space but allows C-style cast of a pointer to a pointer type in different address space. However, there is a bug in Sema causing incorrect Cast Expr in AST for the latter case, which in turn results in invalid LLVM IR in codegen. This is because Sema::IsQualificationConversion returns true for a cast of pointer to a pointer type in different address space, which in turn allows a standard conversion and results in a cast expression with no op in AST. This patch fixes that by let Sema::IsQualificationConversion returns false for a cast of pointer to a pointer type in different address space, which in turn disallows standard conversion, implicit cast, and static cast. Finally it results in an reinterpret cast and correct conversion kind is set. Differential Revision: https://reviews.llvm.org/D49294 llvm-svn: 337540
OpenPOWER on IntegriCloud