aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/ExprConstant.cpp
AgeCommit message (Collapse)AuthorFilesLines
2022-09-12Rewording note note_constexpr_invalid_castMuhammad Usman Shahid1-5/+9
The diagnostics here are correct, but the note is really silly. It talks about reinterpret_cast in C code. So rewording it for c mode by using another %select{}. ``` int array[(long)(char *)0]; ``` previous note: ``` cast that performs the conversions of a reinterpret_cast is not allowed in a constant expression ``` reworded note: ``` this conversion is not allowed in a constant expression ``` Differential Revision: https://reviews.llvm.org/D133194
2022-09-10[Clang] NFC: Remove duplicated variable def in CheckLValueConstantExpressionCorentin Jabot1-5/+3
2022-09-08[clang] Fix a crash in constant evaluationKadir Cetinkaya1-0/+2
2022-09-08[clang] Perform implicit lvalue-to-rvalue cast with new interpreterTimm Bäder1-12/+14
The EvaluateAsRValue() documentation mentions that an implicit lvalue-to-rvalue cast is being performed if the result is an lvalue. However, that was not being done if the new constant interpreter was in use. Just always do it. Differential Revision: https://reviews.llvm.org/D132136
2022-08-31Revert "[clang] Fix a crash in constant evaluation"Kadir Cetinkaya1-5/+0
This reverts commit a5ab650714d05c2e49ec158dc99156118a893027.
2022-08-31[clang] Fix a crash in constant evaluationKadir Cetinkaya1-0/+5
This was showing up in our internal crash collector. I have no idea how to test it out though, open for suggestions if there are easy paths but otherwise I'd move forward with the patch. Differential Revision: https://reviews.llvm.org/D132918
2022-08-17[Clang] Tighten restrictions on enum out of range diagnostic to avoid ↵Shafik Yaghmour1-5/+18
constant initialization The restrictions added in D131704 were not sufficient to avoid all non-constant expression contexts. In particular constant initialization cases. We need to check EvaluatingDecl to detect if the variable we are initializing is constexpr or not. At this point it looks like this is the remaining case affecting various projects with this diagnostic. Differential Revision: https://reviews.llvm.org/D131874
2022-08-11[Clang] Fix for Tighten restrictions on enum out of range diagnosticShafik Yaghmour1-0/+1
Ok it looks like this is a bit more subtle, I broke the llvm-test-suite file paq8p.cpp again. We need both conditions to be true Info.EvalMode == EvalInfo::EM_ConstantExpression && Info.InConstantContext. We need to be in a context that requires a constant value but also in a constant expression context. Differential Revision: https://reviews.llvm.org/D131704
2022-08-11[Clang] Tighten restrictions on enum out of range diagnosticShafik Yaghmour1-2/+1
In D131528 using Info.EvalMode == EvalInfo::EM_ConstantExpression is not strict enough to restrict the diagnostic to only constant expression contexts. It is sometimes set in cases where we are still determining if we are in a constant expression context. Using InConstantContext will tighten the restriction. Differential Revision: https://reviews.llvm.org/D131704
2022-08-10[Clang] Restrict non fixed enum to a value outside the range of the ↵Shafik Yaghmour1-1/+3
enumeration values warning to context requiring a constant expression In D131307 we allowed the diagnostic to be turned into a warning for a transition period. This had the side effect of triggering the warning in contexts not required to be constant expression. This change will restrict the diagnostic to constant expression contexts. This should reduce the fallout of this diagnostic. Differential Revision: https://reviews.llvm.org/D131528
2022-08-09[clang][clang-tools-extra] LLVM_NODISCARD => [[nodiscard]]. NFCFangrui Song1-4/+3
2022-08-08[Clang] Allow downgrading to a warning the diagnostic for setting a non ↵Shafik Yaghmour1-5/+7
fixed enum to a value outside the range of the enumeration values In D130058 we diagnose the undefined behavior of setting the value outside the range of the enumerations values for an enum without a fixed underlying type. Based on feedback we will provide users to the ability to downgrade this diagnostic to a waring to allow for a transition period. We expect to turn this diagnostic to an error in the next release. Differential Revision: https://reviews.llvm.org/D131307
2022-08-08[clang] LLVM_FALLTHROUGH => [[fallthrough]]. NFCFangrui Song1-7/+7
With C++17 there is no Clang pedantic warning or MSVC C5051. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D131346
2022-08-05[clang] Consider array filler in MaybeElementDependentArrayfiller()Timm Bäder1-0/+5
Any InitListExpr may have an array filler and since we may be evaluating the array filler as well, we need to take into account that the array filler expression might make the InitListExpr element dependent. Fixes https://github.com/llvm/llvm-project/issues/56016 Differential Revision: https://reviews.llvm.org/D131155
2022-08-04[Clang][C++20] Support capturing structured bindings in lambdasCorentin Jabot1-1/+1
This completes the implementation of P1091R3 and P1381R1. This patch allow the capture of structured bindings both for C++20+ and C++17, with extension/compat warning. In addition, capturing an anonymous union member, a bitfield, or a structured binding thereof now has a better diagnostic. We only support structured bindings - as opposed to other kinds of structured statements/blocks. We still emit an error for those. In addition, support for structured bindings capture is entirely disabled in OpenMP mode as this needs more investigation - a specific diagnostic indicate the feature is not yet supported there. Note that the rest of P1091R3 (static/thread_local structured bindings) was already implemented. at the request of @shafik, i can confirm the correct behavior of lldb wit this change. Fixes https://github.com/llvm/llvm-project/issues/54300 Fixes https://github.com/llvm/llvm-project/issues/54300 Fixes https://github.com/llvm/llvm-project/issues/52720 Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D122768
2022-08-03Revert "[Clang][C++20] Support capturing structured bindings in lambdas"Corentin Jabot1-1/+1
This reverts commit 44f2baa3804a62ca793f0ff3e43aa71cea91a795. Breaks self builds and seems to have conformance issues.
2022-08-03[Clang][C++20] Support capturing structured bindings in lambdasCorentin Jabot1-1/+1
This completes the implementation of P1091R3 and P1381R1. This patch allow the capture of structured bindings both for C++20+ and C++17, with extension/compat warning. In addition, capturing an anonymous union member, a bitfield, or a structured binding thereof now has a better diagnostic. We only support structured bindings - as opposed to other kinds of structured statements/blocks. We still emit an error for those. In addition, support for structured bindings capture is entirely disabled in OpenMP mode as this needs more investigation - a specific diagnostic indicate the feature is not yet supported there. Note that the rest of P1091R3 (static/thread_local structured bindings) was already implemented. at the request of @shafik, i can confirm the correct behavior of lldb wit this change. Fixes https://github.com/llvm/llvm-project/issues/54300 Fixes https://github.com/llvm/llvm-project/issues/54300 Fixes https://github.com/llvm/llvm-project/issues/52720 Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D122768
2022-08-03[clang] Short-circuit trivial constructors when evaluating arraysTimm Bäder1-13/+23
VisitCXXConstructExpr() will later do something similar, but for large arrays, we should try to do it once an not for every element. Fixes #56774 Differential Revision: https://reviews.llvm.org/D130791
2022-07-29[Clang] Fix handling of Max from getValueRange(...) in ↵Shafik Yaghmour1-2/+3
IntExprEvaluator::VisitCastExpr(...) This is a follow-up to D130058 to fix how we handle the Max value we obtain from getValueRange(...) in IntExprEvaluator::VisitCastExpr(...) which in the case of an enum that contains an enumerator with the max integer value will overflow by one. The fix is to decrement the value of Max and use slt and ult for comparison Vs sle and ule.` Differential Revision: https://reviews.llvm.org/D130811
2022-07-28[Clang] Diagnose ill-formed constant expression when setting a non fixed ↵Shafik Yaghmour1-0/+31
enum to a value outside the range of the enumeration values DR2338 clarified that it was undefined behavior to set the value outside the range of the enumerations values for an enum without a fixed underlying type. We should diagnose this with a constant expression context. Differential Revision: https://reviews.llvm.org/D130058
2022-07-27Revert "[Clang] Diagnose ill-formed constant expression when setting a non ↵Shafik Yaghmour1-28/+0
fixed enum to a value outside the range of the enumeration values" This reverts commit a3710589f285de0bb22ff92b1fc24df9411e986f.
2022-07-27[Clang] Diagnose ill-formed constant expression when setting a non fixed ↵Shafik Yaghmour1-0/+28
enum to a value outside the range of the enumeration values DR2338 clarified that it was undefined behavior to set the value outside the range of the enumerations values for an enum without a fixed underlying type. We should diagnose this with a constant expression context. Differential Revision: https://reviews.llvm.org/D130058
2022-07-24[clang] Fix incorrect constant folding of `if consteval`Corentin Jabot1-3/+7
Fixes https://github.com/llvm/llvm-project/issues/55638. `if consteval` was evaluated incorrectly when in a non-constant context that could be constant-folded. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D130437
2022-07-18[clang] Introduce -fstrict-flex-arrays=<n> for stricter handling of flexible ↵serge-sans-paille1-0/+6
arrays Some code [0] consider that trailing arrays are flexible, whatever their size. Support for these legacy code has been introduced in f8f632498307d22e10fab0704548b270b15f1e1e but it prevents evaluation of __builtin_object_size and __builtin_dynamic_object_size in some legit cases. Introduce -fstrict-flex-arrays=<n> to have stricter conformance when it is desirable. n = 0: current behavior, any trailing array member is a flexible array. The default. n = 1: any trailing array member of undefined, 0 or 1 size is a flexible array member n = 2: any trailing array member of undefined or 0 size is a flexible array member This takes into account two specificities of clang: array bounds as macro id disqualify FAM, as well as non standard layout. Similar patch for gcc discuss here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101836 [0] https://docs.freebsd.org/en/books/developers-handbook/sockets/#sockets-essential-functions
2022-06-29[Clang] Rename StringLiteral::isAscii() => isOrdinary() [NFC]Corentin Jabot1-1/+1
"Ascii" StringLiteral instances are actually narrow strings that are UTF-8 encoded and do not have an encoding prefix. (UTF8 StringLiteral are also UTF-8 encoded strings, but with the u8 prefix. To avoid possible confusion both with actuall ASCII strings, and with future works extending the set of literal encodings supported by clang, this rename StringLiteral::isAscii() to isOrdinary(), matching C++ standard terminology. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D128762
2022-06-27Revert "[clang] Introduce -fstrict-flex-arrays=<n> for stricter handling of ↵Vitaly Buka1-7/+0
flexible arrays" This reverts D126864 and related fixes. This reverts commit 572b08790a69f955ae0cbb1b4a7d4a215f15dad9. This reverts commit 886715af962de2c92fac4bd37104450345711e4a.
2022-06-24[clang] Introduce -fstrict-flex-arrays=<n> for stricter handling of flexible ↵serge-sans-paille1-0/+7
arrays Some code [0] consider that trailing arrays are flexible, whatever their size. Support for these legacy code has been introduced in f8f632498307d22e10fab0704548b270b15f1e1e but it prevents evaluation of __builtin_object_size and __builtin_dynamic_object_size in some legit cases. Introduce -fstrict-flex-arrays=<n> to have stricter conformance when it is desirable. n = 0: current behavior, any trailing array member is a flexible array. The default. n = 1: any trailing array member of undefined, 0 or 1 size is a flexible array member n = 2: any trailing array member of undefined or 0 size is a flexible array member n = 3: any trailing array member of undefined size is a flexible array member (strict c99 conformance) Similar patch for gcc discuss here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101836 [0] https://docs.freebsd.org/en/books/developers-handbook/sockets/#sockets-essential-functions
2022-06-22Fix interaction of pragma FENV_ACCESS with other pragmasSerge Pavlov1-2/+2
Previously `#pragma STDC FENV_ACCESS ON` always set dynamic rounding mode and strict exception handling. It is not correct in the presence of other pragmas that also modify rounding mode and exception handling. For example, the effect of previous pragma FENV_ROUND could be cancelled, which is not conformant with the C standard. Also `#pragma STDC FENV_ACCESS OFF` turned off only FEnvAccess flag, leaving rounding mode and exception handling unchanged, which is incorrect in general case. Concrete rounding and exception mode depend on a combination of several factors like various pragmas and command-line options. During the review of this patch an idea was proposed that the semantic actions associated with such pragmas should only set appropriate flags. Actual rounding mode and exception handling should be calculated taking into account the state of all relevant options. In such implementation the pragma FENV_ACCESS should not override properties set by other pragmas but should set them if such setting is absent. To implement this approach the following main changes are made: - Field `FPRoundingMode` is removed from `LangOptions`. Actually there are no options that set it to arbitrary rounding mode, the choice was only `dynamic` or `tonearest`. Instead, a new boolean flag `RoundingMath` is added, with the same meaning as the corresponding command-line option. - Type `FPExceptionModeKind` now has possible value `FPE_Default`. It does not represent any particular exception mode but indicates that such mode was not set and default value should be used. It allows to distinguish the case: { #pragma STDC FENV_ACCESS ON ... } where the pragma must set FPE_Strict, from the case: { #pragma clang fp exceptions(ignore) #pragma STDC FENV_ACCESS ON ... } where exception mode should remain `FPE_Ignore`. - Class `FPOptions` has now methods `getRoundingMode` and `getExceptionMode`, which calculates the respective properties from other specified FP properties. - Class `LangOptions` has now methods `getDefaultRoundingMode` and `getDefaultExceptionMode`, which calculates default modes from the specified options and should be used instead of `getRoundingMode` and `getFPExceptionMode` of the same class. Differential Revision: https://reviews.llvm.org/D126364
2022-06-14[NFC] Remove unused function parameterSerge Pavlov1-11/+6
2022-06-10[clang] Construct SmallVector with iterator ranges (NFC)Kazu Hirata1-1/+1
2022-06-06[Clang][FP16] Add 4 builtins for _Float16Phoebe Wang1-0/+4
We are lacking builtins support for `_Float16`. In most cases, we can use other floating-type builtins and truncate them to `_Float16`. But it's a problem to SNaN, e.g., https://gcc.godbolt.org/z/cqr5nG1jh This patch adds `__builtin_nansf16` support as well as other 3 ones since they are usually used together. Reviewed By: LuoYuanke Differential Revision: https://reviews.llvm.org/D127050
2022-05-19[APInt] Remove all uses of zextOrSelf, sextOrSelf and truncOrSelfJay Foad1-5/+5
Most clients only used these methods because they wanted to be able to extend or truncate to the same bit width (which is a no-op). Now that the standard zext, sext and trunc allow this, there is no reason to use the OrSelf versions. The OrSelf versions additionally have the strange behaviour of allowing extending to a *smaller* width, or truncating to a *larger* width, which are also treated as no-ops. A small amount of client code relied on this (ConstantRange::castOp and MicrosoftCXXNameMangler::mangleNumber) and needed rewriting. Differential Revision: https://reviews.llvm.org/D125557
2022-05-16[clang] Prevent folding of non-const compound exprserge-sans-paille1-0/+24
When a non-const compound statement is used to initialize a constexpr pointer, the pointed value is not const itself and cannot be folded at codegen time. This matches GCC behavior for compound literal expr arrays. Fix issue #39324. Differential Revision: https://reviews.llvm.org/D124038
2022-05-04Fix a failing assertion with vector type initializationAaron Ballman1-2/+2
When constant evaluating the initializer for an object of vector type, we would call APInt::trunc() but truncate to the same bit-width the object already had, which would cause an assertion. Instead, use APInt::truncOrSelf() so that we no longer assert in this situation. Fix #50216
2022-04-26[clang] Fix a constant evaluator crash on a NULL-type expr.Haojian Wu1-1/+1
Differential Revision: https://reviews.llvm.org/D124384
2022-04-20Treat `std::move`, `forward`, etc. as builtins.Richard Smith1-0/+17
This is extended to all `std::` functions that take a reference to a value and return a reference (or pointer) to that same value: `move`, `forward`, `move_if_noexcept`, `as_const`, `addressof`, and the libstdc++-specific function `__addressof`. We still require these functions to be declared before they can be used, but don't instantiate their definitions unless their addresses are taken. Instead, code generation, constant evaluation, and static analysis are given direct knowledge of their effect. This change aims to reduce various costs associated with these functions -- per-instantiation memory costs, compile time and memory costs due to creating out-of-line copies and inlining them, code size at -O0, and so on -- so that they are not substantially more expensive than a cast. Most of these improvements are very small, but I measured a 3% decrease in -O0 object file size for a simple C++ source file using the standard library after this change. We now automatically infer the `const` and `nothrow` attributes on these now-builtin functions, in particular meaning that we get a warning for an unused call to one of these functions. In C++20 onwards, we disallow taking the addresses of these functions, per the C++20 "addressable function" rule. In earlier language modes, a compatibility warning is produced but the address can still be taken. The same infrastructure is extended to the existing MSVC builtin `__GetExceptionInfo`, which is now only recognized in namespace `std` like it always should have been. This is a re-commit of fc3090109643af8d2da9822d0f99c84742b9c877, a571f82a50416b767fd3cce0fb5027bb5dfec58c, 64c045e25b8471bbb572bd29159c294a82a86a2, and de6ddaeef3aaa8a9ae3663c12cdb57d9afc0f906, and reverts aa643f455a5362de7189eac630050d2c8aefe8f2. This change also includes a workaround for users using libc++ 3.1 and earlier (!!), as apparently happens on AIX, where std::move sometimes returns by value. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D123345 Revert "Fixup D123950 to address revert of D123345" This reverts commit aa643f455a5362de7189eac630050d2c8aefe8f2.
2022-04-20Revert "Treat `std::move`, `forward`, etc. as builtins."David Tenty1-17/+0
This reverts commit b27430f9f46b88bcd54d992debc8d72e131e1bd0 as the parent https://reviews.llvm.org/D123345 breaks the AIX CI: https://lab.llvm.org/buildbot/#/builders/214/builds/819
2022-04-19[NFC] Remove unused variableChuanqi Xu1-1/+1
2022-04-17Treat `std::move`, `forward`, etc. as builtins.Richard Smith1-0/+17
This is extended to all `std::` functions that take a reference to a value and return a reference (or pointer) to that same value: `move`, `forward`, `move_if_noexcept`, `as_const`, `addressof`, and the libstdc++-specific function `__addressof`. We still require these functions to be declared before they can be used, but don't instantiate their definitions unless their addresses are taken. Instead, code generation, constant evaluation, and static analysis are given direct knowledge of their effect. This change aims to reduce various costs associated with these functions -- per-instantiation memory costs, compile time and memory costs due to creating out-of-line copies and inlining them, code size at -O0, and so on -- so that they are not substantially more expensive than a cast. Most of these improvements are very small, but I measured a 3% decrease in -O0 object file size for a simple C++ source file using the standard library after this change. We now automatically infer the `const` and `nothrow` attributes on these now-builtin functions, in particular meaning that we get a warning for an unused call to one of these functions. In C++20 onwards, we disallow taking the addresses of these functions, per the C++20 "addressable function" rule. In earlier language modes, a compatibility warning is produced but the address can still be taken. The same infrastructure is extended to the existing MSVC builtin `__GetExceptionInfo`, which is now only recognized in namespace `std` like it always should have been. This is a re-commit of fc3090109643af8d2da9822d0f99c84742b9c877, a571f82a50416b767fd3cce0fb5027bb5dfec58c, and 64c045e25b8471bbb572bd29159c294a82a86a25 which were reverted in e75d8b70370435b0ad10388afba0df45fcf9bfcc due to a crasher bug where CodeGen would emit a builtin glvalue as an rvalue if it constant-folds. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D123345
2022-04-16Revert "Treat `std::move`, `forward`, and `move_if_noexcept` as builtins."Vitaly Buka1-17/+0
Revert "Extend support for std::move etc to also cover std::as_const and" Revert "Update test to handle opaque pointers flag flip." It crashes on libcxx tests https://lab.llvm.org/buildbot/#/builders/85/builds/8174 This reverts commit fc3090109643af8d2da9822d0f99c84742b9c877. This reverts commit a571f82a50416b767fd3cce0fb5027bb5dfec58c. This reverts commit 64c045e25b8471bbb572bd29159c294a82a86a25.
2022-04-15Extend support for std::move etc to also cover std::as_const andRichard Smith1-1/+4
std::addressof, plus the libstdc++-specific std::__addressof. This brings us to parity with the corresponding GCC behavior. Remove STDBUILTIN macro that ended up not being used.
2022-04-15Treat `std::move`, `forward`, and `move_if_noexcept` as builtins.Richard Smith1-0/+14
We still require these functions to be declared before they can be used, but don't instantiate their definitions unless their addresses are taken. Instead, code generation, constant evaluation, and static analysis are given direct knowledge of their effect. This change aims to reduce various costs associated with these functions -- per-instantiation memory costs, compile time and memory costs due to creating out-of-line copies and inlining them, code size at -O0, and so on -- so that they are not substantially more expensive than a cast. Most of these improvements are very small, but I measured a 3% decrease in -O0 object file size for a simple C++ source file using the standard library after this change. We now automatically infer the `const` and `nothrow` attributes on these now-builtin functions, in particular meaning that we get a warning for an unused call to one of these functions. In C++20 onwards, we disallow taking the addresses of these functions, per the C++20 "addressable function" rule. In earlier language modes, a compatibility warning is produced but the address can still be taken. The same infrastructure is extended to the existing MSVC builtin `__GetExceptionInfo`, which is now only recognized in namespace `std` like it always should have been. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D123345
2022-04-14Allow flexible array initialization in C++.Eli Friedman1-0/+11
Flexible array initialization is a C/C++ extension implemented in many compilers to allow initializing the flexible array tail of a struct type that contains a flexible array. In clang, this is currently restricted to C. But this construct is used in the Microsoft SDK headers, so I'd like to extend it to C++. For now, this doesn't handle dynamic initialization; probably not hard to implement, but it's extra code, and I don't think it's necessary for the expected uses. And we explicitly fail out of constant evaluation. I've added some additional code to assert that initializers have the correct size, with or without flexible array init. This might catch issues unrelated to flexible array init. Differential Revision: https://reviews.llvm.org/D123649
2022-04-14[Clang][AArch64][SVE] Allow subscript operator for SVE typesDavid Truby1-1/+2
Undefined behaviour is just passed on to extract_element when the index is out of bounds. Subscript on svbool_t is not allowed as this doesn't really have meaningful semantics. Differential Revision: https://reviews.llvm.org/D122732
2022-04-06[clang][NFC] Add specificity to compatibility hackNathan Sidwell1-4/+5
Add specific dates and versions to note about source_location handling. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D123119
2022-03-28[Clang] Implement __builtin_source_location.James Y Knight1-9/+50
This builtin returns the address of a global instance of the `std::source_location::__impl` type, which must be defined (with an appropriate shape) before calling the builtin. It will be used to implement std::source_location in libc++ in a future change. The builtin is compatible with GCC's implementation, and libstdc++'s usage. An intentional divergence is that GCC declares the builtin's return type to be `const void*` (for ease-of-implementation reasons), while Clang uses the actual type, `const std::source_location::__impl*`. In order to support this new functionality, I've also added a new 'UnnamedGlobalConstantDecl'. This artificial Decl is modeled after MSGuidDecl, and is used to represent a generic concept of an lvalue constant with global scope, deduplicated by its value. It's possible that MSGuidDecl itself, or some of the other similar sorts of things in Clang might be able to be refactored onto this more-generic concept, but there's enough special-case weirdness in MSGuidDecl that I gave up attempting to share code there, at least for now. Finally, for compatibility with libstdc++'s <source_location> header, I've added a second exception to the "cannot cast from void* to T* in constant evaluation" rule. This seems a bit distasteful, but feels like the best available option. Reviewers: aaron.ballman, erichkeane Differential Revision: https://reviews.llvm.org/D120159
2022-03-24[NFCI] Fix set-but-unused warning in ExprConstant.cppDávid Bolvanský1-2/+0
2022-03-22[Clang][C++2b] P2242R3: Non-literal variables [...] in constexprCorentin Jabot1-0/+17
Allow goto, labelled statements as well as `static`, `thread_local`, and non-literal variables in `constexpr` functions. As specified. for all of the above (except labelled statements) constant evaluation of the construct still fails. For `constexpr` bodies, the proposal is implemented with diagnostics as a language extension in older language modes. For determination of whether a lambda body satisfies the requirements for a constexpr function, the proposal is implemented only in C++2b mode to retain the semantics of older modes for programs conforming to them. Reviewed By: aaron.ballman, hubert.reinterpretcast, erichkeane Differential Revision: https://reviews.llvm.org/D111400
2022-02-22[clang] Never wrap a nullptr in CXXNewExpr::getArraySize()Timm Bäder1-1/+1
Otherwise callers of these functions have to check both the return value for and the contents of the returned llvm::Optional. Fixes #53742 Differential Revision: https://reviews.llvm.org/D119525
2022-02-02PR45879: Fix assert when constant evaluating union assignment.Richard Smith1-3/+9
Consider the form of the first operand of a class assignment not the second operand when implicitly starting the lifetimes of union members. Also add a missing check that the assignment call actually came from a syntactic assignment, not from a direct call to `operator=`.