aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaExceptionSpec.cpp
AgeCommit message (Collapse)AuthorFilesLines
2023-01-04[clang] Revert parentesized aggregate initalization patchesAlan Zhao1-1/+0
This feature causes clang to crash when compiling Chrome - see https://crbug.com/1405031 and https://github.com/llvm/llvm-project/issues/59675 Revert "[clang] Fix a clang crash on invalid code in C++20 mode." This reverts commit 32d7aae04fdb58e65a952f281ff2f2c3f396d98f. Revert "[clang] Remove overly restrictive aggregate paren init logic" This reverts commit c77a91bb7ba793ec3a6a5da3743ed55056291658. Revert "[clang][C++20] P0960R3 and P1975R0: Allow initializing aggregates from a parenthesized list of values" This reverts commit 40c52159d3ee337dbed14e4c73b5616ea354c337.
2022-12-14[clang][C++20] P0960R3 and P1975R0: Allow initializing aggregates from a ↵Alan Zhao1-0/+1
parenthesized list of values This patch implements P0960R3, which allows initialization of aggregates via parentheses. As an example: ``` struct S { int i, j; }; S s1(1, 1); int arr1[2](1, 2); ``` This patch also implements P1975R0, which fixes the wording of P0960R3 for single-argument parenthesized lists so that statements like the following are allowed: ``` S s2(1); S s3 = static_cast<S>(1); S s4 = (S)1; int (&&arr2)[] = static_cast<int[]>(1); int (&&arr3)[2] = static_cast<int[2]>(1); ``` This patch was originally authored by @0x59616e and completed by @ayzhao. Fixes #54040, Fixes #54041 Co-authored-by: Sheng <ox59616e@gmail.com> Full write up : https://discourse.llvm.org/t/c-20-rfc-suggestion-desired-regarding-the-implementation-of-p0960r3/63744 Reviewed By: ilya-biryukov Differential Revision: https://reviews.llvm.org/D129531
2022-11-02[OPENMP]Initial support for error directive.Jennifer Yu1-0/+1
Differential Revision: https://reviews.llvm.org/D137209
2022-07-01[OpenMP] Initial parsing and semantic support for 'parallel masked taskloop ↵Fazlay Rabbi1-0/+1
simd' construct This patch gives basic parsing and semantic support for "parallel masked taskloop simd" construct introduced in OpenMP 5.1 (section 2.16.10) Differential Revision: https://reviews.llvm.org/D128946
2022-06-30[OpenMP] Initial parsing and sema support for 'parallel masked taskloop' ↵Fazlay Rabbi1-0/+1
construct This patch gives basic parsing and semantic support for "parallel masked taskloop" construct introduced in OpenMP 5.1 (section 2.16.9) Differential Revision: https://reviews.llvm.org/D128834
2022-06-28[OpenMP] Initial parsing and sema support for 'masked taskloop simd' constructFazlay Rabbi1-0/+1
This patch gives basic parsing and semantic support for "masked taskloop simd" construct introduced in OpenMP 5.1 (section 2.16.8) Differential Revision: https://reviews.llvm.org/D128693
2022-06-24[OpenMP] Initial parsing and sema support for 'masked taskloop' constructFazlay Rabbi1-0/+1
This patch gives basic parsing and semantic support for "masked taskloop" construct introduced in OpenMP 5.1 (section 2.16.7) Differential Revision: https://reviews.llvm.org/D128478
2022-06-16[OpenMP] Initial parsing and sema for 'parallel masked' constructJennifer Yu1-0/+1
Differential Revision: https://reviews.llvm.org/D127454
2022-03-24[OpenMP] Initial parsing/sema for the 'omp target parallel loop' constructMike Rice1-0/+1
Adds basic parsing/sema/serialization support for the #pragma omp target parallel loop directive. Differential Revision: https://reviews.llvm.org/D122359
2022-03-22[OpenMP] Initial parsing/sema for the 'omp parallel loop' constructMike Rice1-0/+1
Adds basic parsing/sema/serialization support for the #pragma omp parallel loop directive. Differential Revision: https://reviews.llvm.org/D122247
2022-03-18[OpenMP] Initial parsing/sema for the 'omp target teams loop' constructMike Rice1-0/+1
Adds basic parsing/sema/serialization support for the #pragma omp target teams loop directive. Differential Revision: https://reviews.llvm.org/D122028
2022-03-16[OpenMP] Initial parsing/sema for the 'omp teams loop' constructMike Rice1-0/+1
Adds basic parsing/sema/serialization support for the #pragma omp teams loop directive. Differential Revision: https://reviews.llvm.org/D121713
2022-02-17[clang] Sema::CheckEquivalentExceptionSpec - remove useless nullptr testSimon Pilgrim1-5/+3
We use castAs<> for NewProto/OldProto, which would assert if the cast failed.
2022-01-07[-fms-extensions] Make some exception specification warnings/errors ↵Amy Huang1-3/+6
compatible with what cl.exe does Make clang-cl error when a function definition is missing 'noexcept', and succeed without warnings when missing '__declspec(nothrow)' or 'throw'. Fixes pr52860 Differential Revision: https://reviews.llvm.org/D116256
2021-10-28[OpenMP] Initial parsing/sema for the 'omp loop' constructMike Rice1-0/+1
Adds basic parsing/sema/serialization support for the #pragma omp loop directive. Differential Revision: https://reviews.llvm.org/D112499
2021-09-18OpenMP 5.0 metadirectivealokmishra.besu1-0/+1
This patch supports OpenMP 5.0 metadirective features. It is implemented keeping the OpenMP 5.1 features like dynamic user condition in mind. A new function, getBestWhenMatchForContext, is defined in llvm/Frontend/OpenMP/OMPContext.h Currently this function return the index of the when clause with the highest score from the ones applicable in the Context. But this function is declared with an array which can be used in OpenMP 5.1 implementation to select all the valid when clauses which can be resolved in runtime. Currently this array is set to null by default and its implementation is left for future. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D91944
2021-09-18Revert "OpenMP 5.0 metadirective"Nico Weber1-1/+0
This reverts commit c7d7b98e5263472f05b2f3cb767b5d16e1349e9a. Breaks tests on macOS, see comment on https://reviews.llvm.org/D91944
2021-09-17OpenMP 5.0 metadirectivealokmishra.besu1-0/+1
This patch supports OpenMP 5.0 metadirective features. It is implemented keeping the OpenMP 5.1 features like dynamic user condition in mind. A new function, getBestWhenMatchForContext, is defined in llvm/Frontend/OpenMP/OMPContext.h Currently this function return the index of the when clause with the highest score from the ones applicable in the Context. But this function is declared with an array which can be used in OpenMP 5.1 implementation to select all the valid when clauses which can be resolved in runtime. Currently this array is set to null by default and its implementation is left for future. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D91944
2021-09-17Revert "OpenMP 5.0 metadirective"cchen1-1/+0
This reverts commit c7d7b98e5263472f05b2f3cb767b5d16e1349e9a.
2021-09-17OpenMP 5.0 metadirectivecchen1-0/+1
This patch supports OpenMP 5.0 metadirective features. It is implemented keeping the OpenMP 5.1 features like dynamic user condition in mind. A new function, getBestWhenMatchForContext, is defined in llvm/Frontend/OpenMP/OMPContext.h Currently this function return the index of the when clause with the highest score from the ones applicable in the Context. But this function is declared with an array which can be used in OpenMP 5.1 implementation to select all the valid when clauses which can be resolved in runtime. Currently this array is set to null by default and its implementation is left for future. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D91944
2021-08-06Disallow narrowing conversions to bool in noexcept specififersCorentin Jabot1-8/+12
Completes the support for P1401R5.
2021-06-10[OpenMP] Implement '#pragma omp unroll'.Michael Kruse1-0/+1
Implementation of the unroll directive introduced in OpenMP 5.1. Follows the approach from D76342 for the tile directive (i.e. AST-based, not using the OpenMPIRBuilder). Tries to use `llvm.loop.unroll.*` metadata where possible, but has to fall back to an AST representation of the outer loop if the partially unrolled generated loop is associated with another directive (because it needs to compute the number of iterations). Reviewed By: ABataev Differential Revision: https://reviews.llvm.org/D99459
2021-05-27Reimplement __builtin_unique_stable_name-Erich Keane1-0/+2
The original version of this was reverted, and @rjmcall provided some advice to architect a new solution. This is that solution. This implements a builtin to provide a unique name that is stable across compilations of this TU for the purposes of implementing the library component of the unnamed kernel feature of SYCL. It does this by running the Itanium mangler with a few modifications. Because it is somewhat common to wrap non-kernel-related lambdas in macros that aren't present on the device (such as for logging), this uniquely generates an ID for all lambdas involved in the naming of a kernel. It uses the lambda-mangling number to do this, except replaces this with its own number (starting at 10000 for readabililty reasons) for lambdas used to name a kernel. Additionally, this implements itself as constexpr with a slight catch: if a name would be invalidated by the use of this lambda in a later kernel invocation, it is diagnosed as an error (see the Sema tests). Differential Revision: https://reviews.llvm.org/D103112
2021-04-29Update libstdc++ hack commentNathan Sidwell1-4/+6
This libstc++ hack isn't ready for removal. Updating the comment to note what I found. While I have not proven Ville's __is_throw_swappable patch made this go away, that patch did remove the use of noexcept(noexcept(swap(....))). I'm not sure when gcc grew deferred noexcept parsing. Differential Revision: https://reviews.llvm.org/D101441
2021-04-09[OpenMP51] Initial support for masked directive and filter clausecchen1-0/+1
Adds basic parsing/sema/serialization support for the #pragma omp masked directive. Reviewed By: ABataev Differential Revision: https://reviews.llvm.org/D99995
2021-03-30[OPENMP51]Initial support for the dispatch directive.Mike Rice1-0/+1
Added basic parsing/sema/serialization support for dispatch directive. Differential Revision: https://reviews.llvm.org/D99537
2021-03-17[OPENMP51]Initial support for the interop directive.Mike Rice1-0/+1
Added basic parsing/sema/serialization support for interop directive. Support for the 'init' clause. Differential Revision: https://reviews.llvm.org/D98558
2021-03-04[clang][OpenMP] Use OpenMPIRBuilder for workshare loops.Michael Kruse1-0/+1
Initial support for using the OpenMPIRBuilder by clang to generate loops using the OpenMPIRBuilder. This initial support is intentionally limited to: * Only the worksharing-loop directive. * Recognizes only the nowait clause. * No loop nests with more than one loop. * Untested with templates, exceptions. * Semantic checking left to the existing infrastructure. This patch introduces a new AST node, OMPCanonicalLoop, which becomes parent of any loop that has to adheres to the restrictions as specified by the OpenMP standard. These restrictions allow OMPCanonicalLoop to provide the following additional information that depends on base language semantics: * The distance function: How many loop iterations there will be before entering the loop nest. * The loop variable function: Conversion from a logical iteration number to the loop variable. These allow the OpenMPIRBuilder to act solely using logical iteration numbers without needing to be concerned with iterator semantics between calling the distance function and determining what the value of the loop variable ought to be. Any OpenMP logical should be done by the OpenMPIRBuilder such that it can be reused MLIR OpenMP dialect and thus by flang. The distance and loop variable function are implemented using lambdas (or more exactly: CapturedStmt because lambda implementation is more interviewed with the parser). It is up to the OpenMPIRBuilder how they are called which depends on what is done with the loop. By default, these are emitted as outlined functions but we might think about emitting them inline as the OpenMPRuntime does. For compatibility with the current OpenMP implementation, even though not necessary for the OpenMPIRBuilder, OMPCanonicalLoop can still be nested within OMPLoopDirectives' CapturedStmt. Although OMPCanonicalLoop's are not currently generated when the OpenMPIRBuilder is not enabled, these can just be skipped when not using the OpenMPIRBuilder in case we don't want to make the AST dependent on the EnableOMPBuilder setting. Loop nests with more than one loop require support by the OpenMPIRBuilder (D93268). A simple implementation of non-rectangular loop nests would add another lambda function that returns whether a loop iteration of the rectangular overapproximation is also within its non-rectangular subset. Reviewed By: jdenny Differential Revision: https://reviews.llvm.org/D94973
2021-02-16[OpenMP] Implement '#pragma omp tile', by Michael Kruse (@Meinersbur).Michael Kruse1-0/+1
The tile directive is in OpenMP's Technical Report 8 and foreseeably will be part of the upcoming OpenMP 5.1 standard. This implementation is based on an AST transformation providing a de-sugared loop nest. This makes it simple to forward the de-sugared transformation to loop associated directives taking the tiled loops. In contrast to other loop associated directives, the OMPTileDirective does not use CapturedStmts. Letting loop associated directives consume loops from different capture context would be difficult. A significant amount of code generation logic is taking place in the Sema class. Eventually, I would prefer if these would move into the CodeGen component such that we could make use of the OpenMPIRBuilder, together with flang. Only expressions converting between the language's iteration variable and the logical iteration space need to take place in the semantic analyzer: Getting the of iterations (e.g. the overload resolution of `std::distance`) and converting the logical iteration number to the iteration variable (e.g. overload resolution of `iteration + .omp.iv`). In clang, only CXXForRangeStmt is also represented by its de-sugared components. However, OpenMP loop are not defined as syntatic sugar. Starting with an AST-based approach allows us to gradually move generated AST statements into CodeGen, instead all at once. I would also like to refactor `checkOpenMPLoop` into its functionalities in a follow-up. In this patch it is used twice. Once for checking proper nesting and emitting diagnostics, and additionally for deriving the logical iteration space per-loop (instead of for the loop nest). Differential Revision: https://reviews.llvm.org/D76342
2020-10-15Switch the default of VerifyIntegerConstantExpression from constantRichard Smith1-3/+1
folding to not constant folding. Constant folding of ICEs is done as a GCC compatibility measure, but new code was picking it up, presumably by accident, due to the bad default. While here, also switch the flag from a bool to an enum to make it more obvious what it means at call sites. This highlighted a couple of places where our behavior is different between C++11 and C++14 due to switching from checking for an ICE to checking for a converted constant expression (where there is no 'fold' codepath).
2020-06-22[Coroutines] Ensure co_await promise.final_suspend() does not throwXun Li1-6/+5
Summary: This patch addresses https://bugs.llvm.org/show_bug.cgi?id=46256 The spec of coroutine requires that the expression co_­await promise.final_­suspend() shall not be potentially-throwing. To check this, we recursively look at every call (including Call, MemberCall, OperatorCall and Constructor) in all code generated by the final suspend, and ensure that the callees are declared with noexcept. We also look at any returned data type that requires explicit destruction, and check their destructors for noexcept. This patch does not check declarations with dependent types yet, which will be done in future patches. Updated all tests to add noexcept to the required functions, and added a dedicated test for this patch. This patch might start to cause existing codebase fail to compile because most people may not have been strict in tagging all the related functions noexcept. Reviewers: lewissbaker, modocache, junparser Reviewed By: modocache Subscribers: arphaman, junparser, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D82029
2020-06-01[Matrix] Implement matrix index expressions ([][]).Florian Hahn1-0/+1
This patch implements matrix index expressions (matrix[RowIdx][ColumnIdx]). It does so by introducing a new MatrixSubscriptExpr(Base, RowIdx, ColumnIdx). MatrixSubscriptExprs are built in 2 steps in ActOnMatrixSubscriptExpr. First, if the base of a subscript is of matrix type, we create a incomplete MatrixSubscriptExpr(base, idx, nullptr). Second, if the base is an incomplete MatrixSubscriptExpr, we create a complete MatrixSubscriptExpr(base->getBase(), base->getRowIdx(), idx) Similar to vector elements, it is not possible to take the address of a MatrixSubscriptExpr. For CodeGen, a new MatrixElt type is added to LValue, which is very similar to VectorElt. The only difference is that we may need to cast the type of the base from an array to a vector type when accessing it. Reviewers: rjmccall, anemet, Bigcheese, rsmith, martong Reviewed By: rjmccall Differential Revision: https://reviews.llvm.org/D76791
2020-05-18[OpenCL] Added addrspace_cast operator in C++ mode.Anastasia Stulova1-0/+1
This operator is intended for casting between pointers to objects in different address spaces and follows similar logic as const_cast in C++. Tags: #clang Differential Revision: https://reviews.llvm.org/D60193
2020-04-02[OPENMP50]Add initial support for OpenMP 5.0 iterator.Alexey Bataev1-0/+1
Added basic parsing/semantic analysis/(de)serialization support for iterator expression introduced in OpenMP 5.0.
2020-04-01Revert "[OPENMP50]Add initial support for OpenMP 5.0 iterator."Alexey Bataev1-1/+0
This reverts commit f08df464ae89972a777c0a7e299a2c153a9829d8 to fix the bug with serialization support for iterator expression.
2020-04-01[OPENMP50]Add initial support for OpenMP 5.0 iterator.Alexey Bataev1-0/+1
Added basic parsing/semantic analysis/(de)serialization support for iterator expression introduced in OpenMP 5.0.
2020-03-30[OPENMP50]Add basic support for array-shaping operation.Alexey Bataev1-0/+1
Summary: Added basic representation and parsing/sema handling of array-shaping operations. Array shaping expression is an expression of form ([s0]..[sn])base, where s0, ..., sn must be a positive integer, base - a pointer. This expression is a kind of cast operation that converts pointer expression into an array-like kind of expression. Reviewers: rjmccall, rsmith, jdoerfert Subscribers: guansong, arphaman, cfe-commits, caomhin, kkwli0 Tags: #clang Differential Revision: https://reviews.llvm.org/D74144
2020-03-24[AST] Add RecoveryExpr to retain expressions on semantic errorsHaojian Wu1-0/+1
Normally clang avoids creating expressions when it encounters semantic errors, even if the parser knows which expression to produce. This works well for the compiler. However, this is not ideal for source-level tools that have to deal with broken code, e.g. clangd is not able to provide navigation features even for names that compiler knows how to resolve. The new RecoveryExpr aims to capture the minimal set of information useful for the tools that need to deal with incorrect code: source range of the expression being dropped, subexpressions of the expression. We aim to make constructing RecoveryExprs as simple as possible to ensure writing code to avoid dropping expressions is easy. Producing RecoveryExprs can result in new code paths being taken in the frontend. In particular, clang can produce some new diagnostics now and we aim to suppress bogus ones based on Expr::containsErrors. We deliberately produce RecoveryExprs only in the parser for now to minimize the code affected by this patch. Producing RecoveryExprs in Sema potentially allows to preserve more information (e.g. type of an expression), but also results in more code being affected. E.g. SFINAE checks will have to take presence of RecoveryExprs into account. Initial implementation only works in C++ mode, as it relies on compiler postponing diagnostics on dependent expressions. C and ObjC often do not do this, so they require more work to make sure we do not produce too many bogus diagnostics on the new expressions. See documentation of RecoveryExpr for more details. original patch from Ilya This change is based on https://reviews.llvm.org/D61722 Reviewers: sammccall, rsmith Reviewed By: sammccall, rsmith Tags: #clang Differential Revision: https://reviews.llvm.org/D69330
2020-03-20[OPENMP50]Initial support for scan directive.Alexey Bataev1-0/+1
Addedi basic parsing/sema/serialization support for scan directive.
2020-03-17[Sema][SVE] Reject sizeless types in exception specsRichard Sandiford1-0/+8
In the current SVE ACLE spec, the usual rules for throwing and catching incomplete types also apply to sizeless types. However, throwing pointers to sizeless types should not pose any real difficulty, so as an extension, the clang implementation allows that. This patch enforces these rules for explicit exception specs. Differential Revision: https://reviews.llvm.org/D76087
2020-03-02[OPENMP50]Add basic support for depobj construct.Alexey Bataev1-0/+1
Added basic parsing/sema/serialization support for depobj directive.
2020-01-19[Concepts] Requires ExpressionsSaar Raz1-0/+1
Implement support for C++2a requires-expressions. Re-commit after compilation failure on some platforms due to alignment issues with PointerIntPair. Differential Revision: https://reviews.llvm.org/D50360
2020-01-18Revert "[Concepts] Requires Expressions"Saar Raz1-1/+0
This reverts commit 027931899763409e2c61a84bdee6057b5e838ffa. There have been some failing tests on some platforms, reverting while investigating.
2020-01-18[Concepts] Requires ExpressionsSaar Raz1-0/+1
Implement support for C++2a requires-expressions. Differential Revision: https://reviews.llvm.org/D50360
2020-01-13PR44514: Fix recovery from noexcept with non-convertible expressionsErich Keane1-2/+10
We currently treat noexcept(not-convertible-to-bool) as 'none', which results in the typeloc info being a different size, and causing an assert later on in the process. In order to make recovery less destructive, replace this with noexcept(false) and a constructed 'false' expression. Bug Report: https://bugs.llvm.org/show_bug.cgi?id=44514 Differential Revision: https://reviews.llvm.org/D72621
2019-12-15[c++20] Compute exception specifications for defaulted comparisons.Richard Smith1-3/+13
This requires us to essentially fully form the body of the defaulted comparison, but from an unevaluated context. Naively this would require generating the function definition twice; instead, we ensure that the function body is implicitly defined before performing the check, and walk the actual body where possible.
2019-12-15Properly compute whether statement expressions can throw, rather thanRichard Smith1-60/+269
conservatively assuming they always can. Also fix cases where we would not consider the computation of a VLA type when determining whether an expression can throw. We don't yet properly determine whether a VLA can throw, but no longer incorrectly claim it can never throw.
2019-10-21SemaExceptionSpec - silence static analyzer getAs<> null dereference ↵Simon Pilgrim1-4/+3
warnings. NFCI. The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<> directly and if not assert will fire for us. llvm-svn: 375440
2019-10-19[c++20] Add CXXRewrittenBinaryOperator to represent a comparisonRichard Smith1-0/+1
operator that is rewritten as a call to multiple other operators. No functionality change yet: nothing creates these expressions. llvm-svn: 375305
2019-10-15[Concepts] Concept Specialization ExpressionsSaar Raz1-0/+1
Part of C++20 Concepts implementation effort. Added Concept Specialization Expressions that are created when a concept is refe$ D41217 on Phabricator. (recommit after fixing failing Parser test on windows) llvm-svn: 374903