aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/Sema.cpp
AgeCommit message (Collapse)AuthorFilesLines
2022-01-04CUDA/HIP: Allow __int128 on the host sideHenry Linjamäki1-1/+2
Consider case where `__int128` type is supported by the host target but not by a device target (e.g. spirv*). Clang emits an error message for unsupported type even if the device code does not use it. This patch fixes this issue by emitting the error message when the device code attempts to use the unsupported type. Reviewed By: tra Differential Revision: https://reviews.llvm.org/D111047
2021-12-29[SYCL] Diagnose uses of zero length arraysMariya Podchishchaeva1-0/+9
Adds diagnosing on attempt to use zero length arrays, pointers, refs, arrays of them and structs/classes containing all of it. In case a struct/class with zero length array is used this emits a set of notes pointing out how zero length array got into used struct, like this: ``` struct ContainsArr { int A[0]; // note: field of illegal type declared here }; struct Wrapper { ContainsArr F; // note: within field of type ContainsArr declared here // ... } // Device code Wrapper W; W.use(); // error: zero-length arrays are not permitted ``` Total deep check of each used declaration may result in double diagnosing at the same location. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D114080
2021-12-10Revert "[X86][clang] Emit diagnostic for float and double when we have ↵Phoebe Wang1-1/+9
features -x87 and -sse on 64-bits" This reverts commit 4a2c827b178f89d4cdeb56153d9440ad4ba786a3. Need to fix the problem when using `-mno-sse` together with "x86intrin.h"
2021-12-08[X86][clang] Emit diagnostic for float and double when we have features -x87 ↵Phoebe Wang1-9/+1
and -sse on 64-bits A follow up of D114162. Reviewed By: asavonic Differential Revision: https://reviews.llvm.org/D114782
2021-12-06Introduce _BitInt, deprecate _ExtIntAaron Ballman1-2/+2
WG14 adopted the _ExtInt feature from Clang for C23, but renamed the type to be _BitInt. This patch does the vast majority of the work to rename _ExtInt to _BitInt, which accounts for most of its size. The new type is exposed in older C modes and all C++ modes as a conforming extension. However, there are functional changes worth calling out: * Deprecates _ExtInt with a fix-it to help users migrate to _BitInt. * Updates the mangling for the type. * Updates the documentation and adds a release note to warn users what is going on. * Adds new diagnostics for use of _BitInt to call out when it's used as a Clang extension or as a pre-C23 compatibility concern. * Adds new tests for the new diagnostic behaviors. I want to call out the ABI break specifically. We do not believe that this break will cause a significant imposition for early adopters of the feature, and so this is being done as a full break. If it turns out there are critical uses where recompilation is not an option for some reason, we can consider using ABI tags to ease the transition.
2021-11-03[X86][clang] Disable long double type for -mno-x87 optionAndrew Savonichev1-8/+47
This patch attempts to fix a compiler crash that occurs when long double type is used with -mno-x87 compiler option. The option disables x87 target feature, which in turn disables x87 registers, so CG cannot select them for x86_fp80 LLVM IR type. Long double is lowered as x86_fp80 for some targets, so it leads to a crash. The option seems to contradict the SystemV ABI, which requires long double to be represented as a 80-bit floating point, and it also requires to use x87 registers. To avoid that, `long double` type is disabled when -mno-x87 option is set. In addition to that, `float` and `double` also use x87 registers for return values on 32-bit x86, so they are disabled as well. Differential Revision: https://reviews.llvm.org/D98895
2021-10-15Reland [clang] Check unsupported types in expressionsAndrew Savonichev1-12/+29
This was committed as ec6c847179fd, but then reverted after a failure in: https://lab.llvm.org/buildbot/#/builders/84/builds/13983 I was not able to reproduce the problem, but I added an extra check for a NULL QualType just in case. Original comit message: The patch adds missing diagnostics for cases like: float F3 = ((__float128)F1 * (__float128)F2) / 2.0f; Sema::checkDeviceDecl (renamed to checkTypeSupport) is changed to work with a type without the corresponding ValueDecl. It is also refactored so that host diagnostics for unsupported types can be added here as well. Differential Revision: https://reviews.llvm.org/D109315
2021-10-12[OpenCL] Add atomic_half type builtinsSven van Haastregt1-0/+5
Add atomic_half types and builtins operating on the types from the cl_ext_float_atomics extension. Patch by Haonan Yang. Differential Revision: https://reviews.llvm.org/D109740
2021-10-08[clang] Set max allowed alignment to 2^32Arthur Eubanks1-1/+1
Followup to D110451 which set LLVM's max allowed alignment to 2^32. Reviewed By: hans Differential Revision: https://reviews.llvm.org/D111250
2021-10-05[PowerPC][MMA] Allow MMA builtin types in pre-P10 compilation unitsKamau Bridgeman1-4/+1
This patch allows the use of __vector_quad and __vector_pair, PPC MMA builtin types, on all PowerPC 64-bit compilation units. When these types are made available the builtins that use them automatically become available so semantic checking for mma and pair vector memop __builtins is also expanded to ensure these builtin function call are only allowed on Power10 and new architectures. All related test cases are updated to ensure test coverage. Reviewed By: #powerpc, nemanjai Differential Revision: https://reviews.llvm.org/D109599
2021-09-21[clang] don't mark as Elidable CXXConstruct expressions used in NRVOMatheus Izvekov1-1/+1
See PR51862. The consumers of the Elidable flag in CXXConstructExpr assume that an elidable construction just goes through a single copy/move construction, so that the source object is immediately passed as an argument and is the same type as the parameter itself. With the implementation of P2266 and after some adjustments to the implementation of P1825, we started (correctly, as per standard) allowing more cases where the copy initialization goes through user defined conversions. With this patch we stop using this flag in NRVO contexts, to preserve code that relies on that assumption. This causes no known functional changes, we just stop firing some asserts in a cople of included test cases. Reviewed By: rsmith Differential Revision: https://reviews.llvm.org/D109800
2021-09-21[OpenCL] Defines helper function for OpenCL default address spaceJustas Janickas1-1/+1
Helper function `getDefaultOpenCLPointeeAddrSpace()` introduced to `ASTContext` class. It returns default OpenCL address space depending on language version and enabled features. If generic address space is supported, the helper function returns value `LangAS::opencl_generic`. Otherwise, value `LangAS::opencl_private` is returned. Code refactoring changes performed in several suitable places. Differential Revision: https://reviews.llvm.org/D109874
2021-09-17[Clang] Fix long double availability checkQiu Chaofan1-2/+4
fae0dfa changed code to check 128-bit float availability, since it introduced a new 128-bit double type on PowerPC. However, there're other long float types besides IEEE float128 and PPC double-double requiring this feature. Reviewed By: ronlieb Differential Revision: https://reviews.llvm.org/D109943
2021-09-13Revert "[clang] Check unsupported types in expressions"Andrew Savonichev1-28/+11
This reverts commit ec6c847179fd019acae4d97a18f9e7d3961a6fdf. Fails on check-openmp: /b/1/openmp-clang-x86_64-linux-debian/llvm.build/projects/openmp/runtime/test/lock/Output/omp_init_lock.c.tmp -- Exit Code: -11
2021-09-13[clang] Check unsupported types in expressionsAndrew Savonichev1-11/+28
The patch adds missing diagnostics for cases like: float F3 = ((__float128)F1 * (__float128)F2) / 2.0f; Sema::checkDeviceDecl (renamed to checkTypeSupport) is changed to work with a type without the corresponding ValueDecl. It is also refactored so that host diagnostics for unsupported types can be added here as well. Differential Revision: https://reviews.llvm.org/D109315
2021-09-06[Clang] Add __ibm128 type to represent ppc_fp128Qiu Chaofan1-4/+14
Currently, we have no front-end type for ppc_fp128 type in IR. PowerPC target generates ppc_fp128 type from long double now, but there's option (-mabi=(ieee|ibm)longdouble) to control it and we're going to do transition from IBM extended double-double ppc_fp128 to IEEE fp128 in the future. This patch adds type __ibm128 which always represents ppc_fp128 in IR, as what GCC did for that type. Without this type in Clang, compilation will fail if compiling against future version of libstdcxx (which uses __ibm128 in headers). Although all operations in backend for __ibm128 is done by software, only PowerPC enables support for it. There's something not implemented in this commit, which can be done in future ones: - Literal suffix for __ibm128 type. w/W is suitable as GCC documented. - __attribute__((mode(IF))) should be for __ibm128. - Complex __ibm128 type. Reviewed By: rjmccall Differential Revision: https://reviews.llvm.org/D93377
2021-09-01Revert "[CLANG][PATCH][FPEnv] Add support for option -ffp-eval-method and ↵Zahira Ammarguellat1-17/+0
extend #pragma float_control similarly" The intent of this patch is to add support of -fp-model=[source|double|extended] to allow the compiler to use a wider type for intermediate floating point calculations. As a side effect to that, the value of FLT_EVAL_METHOD is changed according to the pragma float_control. Unfortunately some issue was uncovered with this change in preprocessing. See details in https://reviews.llvm.org/D93769 . We are therefore reverting this patch until we find a way to reconcile the value of FLT_EVAL_METHOD, the pragma and the -E flow. This reverts commit 66ddac22e2a7f268e91c26d694112970dfa607ae.
2021-08-31[OpenCL] Defines helper function for kernel language compatible OpenCL versionJustas Janickas1-1/+1
This change defines a helper function getOpenCLCompatibleVersion() inside LangOptions class. The function contains mapping between C++ for OpenCL versions and their corresponding compatible OpenCL versions. This mapping function should be updated each time a new C++ for OpenCL language version is introduced. The helper function is expected to simplify conditions on OpenCL C and C++ for OpenCL versions inside compiler code. Code refactoring performed. Differential Revision: https://reviews.llvm.org/D108693
2021-07-30[OpenCL] Add support of __opencl_c_pipes feature macro.Anton Zabaznov1-1/+2
'pipe' keyword is introduced in OpenCL C 2.0: so do checks for OpenCL C version while parsing and then later on check for language options to construct actual pipe. This feature requires support of __opencl_c_generic_address_space, so diagnostics for that is provided as well. This is the same patch as in D106748 but with a tiny fix in checking of diagnostic messages. Also added tests when program scope global variables are not supported. Reviewed By: Anastasia Differential Revision: https://reviews.llvm.org/D107154
2021-07-30Revert "[OpenCL] Add support of __opencl_c_pipes feature macro."Anton Zabaznov1-2/+1
This reverts commit d1e4b25756730576996457ba7324e9bf210e3693.
2021-07-30[OpenCL] Add support of __opencl_c_pipes feature macro.Anton Zabaznov1-1/+2
'pipe' keyword is introduced in OpenCL C 2.0: so do checks for OpenCL C version while parsing and then later on check for language options to construct actual pipe. This feature requires support of __opencl_c_generic_address_space, so diagnostics for that is provided as well. Reviewed By: Anastasia Differential Revision: https://reviews.llvm.org/D106748
2021-07-28[CLANG][PATCH][FPEnv] Add support for option -ffp-eval-method and extend ↵Melanie Blower1-0/+17
#pragma float_control similarly The Intel compiler ICC supports the option "-fp-model=(source|double|extended)" which causes the compiler to use a wider type for intermediate floating point calculations. Also supported is a way to embed this effect in the source program with #pragma float_control(source|double|extended). This patch extends pragma float_control syntax, and also adds support for a new floating point option "-ffp-eval-method=(source|double|extended)". source: intermediate results use source precision double: intermediate results use double precision extended: intermediate results use extended precision Reviewed By: Aaron Ballman Differential Revision: https://reviews.llvm.org/D93769
2021-07-28[clang] NFC: change uses of `Expr->getValueKind` into `is?Value`Matheus Izvekov1-1/+1
Signed-off-by: Matheus Izvekov <mizvekov@gmail.com> Reviewed By: rsmith Differential Revision: https://reviews.llvm.org/D100733
2021-07-22Correctly diagnose taking the address of a register variable in CAaron Ballman1-10/+30
We caught the cases where the user would explicitly use the & operator, but we were missing implicit conversions such as array decay. Fixes PR26336. Thanks to Samuel Neves for inspiration for the patch.
2021-07-21[clang][darwin] add support for remapping macOS availability to Mac Catalyst ↵Alex Lorenz1-0/+22
availability This commit adds supports for clang to remap macOS availability attributes that have introduced, deprecated or obsoleted versions to appropriate Mac Catalyst availability attributes. This mapping is done using the version mapping provided in the macOS SDK, in the SDKSettings.json file. The mappings in the SDKSettings json file will also be used in the clang driver for the driver Mac Catalyst patch, and they could also be used in the future for other platforms as well. Differential Revision: https://reviews.llvm.org/D105257
2021-07-20Revert "[CLANG][PATCH][FPEnv] Add support for option -ffp-eval-method and ↵Melanie Blower1-17/+0
extend #pragma float_control similarly" This reverts commit ce8024e8ff76e7be8b9ffa1a39d1dc9310bf74c7. There are a couple buildbot problems
2021-07-20[CLANG][PATCH][FPEnv] Add support for option -ffp-eval-method and extend ↵Melanie Blower1-0/+17
#pragma float_control similarly The Intel compiler ICC supports the option "-fp-model=(source|double|extended)" which causes the compiler to use a wider type for intermediate floating point calculations. Also supported is a way to embed this effect in the source program with #pragma float_control(source|double|extended). This patch extends pragma float_control syntax, and also adds support for a new floating point option "-ffp-eval-method=(source|double|extended)". source: intermediate results use source precision double: intermediate results use double precision extended: intermediate results use extended precision Reviewed By: Aaron Ballman Differential Revision: https://reviews.llvm.org/D93769
2021-07-12Reland "[clang-repl] Implement partial translation units and error recovery."Vassil Vassilev1-0/+1
Original commit message: [clang-repl] Implement partial translation units and error recovery. https://reviews.llvm.org/D96033 contained a discussion regarding efficient modeling of error recovery. @rjmccall has outlined the key ideas: Conceptually, we can split the translation unit into a sequence of partial translation units (PTUs). Every declaration will be associated with a unique PTU that owns it. The first key insight here is that the owning PTU isn't always the "active" (most recent) PTU, and it isn't always the PTU that the declaration "comes from". A new declaration (that isn't a redeclaration or specialization of anything) does belong to the active PTU. A template specialization, however, belongs to the most recent PTU of all the declarations in its signature - mostly that means that it can be pulled into a more recent PTU by its template arguments. The second key insight is that processing a PTU might extend an earlier PTU. Rolling back the later PTU shouldn't throw that extension away. For example, if the second PTU defines a template, and the third PTU requires that template to be instantiated at float, that template specialization is still part of the second PTU. Similarly, if the fifth PTU uses an inline function belonging to the fourth, that definition still belongs to the fourth. When we go to emit code in a new PTU, we map each declaration we have to emit back to its owning PTU and emit it in a new module for just the extensions to that PTU. We keep track of all the modules we've emitted for a PTU so that we can unload them all if we decide to roll it back. Most declarations/definitions will only refer to entities from the same or earlier PTUs. However, it is possible (primarily by defining a previously-declared entity, but also through templates or ADL) for an entity that belongs to one PTU to refer to something from a later PTU. We will have to keep track of this and prevent unwinding to later PTU when we recognize it. Fortunately, this should be very rare; and crucially, we don't have to do the bookkeeping for this if we've only got one PTU, e.g. in normal compilation. Otherwise, PTUs after the first just need to record enough metadata to be able to revert any changes they've made to declarations belonging to earlier PTUs, e.g. to redeclaration chains or template specialization lists. It should even eventually be possible for PTUs to provide their own slab allocators which can be thrown away as part of rolling back the PTU. We can maintain a notion of the active allocator and allocate things like Stmt/Expr nodes in it, temporarily changing it to the appropriate PTU whenever we go to do something like instantiate a function template. More care will be required when allocating declarations and types, though. We would want the PTU to be efficiently recoverable from a Decl; I'm not sure how best to do that. An easy option that would cover most declarations would be to make multiple TranslationUnitDecls and parent the declarations appropriately, but I don't think that's good enough for things like member function templates, since an instantiation of that would still be parented by its original class. Maybe we can work this into the DC chain somehow, like how lexical DCs are. We add a different kind of translation unit `TU_Incremental` which is a complete translation unit that we might nonetheless incrementally extend later. Because it is complete (and we might want to generate code for it), we do perform template instantiation, but because it might be extended later, we don't warn if it declares or uses undefined internal-linkage symbols. This patch teaches clang-repl how to recover from errors by disconnecting the most recent PTU and update the primary PTU lookup tables. For instance: ```./clang-repl clang-repl> int i = 12; error; In file included from <<< inputs >>>:1: input_line_0:1:13: error: C++ requires a type specifier for all declarations int i = 12; error; ^ error: Parsing failed. clang-repl> int i = 13; extern "C" int printf(const char*,...); clang-repl> auto r1 = printf("i=%d\n", i); i=13 clang-repl> quit ``` Differential revision: https://reviews.llvm.org/D104918
2021-07-11Revert "[clang-repl] Implement partial translation units and error recovery."Vassil Vassilev1-1/+0
This reverts commit 6775fc6ffa3ca1c36b20c25fa4e7f48f81213cf2. It also reverts "[lldb] Fix compilation by adjusting to the new ASTContext signature." This reverts commit 03a3f86071c10a1f6cbbf7375aa6fe9d94168972. We see some failures on the lldb infrastructure, these changes might play a role in it. Let's revert it now and see if the bots will become green. Ref: https://reviews.llvm.org/D104918
2021-07-11[clang-repl] Implement partial translation units and error recovery.Vassil Vassilev1-0/+1
https://reviews.llvm.org/D96033 contained a discussion regarding efficient modeling of error recovery. @rjmccall has outlined the key ideas: Conceptually, we can split the translation unit into a sequence of partial translation units (PTUs). Every declaration will be associated with a unique PTU that owns it. The first key insight here is that the owning PTU isn't always the "active" (most recent) PTU, and it isn't always the PTU that the declaration "comes from". A new declaration (that isn't a redeclaration or specialization of anything) does belong to the active PTU. A template specialization, however, belongs to the most recent PTU of all the declarations in its signature - mostly that means that it can be pulled into a more recent PTU by its template arguments. The second key insight is that processing a PTU might extend an earlier PTU. Rolling back the later PTU shouldn't throw that extension away. For example, if the second PTU defines a template, and the third PTU requires that template to be instantiated at float, that template specialization is still part of the second PTU. Similarly, if the fifth PTU uses an inline function belonging to the fourth, that definition still belongs to the fourth. When we go to emit code in a new PTU, we map each declaration we have to emit back to its owning PTU and emit it in a new module for just the extensions to that PTU. We keep track of all the modules we've emitted for a PTU so that we can unload them all if we decide to roll it back. Most declarations/definitions will only refer to entities from the same or earlier PTUs. However, it is possible (primarily by defining a previously-declared entity, but also through templates or ADL) for an entity that belongs to one PTU to refer to something from a later PTU. We will have to keep track of this and prevent unwinding to later PTU when we recognize it. Fortunately, this should be very rare; and crucially, we don't have to do the bookkeeping for this if we've only got one PTU, e.g. in normal compilation. Otherwise, PTUs after the first just need to record enough metadata to be able to revert any changes they've made to declarations belonging to earlier PTUs, e.g. to redeclaration chains or template specialization lists. It should even eventually be possible for PTUs to provide their own slab allocators which can be thrown away as part of rolling back the PTU. We can maintain a notion of the active allocator and allocate things like Stmt/Expr nodes in it, temporarily changing it to the appropriate PTU whenever we go to do something like instantiate a function template. More care will be required when allocating declarations and types, though. We would want the PTU to be efficiently recoverable from a Decl; I'm not sure how best to do that. An easy option that would cover most declarations would be to make multiple TranslationUnitDecls and parent the declarations appropriately, but I don't think that's good enough for things like member function templates, since an instantiation of that would still be parented by its original class. Maybe we can work this into the DC chain somehow, like how lexical DCs are. We add a different kind of translation unit `TU_Incremental` which is a complete translation unit that we might nonetheless incrementally extend later. Because it is complete (and we might want to generate code for it), we do perform template instantiation, but because it might be extended later, we don't warn if it declares or uses undefined internal-linkage symbols. This patch teaches clang-repl how to recover from errors by disconnecting the most recent PTU and update the primary PTU lookup tables. For instance: ```./clang-repl clang-repl> int i = 12; error; In file included from <<< inputs >>>:1: input_line_0:1:13: error: C++ requires a type specifier for all declarations int i = 12; error; ^ error: Parsing failed. clang-repl> int i = 13; extern "C" int printf(const char*,...); clang-repl> auto r1 = printf("i=%d\n", i); i=13 clang-repl> quit ``` Differential revision: https://reviews.llvm.org/D104918
2021-06-23[HIP] Defer operator overloading errorsYaxun (Sam) Liu1-1/+1
Although clang is able to defer overloading resolution diagnostics for common functions. It does not defer overloading resolution caused diagnostics for overloaded operators. This patch extends the existing deferred diagnostic mechanism and defers a diagnostic caused by overloaded operator. Reviewed by: Artem Belevich Differential Revision: https://reviews.llvm.org/D104505
2021-06-18[clang] Implement P2266 Simpler implicit moveMatheus Izvekov1-3/+11
This Implements [[http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2266r1.html|P2266 Simpler implicit move]]. Signed-off-by: Matheus Izvekov <mizvekov@gmail.com> Reviewed By: Quuxplusone Differential Revision: https://reviews.llvm.org/D99005
2021-06-17[clang] NRVO: Improvements and handling of more cases.Matheus Izvekov1-2/+6
This expands NRVO propagation for more cases: Parse analysis improvement: * Lambdas and Blocks with dependent return type can have their variables marked as NRVO Candidates. Variable instantiation improvements: * Fixes crash when instantiating NRVO variables in Blocks. * Functions, Lambdas, and Blocks which have auto return type have their variables' NRVO status propagated. For Blocks with non-auto return type, as a limitation, this propagation does not consider the actual return type. This also implements exclusion of VarDecls which are references to dependent types. Signed-off-by: Matheus Izvekov <mizvekov@gmail.com> Reviewed By: Quuxplusone Differential Revision: https://reviews.llvm.org/D99696
2021-06-14Revert "[clang] NRVO: Improvements and handling of more cases."Hans Wennborg1-4/+3
This change caused build errors related to move-only __block variables, see discussion on https://reviews.llvm.org/D99696 > This expands NRVO propagation for more cases: > > Parse analysis improvement: > * Lambdas and Blocks with dependent return type can have their variables > marked as NRVO Candidates. > > Variable instantiation improvements: > * Fixes crash when instantiating NRVO variables in Blocks. > * Functions, Lambdas, and Blocks which have auto return type have their > variables' NRVO status propagated. For Blocks with non-auto return type, > as a limitation, this propagation does not consider the actual return > type. > > This also implements exclusion of VarDecls which are references to > dependent types. > > Signed-off-by: Matheus Izvekov <mizvekov@gmail.com> > > Reviewed By: Quuxplusone > > Differential Revision: https://reviews.llvm.org/D99696 This also reverts the follow-on change which was hard to tease apart form the one above: > "[clang] Implement P2266 Simpler implicit move" > > This Implements [[http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2266r1.html|P2266 Simpler implicit move]]. > > Signed-off-by: Matheus Izvekov <mizvekov@gmail.com> > > Reviewed By: Quuxplusone > > Differential Revision: https://reviews.llvm.org/D99005 This reverts commits 1e50c3d785f4563873ab1ce86559f2a1285b5678 and bf20631782183cd19e0bb7219e908c2bbb01a75f.
2021-06-12[clang] NRVO: Improvements and handling of more cases.Matheus Izvekov1-3/+4
This expands NRVO propagation for more cases: Parse analysis improvement: * Lambdas and Blocks with dependent return type can have their variables marked as NRVO Candidates. Variable instantiation improvements: * Fixes crash when instantiating NRVO variables in Blocks. * Functions, Lambdas, and Blocks which have auto return type have their variables' NRVO status propagated. For Blocks with non-auto return type, as a limitation, this propagation does not consider the actual return type. This also implements exclusion of VarDecls which are references to dependent types. Signed-off-by: Matheus Izvekov <mizvekov@gmail.com> Reviewed By: Quuxplusone Differential Revision: https://reviews.llvm.org/D99696
2021-06-11Referencing a static function defined in an opnemp clause, isZahira Ammarguellat1-2/+15
generating an erroneous warning. See here: https://godbolt.org/z/ajKPc36M7
2021-06-10Revert "[clang] NRVO: Improvements and handling of more cases."Arthur Eubanks1-4/+3
This reverts commit 667fbcdd0b2ee5e78f5ce9789b862e3bbca94644. Causes crashes on a stage 2 build on Windows.
2021-06-10[clang] NRVO: Improvements and handling of more cases.Matheus Izvekov1-3/+4
This expands NRVO propagation for more cases: Parse analysis improvement: * Lambdas and Blocks with dependent return type can have their variables marked as NRVO Candidates. Variable instantiation improvements: * Fixes crash when instantiating NRVO variables in Blocks. * Functions, Lambdas, and Blocks which have auto return type have their variables' NRVO status propagated. For Blocks with non-auto return type, as a limitation, this propagation does not consider the actual return type. This also implements exclusion of VarDecls which are references to dependent types. Signed-off-by: Matheus Izvekov <mizvekov@gmail.com> Reviewed By: Quuxplusone Differential Revision: https://reviews.llvm.org/D99696
2021-06-09[clang] NFC: Rename rvalue to prvalueMatheus Izvekov1-8/+9
This renames the expression value categories from rvalue to prvalue, keeping nomenclature consistent with C++11 onwards. C++ has the most complicated taxonomy here, and every other language only uses a subset of it, so it's less confusing to use the C++ names consistently, and mentally remap to the C names when working on that context (prvalue -> rvalue, no xvalues, etc). Renames: * VK_RValue -> VK_PRValue * Expr::isRValue -> Expr::isPRValue * SK_QualificationConversionRValue -> SK_QualificationConversionPRValue * JSON AST Dumper Expression nodes value category: "rvalue" -> "prvalue" Signed-off-by: Matheus Izvekov <mizvekov@gmail.com> Reviewed By: rsmith Differential Revision: https://reviews.llvm.org/D103720
2021-05-17[OpenCL] Drop pragma handling for extension types/decls.Anastasia Stulova1-113/+0
Drop non-conformant extension pragma implementation as it does not properly disable anything and therefore enabling non-disabled logic has no meaning. This simplifies clang code and user interface to the extension functionality. With this patch extension pragma 'begin'/'end' and 'enable'/'disable' are only accepted for backward compatibility and no longer have any default behavior. Differential Revision: https://reviews.llvm.org/D101043
2021-05-14[OpenCL] Simplify use of C11 atomic types.Anastasia Stulova1-22/+21
Remove requirements on extension pragma in atomic types because it has not respected the spec wrt disabling types and hasn't been useful either. With this change, the developers can use atomic types from the extensions if they are supported without enabling the pragma just like the builtin functions This patch does not break backward compatibility since the extension pragma is still supported and it makes the behavior of the compiler less strict by accepting code without needless and inconsistent pragma statements. Differential Revision: https://reviews.llvm.org/D100976
2021-05-12Suppress Deferred Diagnostics in discarded statements.Erich Keane1-0/+2
It doesn't really make sense to emit language specific diagnostics in a discarded statement, and suppressing these diagnostics results in a programming pattern that many users will feel is quite useful. Basically, this makes sure we only emit errors from the 'true' side of a 'constexpr if'. It does this by making the ExprEvaluatorBase type have an opt-in option as to whether it should visit discarded cases. Differential Revision: https://reviews.llvm.org/D102251
2021-05-11[OpenCL] Allow use of double type without extension pragma.Anastasia Stulova1-1/+0
Simply use of extensions by allowing the use of supported double types without the pragma. Since earlier standards instructed that the pragma is used explicitly a new warning is introduced in pedantic mode to indicate that use of type without extension pragma enable can be non-portable. This patch does not break backward compatibility since the extension pragma is still supported and it makes the behavior of the compiler less strict by accepting code without extra pragma statements. Differential Revision: https://reviews.llvm.org/D100980
2021-05-07[OpenCL] Fix optional image types.Anastasia Stulova1-3/+0
This change allows the use of identifiers for image types from `cl_khr_gl_msaa_sharing` freely in the kernel code if the extension is not supported since they are not in the list of the reserved identifiers. This change also removed the need for pragma for the types in the extensions since the spec does not require the pragma uses. Differential Revision: https://reviews.llvm.org/D100983
2021-04-15Implemented [[clang::musttail]] attribute for guaranteed tail calls.Joshua Haberman1-0/+5
This is a Clang-only change and depends on the existing "musttail" support already implemented in LLVM. The [[clang::musttail]] attribute goes on a return statement, not a function definition. There are several constraints that the user must follow when using [[clang::musttail]], and these constraints are verified by Sema. Tail calls are supported on regular function calls, calls through a function pointer, member function calls, and even pointer to member. Future work would be to throw a warning if a users tries to pass a pointer or reference to a local variable through a musttail call. Reviewed By: rsmith Differential Revision: https://reviews.llvm.org/D99517
2021-03-12[OpenCL] Refactor diagnostic for OpenCL extension/featureAnton Zabaznov1-28/+40
There is no need to check for enabled pragma for core or optional core features, thus this check is removed Reviewed By: Anastasia Differential Revision: https://reviews.llvm.org/D97058
2021-02-25Fix signed-compare warning.Justin Lebar1-2/+2
Introduced in my c90dac27e94ec354a3e8919556ac5bc89b62c731.
2021-02-25[clang] Print 32 candidates on the first failure, with -fshow-overloads=best.Justin Lebar1-3/+3
Previously, -fshow-overloads=best always showed 4 candidates. The problem is, when this isn't enough, you're kind of up a creek; the only option available is to recompile with different flags. This can be quite expensive! With this change, we try to strike a compromise. The *first* error with more than 4 candidates will show up to 32 candidates. All further errors continue to show only 4 candidates. The hope is that this way, users will have *some chance* of making forward progress, without facing unbounded amounts of error spam. Differential Revision: https://reviews.llvm.org/D95754
2021-02-18[Clang][RISCV] Define RISC-V V builtin typesHsiangkai Wang1-0/+6
Add the types for the RISC-V V extension builtins. These types will be used by the RISC-V V intrinsics which require types of the form <vscale x 1 x i64>(LMUL=1 element size=64) or <vscale x 4 x i32>(LMUL=2 element size=32), etc. The vector_size attribute does not work for us as it doesn't create a scalable vector type. We want these types to be opaque and have no operators defined for them. We want them to be sizeless. This makes them similar to the ARM SVE builtin types. But we will have quite a bit more types. This patch adds around 60. Later patches will add another 230 or so types representing tuples of these types similar to the x2/x3/x4 types in ARM SVE. But with extra complexity that these types are combined with the LMUL concept that is unique to RISCV. For more background see this RFC http://lists.llvm.org/pipermail/llvm-dev/2020-October/145850.html Authored-by: Roger Ferrer Ibanez <roger.ferrer@bsc.es> Co-Authored-by: Hsiangkai Wang <kai.wang@sifive.com> Differential Revision: https://reviews.llvm.org/D92715
2021-02-15[OpenMP] Attribute target diagnostics properlyJohannes Doerfert1-14/+22
Type errors in function declarations were not (always) diagnosed prior to this patch. Furthermore, certain remarks did not get associated properly which caused them to be emitted multiple times. Reviewed By: JonChesterfield Differential Revision: https://reviews.llvm.org/D95912