aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Parse/ParseOpenMP.cpp
AgeCommit message (Collapse)AuthorFilesLines
43 hours[Clang][OpenMP][LoopTransformations] Implement "#pragma omp fuse" loop ↵Walter J.T.V1-0/+36
transformation directive and "looprange" clause (#139293) This change implements the fuse directive, `#pragma omp fuse`, as specified in the OpenMP 6.0, along with the `looprange` clause in clang. This change also adds minimal stubs so flang keeps compiling (a full implementation in flang of this directive is still pending). --------- Co-authored-by: Roger Ferrer Ibanez <roger.ferrer@bsc.es>
13 days[clang] [OpenMP] New OpenMP 6.0 - Parsing and Sema support for groupprivate ↵Ritanya-B-Bharadwaj1-0/+32
(#158134)
13 days[OpenMP 5.2] New syntax for 'uses_allocators' clause (#157025)Urvi Rav1-0/+75
This patch updates the parsing changes to handle the new syntax of the `uses_allocators` clause as defined in OpenMP 5.2(Section 6.8). ``` // Case 1: Allocator without traits // < 5.2 → error // ≥ 5.2 → OK, empty traits set #pragma omp target teams uses_allocators(cgroup_alloc) // Case 2: Allocator with traits // Old syntax (< 5.2): #pragma omp target teams uses_allocators(cgroup_alloc(cgroup_traits)) // New syntax (≥ 5.2): #pragma omp target teams uses_allocators(traits(cgroup_traits) : cgroup_alloc) // Case 3: Multiple allocators // Old syntax (< 5.2), comma-separated: #pragma omp target teams uses_allocators(cgroup_alloc(cgroup_traits), aligned_alloc(aligned_traits)) // New syntax (≥ 5.2), semicolon-separated: #pragma omp target teams uses_allocators(traits(cgroup_traits) : cgroup_alloc; traits(aligned_traits) : aligned_alloc) ``` --------- Co-authored-by: urvi-rav <urvi.rav@hpe.com>
2025-09-15[Clang][OpenMP]Default clause variable category (#157063)SunilKuravinakop1-1/+39
Support for Variable Category in Default Clause. --------- Co-authored-by: Sunil Kuravinakop <kuravina@pe31.hpc.amslabs.hpecorp.net>
2025-08-05[Clang][OpenMP] Fixing Clang error for metadirective with multiple when ↵Ritanya-B-Bharadwaj1-1/+1
clauses and no otherwise (#148583) Fixing - https://github.com/llvm/llvm-project/issues/147336
2025-07-10[OpenMP-5.2] deprecate delimited form of 'declare target' (#145854)Urvi Rav1-0/+3
According to OpenMP 5.2 (Section 7.8.2), the directive name `declare target` may be used as a synonym for `begin declare target` only when no clauses are specified. This clause-less delimited form is now deprecated and should emit a deprecation warning. ``` // Deprecated usage (should trigger warning): #pragma omp declare target // deprecated in OpenMP 5.2 void foo1() { } #pragma omp end declare target // Valid usage with clause (should not trigger warning): #pragma omp declare target enter(foo2) void foo2() { } ``` ``` // Recommended replacement for deprecated delimited form: #pragma omp begin declare target void foo() { } #pragma omp end declare target ``` --------- Co-authored-by: urvi-rav <urvi.rav@hpe.com>
2025-07-07[clang][OpenMP] Fix signed v unsigned comparisonKrzysztof Parzyszek1-1/+1
This should unbreak https://lab.llvm.org/buildbot/#/builders/51/builds/19309
2025-07-07[clang][OpenMP] Issue a warning when parsing future directive spelling (#146933)Krzysztof Parzyszek1-4/+24
OpenMP 6.0 introduced alternative spelling for some directives, with the previous spellings still allowed. Warn the user when a new spelling is encountered with OpenMP version set to an older value.
2025-07-07[clang][OpenMP] Use DirectiveNameParser to parse directive names (#146779)Krzysztof Parzyszek1-162/+19
This simplifies the parsing code in clang quite a bit.
2025-07-07[C23] Fix typeof handling in enum declarations (#146394)Aaron Ballman1-5/+6
We have a parsing helper function which parses either a parenthesized expression or a parenthesized type name. This is used when parsing a unary operator such as sizeof, for example. The problem this solves is when that construct is ambiguous. Consider: enum E : typeof(int) { F }; After we've parsed the 'typeof', what ParseParenExpression() is responsible for is '(int) { F }' which looks like a compound literal expression when it's actually the parens and operand for 'typeof' followed by the enumerator list for the enumeration declaration. Then consider: sizeof (int){ 0 }; After we've parsed 'sizeof', ParseParenExpression is responsible for parsing something grammatically similar to the problematic case. The solution is to recognize that the expression form of 'typeof' is required to have parentheses. So we know the open and close parens that ParseParenExpression handles must be part of the grammar production for the operator, not part of the operand expression itself. Fixes #146351
2025-06-24[OpenMP][clang] 6.0: parsing/sema for num_threads 'strict' modifier (#145490)Robert Imschweiler1-2/+31
Implement parsing and semantic analysis support for the optional 'strict' modifier of the num_threads clause. This modifier has been introduced in OpenMP 6.0, section 12.1.2. Note: this is basically 1:1 https://reviews.llvm.org/D138328.
2025-06-14[OpenMP][clang] declare mapper: fix handling of nested types (#143504)Robert Imschweiler1-3/+9
Fix a crash that happened during parsing of a "declare mapper" construct for a struct that contains an element for which we also declared a custom default mapper.
2025-06-13Remove delayed typo expressions (#143423)Aaron Ballman1-14/+13
This removes the delayed typo correction functionality from Clang (regular typo correction still remains) due to fragility of the solution. An RFC was posted here: https://discourse.llvm.org/t/rfc-removing-support-for-delayed-typo-correction/86631 and while that RFC was asking for folks to consider stepping up to be maintainers, and we did have a few new contributors show some interest, experiments show that it's likely worth it to remove this functionality entirely and focus efforts on improving regular typo correction. This removal fixes ~20 open issues (quite possibly more), improves compile time performance by roughly .3-.4% (https://llvm-compile-time-tracker.com/?config=Overview&stat=instructions%3Au&remote=AaronBallman&sortBy=date), and does not appear to regress diagnostic behavior in a way we wouldn't find acceptable. Fixes #142457 Fixes #139913 Fixes #138850 Fixes #137867 Fixes #137860 Fixes #107840 Fixes #93308 Fixes #69470 Fixes #59391 Fixes #58172 Fixes #46215 Fixes #45915 Fixes #45891 Fixes #44490 Fixes #36703 Fixes #32903 Fixes #23312 Fixes #69874
2025-06-11[OpenMP 60] Initial parsing/sema for `need_device_addr` modifier on ↵Fazlay Rabbi1-8/+20
`adjust_args` clause (#143442) Adds initial parsing and semantic analysis for `need_device_addr` modifier on `adjust_args` clause.
2025-05-26[Parse] Remove unused includes (NFC) (#141524)Kazu Hirata1-1/+0
These are identified by misc-include-cleaner. I've filtered out those that break builds. Also, I'm staying away from llvm-config.h, config.h, and Compiler.h, which likely cause platform- or compiler-specific build failures.
2025-05-15[clang][OpenMP] Improve handling of non-C/C++ directives (#139961)Krzysztof Parzyszek1-3/+2
The PR139793 added handling of the Fortran-only "workshare" directive, however there are more such directives, e.g. "allocators". Use the genDirectiveLanguages function to detect non-C/C++ directives instead of enumerating them.
2025-05-14[OpenMP] Fix tentative parsing crash with metadirective (#139901)Aaron Ballman1-2/+9
There were two crashes that have the same root cause: not correctly handling unexpected tokens. In one case, we were failing to return early which caused us to parse a paren as a regular token instead of a special token, causing an assertion. The other case was failing to commit or revert the tentative parse action when not getting a paren when one was expected. Fixes #139665
2025-05-14[clang][OpenMP] Treat "workshare" as unknown OpenMP directive (#139793)Krzysztof Parzyszek1-0/+5
The "workshare" construct is only present in Fortran. The common OpenMP code does treat it as any other directive, but in clang we need to reject it, and do so gracefully before it encounters an internal assertion. Fixes https://github.com/llvm/llvm-project/issues/139424
2025-05-14[clang][NFC] Regroup declarations in `Parser` (#138511)Vlad Serebrennikov1-348/+0
Following the steps of #82217, this patch reorganizes declarations in `Parse.h`. Highlights are: 1) Declarations are grouped in the same fashion as in `Sema.h`. Table of contents is provided at the beginning of `Parser` class. `public` declaration go first, then `private` ones, but unlike `Sema`, most of the stuff in `Parser` is private. 2) Documentation has been moved from `.cpp` files to the header. Grammar was consistently put in `\verbatim` blocks to render nicely in Doxygen. 3) File has been formatted with clang-format, except for the grammar, because clang-format butchers it.
2025-05-12[OpenMP] Fix crash on invalid with cancel directive (#139577)Aaron Ballman1-1/+1
If the next token after 'cancel' is a special token, we would trigger an assertion. We should be consuming any token, same as elsewhere in the function. Note, we could check for an unknown directive and do different error recovery, but that caused too many behavioral changes for other tests in the form of "unexpected tokens ignored" diagnostics that didn't seem like an improvement for the test cases. Fixes #139360
2025-05-12[OpenMP] Allow begin/end declare variant in executable context (#139344)Johannes Doerfert1-66/+92
We are missing a few declerative directives in the parser for executable and declerative directives causing us to error out if they are inside of functions. This adds support for begin/end declare variant by reusing the logic we used in global scope.
2025-05-09[OpenMP] implementation set controls elision for begin declare variant (#139287)Johannes Doerfert1-1/+2
The device and implementation set should trigger elision of tokens if they do not match statically in a begin/end declare variant. This simply extends the logic from the device set only and includes the implementation set. Reported by @kkwli.
2025-05-09[clang][OpenMP] Pass OpenMP version to getOpenMPDirectiveName (#139115)Krzysztof Parzyszek1-45/+83
The OpenMP version is stored in language options in ASTContext. If the context is not available, use the fallback version. RFC: https://discourse.llvm.org/t/rfc-alternative-spellings-of-openmp-directives/85507
2025-05-02[clang][NFC] Convert `Sema::AllowFoldKind` to scoped enumVlad Serebrennikov1-1/+1
2025-05-02default clause replaced by otherwise clause for metadirective in OpenMP 5.2 ↵Urvi Rav1-0/+10
(#128640) This PR replaces the `default` clause with the `otherwise` clause for the `metadirective` in OpenMP. The `otherwise` clause serves as a fallback condition when no directive from the when clauses is selected. In the `when` clause, context selectors define traits evaluated to determine the directive to be applied. The previous merge was reverted due to a failing test case, which has now been resolved. --------- Co-authored-by: urvi-rav <urvi.rav@hpe.com>
2025-04-30[clang][NFC] Convert `Parser::CastParseKind` to scoped enumVlad Serebrennikov1-7/+8
2025-04-30[clang][NFC] Convert `Parser::TypeCastState` to scoped enumVlad Serebrennikov1-3/+4
2025-03-21[OpenMP 6.0] Parse/Sema support for reduction over private variable with ↵CHANDRA GHALE1-0/+31
reduction clause. (#129938) Initial Parse/Sema support for reduction over private variable with reduction clause. Section 7.6.10 in in OpenMP 6.0 spec. - list item in a reduction clause can now be private in the enclosing context. - Added support for _original-sharing-modifier_ with reduction clause. --------- Co-authored-by: Chandra Ghale <ghale@pe31.hpc.amslabs.hpecorp.net>
2025-03-11[clang] [OpenMP] New OpenMP 6.0 self_maps clause (#129888)Ritanya-B-Bharadwaj1-2/+31
Initial parsing/sema support for self maps in map and requirement clause [Sections 7.9.6 and 10.5.1.6 in OpenMP 6.0 spec]
2025-02-28[OpenMP] Missing implicit otherwise clause in metadirective. (#127113)Zahira Ammarguellat1-0/+9
Compiling this: `int main() {` ` #pragma omp metadirective when(use r= {condition(0)}` `: parallel for)` `for (int i=0; i<10; i++)` ; }` is generating an error: `error: expected expression` The compiler is interpreting this as if it's compiling a `#pragma omp metadirective` with no `otherwise` clause. In the OMP5.2 specs chapter 7.4 it's mentioned that: `If no otherwise clause is specified the effect is as if one was specified without an associated directive variant.` This patch fixes the issue.
2025-02-21Revert "default clause replaced by otherwise clause for metadirective in ↵Nico Weber1-20/+0
OpenMP 5.2 (#125648)" This reverts commit 73ad78cc57e10b932bddaa9034237f59bb566e6b. Breaks check-clang, see comments on https://github.com/llvm/llvm-project/pull/125648
2025-02-21default clause replaced by otherwise clause for metadirective in OpenMP 5.2 ↵Urvi Rav1-0/+20
(#125648) This PR replaces the `default` clause with the `otherwise` clause for the `metadirective` in OpenMP. The `otherwise` clause serves as a fallback condition when no directive from the `when` clauses is selected. In the `when` clause, context selectors define traits evaluated to determine the directive to be applied.
2025-02-13[Clang] [OpenMP] Add support for '#pragma omp stripe'. (#126927)Zahira Ammarguellat1-2/+3
This patch was reviewed and approved here: https://github.com/llvm/llvm-project/pull/119891 However it has been reverted here: https://github.com/alejandro-alvarez-sonarsource/llvm-project/commit/083df25dc256154cccbc0e127d79fbac4d0583c5 due to a build issue here: https://lab.llvm.org/buildbot/#/builders/51/builds/10694 This patch is reintroducing the support.
2025-02-11Revert "[Clang] [OpenMP] Add support for '#pragma omp stripe'. (#119891)"Kazu Hirata1-3/+2
This reverts commit 070f84ebc89b11df616a83a56df9ac56efbab783. Buildbot failure: https://lab.llvm.org/buildbot/#/builders/51/builds/10694
2025-02-11[Clang] [OpenMP] Add support for '#pragma omp stripe'. (#119891)Zahira Ammarguellat1-2/+3
Implement basic parsing and semantic support for `#pragma omp stripe` constuct introduced in https://www.openmp.org/wp-content/uploads/[OpenMP-API-Specification-6-0.pdf](https://www.openmp.org/wp-content/uploads/OpenMP-API-Specification-6-0.pdf), section 11.7.
2025-02-06[clang][OpenMP] New OpenMP 6.0 assumption clause, 'no_openmp_constructs' ↵David Pagan1-0/+2
(#125933) Add initial parsing/sema support for new assumption clause so clause can be specified. For now, it's ignored, just like the others. Added support for 'no_openmp_construct' to release notes. Testing - Updated appropriate LIT tests. - Testing: check-all
2025-02-05[OpenMP]Initial parsing/sema support for target_device selector set (#118471)Ritanya-B-Bharadwaj1-9/+24
This patch adds initial support for target_device selector set - Section 9.2 (Spec 6.0)
2025-01-13[clang][OpenMP] Add 'align' modifier for 'allocate' clause (#121814)David Pagan1-20/+76
The 'align' modifier is now accepted in the 'allocate' clause. Added LIT tests covering codegen, PCH, template handling, and serialization for 'align' modifier. Added support for align-modifier to release notes. Testing - New allocate modifier LIT tests. - OpenMP LIT tests. - check-all
2024-12-13[flang][OpenMP] Add frontend support for ompx_bare clause (#111106)Ivan R. Ivanov1-0/+10
2024-11-18[Parse] Remove ParseDiagnostic.h (#116496)Kazu Hirata1-1/+1
This patch removes clang/Parse/ParseDiagnostic.h because it just forwards to clang/Basic/DiagnosticParse.h.
2024-11-11[clang][OpenMP][NFC] Move 'allocate' clause modifier parsing into fun… ↵David Pagan1-17/+31
(#115775) …ction Parsing of 'allocate' clause modifier ('allocator') has been moved into a separate function in anticipation of adding another modifier ('align').
2024-11-05[clang][OpenMP] Add 'allocator' modifier for 'allocate' clause. (#114883)David Pagan1-2/+26
The 'allocator' modifier is now accepted in the 'allocate' clause. Added LIT tests covering codegen, PCH, template handling, and serialization for 'allocator' modifier. Added support for allocator-modifier to release notes. Testing - New allocate modifier LIT tests. - OpenMP LIT tests. - check-all - relevant sollve_vv test cases tests/5.2/scope/test_scope_allocate_construct.c
2024-10-24[clang] Use {} instead of std::nullopt to initialize empty ArrayRef (#109399)Jay Foad1-1/+1
Follow up to #109133.
2024-10-09[Clang][OpenMP] Add permutation clause (#92030)Michael Kruse1-0/+20
Add the permutation clause for the interchange directive which will be introduced in the upcoming OpenMP 6.0 specification. A preview has been published in [Technical Report12](https://www.openmp.org/wp-content/uploads/openmp-TR12.pdf).
2024-08-28[OpenMP][NFC] Remove executable cases from declaration switch (#106438)Mike Rice1-2/+0
The executable directives are handled earlier.
2024-08-10[Clang][Sema][OpenMP] Allow `thread_limit` to accept multiple expressions ↵Shilei Tian1-1/+1
(#102715)
2024-08-06[NFC] Fix compile warning introduced in #99732Shilei Tian1-1/+1
2024-08-06[Clang][Sema][OpenMP] Allow `num_teams` to accept multiple expressions (#99732)Shilei Tian1-1/+7
By the OpenMP standard, `num_teams` clause can only accept one expression (for now). In this patch, we extend it to allow to accept multiple expressions when it is used with `target teams ompx_bare` construct. This will allow to launch a multi-dim grid, same as CUDA/HIP.
2024-08-05Fix an unused variable and -Wswitch warning after ↵Haojian Wu1-1/+0
a42e515e3a9f3bb4e44389c097b89104d95b9b29
2024-08-05[OpenMP] OpenMP 5.1 "assume" directive parsing support (#92731)Julian Brown1-0/+127
This is a minimal patch to support parsing for "omp assume" directives. These are meant to be hints to a compiler's optimisers: as such, it is legitimate (if not very useful) to ignore them. The patch builds on top of the existing support for "omp assumes" directives (note spelling!). Unlike the "omp [begin/end] assumes" directives, "omp assume" is associated with a compound statement, i.e. it can appear within a function. The "holds" assumption could (theoretically) be mapped onto the existing builtin "__builtin_assume", though the latter applies to a single point in the program, and the former to a range (i.e. the whole of the associated compound statement). This patch fixes sollve's OpenMP 5.1 "omp assume"-based tests.