Files
TheRock/compiler/amd-llvm/clang/test/OpenMP/reverse_ast_print.cpp
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

160 lines
4.4 KiB
C++

// Check no warnings/errors
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -fsyntax-only -verify %s
// expected-no-diagnostics
// Check AST and unparsing
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -ast-dump %s | FileCheck %s --check-prefix=DUMP
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -ast-print %s | FileCheck %s --check-prefix=PRINT
// Check same results after serialization round-trip
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -emit-pch -o %t %s
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -include-pch %t -ast-dump-all %s | FileCheck %s --check-prefix=DUMP
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp -fopenmp-version=60 -include-pch %t -ast-print %s | FileCheck %s --check-prefix=PRINT
#ifndef HEADER
#define HEADER
// placeholder for loop body code.
extern "C" void body(...);
// PRINT-LABEL: void foo1(
// DUMP-LABEL: FunctionDecl {{.*}} foo1
void foo1() {
// PRINT: #pragma omp reverse
// DUMP: OMPReverseDirective
#pragma omp reverse
// PRINT: for (int i = 7; i < 17; i += 3)
// DUMP-NEXT: ForStmt
for (int i = 7; i < 17; i += 3)
// PRINT: body(i);
// DUMP: CallExpr
body(i);
}
// PRINT-LABEL: void foo2(
// DUMP-LABEL: FunctionDecl {{.*}} foo2
void foo2(int start, int end, int step) {
// PRINT: #pragma omp reverse
// DUMP: OMPReverseDirective
#pragma omp reverse
// PRINT: for (int i = start; i < end; i += step)
// DUMP-NEXT: ForStmt
for (int i = start; i < end; i += step)
// PRINT: body(i);
// DUMP: CallExpr
body(i);
}
// PRINT-LABEL: void foo3(
// DUMP-LABEL: FunctionDecl {{.*}} foo3
void foo3() {
// PRINT: #pragma omp for
// DUMP: OMPForDirective
// DUMP-NEXT: CapturedStmt
// DUMP-NEXT: CapturedDecl
#pragma omp for
// PRINT: #pragma omp reverse
// DUMP-NEXT: OMPReverseDirective
#pragma omp reverse
for (int i = 7; i < 17; i += 3)
// PRINT: body(i);
// DUMP: CallExpr
body(i);
}
// PRINT-LABEL: void foo4(
// DUMP-LABEL: FunctionDecl {{.*}} foo4
void foo4() {
// PRINT: #pragma omp for collapse(2)
// DUMP: OMPForDirective
// DUMP-NEXT: OMPCollapseClause
// DUMP-NEXT: ConstantExpr
// DUMP-NEXT: value: Int 2
// DUMP-NEXT: IntegerLiteral {{.*}} 2
// DUMP-NEXT: CapturedStmt
// DUMP-NEXT: CapturedDecl
#pragma omp for collapse(2)
// PRINT: #pragma omp reverse
// DUMP: OMPReverseDirective
#pragma omp reverse
// PRINT: for (int i = 7; i < 17; i += 1)
// DUMP-NEXT: ForStmt
for (int i = 7; i < 17; i += 1)
// PRINT: for (int j = 7; j < 17; j += 1)
// DUMP: ForStmt
for (int j = 7; j < 17; j += 1)
// PRINT: body(i, j);
// DUMP: CallExpr
body(i, j);
}
// PRINT-LABEL: void foo5(
// DUMP-LABEL: FunctionDecl {{.*}} foo5
void foo5(int start, int end, int step) {
// PRINT: #pragma omp for collapse(2)
// DUMP: OMPForDirective
// DUMP-NEXT: OMPCollapseClause
// DUMP-NEXT: ConstantExpr
// DUMP-NEXT: value: Int 2
// DUMP-NEXT: IntegerLiteral {{.*}} 2
// DUMP-NEXT: CapturedStmt
// DUMP-NEXT: CapturedDecl
#pragma omp for collapse(2)
// PRINT: for (int i = 7; i < 17; i += 1)
// DUMP-NEXT: ForStmt
for (int i = 7; i < 17; i += 1)
// PRINT: #pragma omp reverse
// DUMP: OMPReverseDirective
#pragma omp reverse
// PRINT: for (int j = 7; j < 17; j += 1)
// DUMP-NEXT: ForStmt
for (int j = 7; j < 17; j += 1)
// PRINT: body(i, j);
// DUMP: CallExpr
body(i, j);
}
// PRINT-LABEL: void foo6(
// DUMP-LABEL: FunctionTemplateDecl {{.*}} foo6
template<typename T, T Step>
void foo6(T start, T end) {
// PRINT: #pragma omp reverse
// DUMP: OMPReverseDirective
#pragma omp reverse
// PRINT-NEXT: for (T i = start; i < end; i += Step)
// DUMP-NEXT: ForStmt
for (T i = start; i < end; i += Step)
// PRINT-NEXT: body(i);
// DUMP: CallExpr
body(i);
}
// Also test instantiating the template.
void tfoo6() {
foo6<int,3>(0, 42);
}
// PRINT-LABEL: void foo7(
// DUMP-LABEL: FunctionDecl {{.*}} foo7
void foo7() {
double arr[128];
// PRINT: #pragma omp reverse
// DUMP: OMPReverseDirective
#pragma omp reverse
// PRINT-NEXT: for (auto &&v : arr)
// DUMP-NEXT: CXXForRangeStmt
for (auto &&v : arr)
// PRINT-NEXT: body(v);
// DUMP: CallExpr
body(v);
}
#endif