brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.0 KiB · 85d73e8 Raw
63 lines · plain
1.. title:: clang-tidy - openmp-use-default-none2 3openmp-use-default-none4=======================5 6Finds OpenMP directives that are allowed to contain a ``default`` clause,7but either don't specify it or the clause is specified but with the kind8other than ``none``, and suggests to use the ``default(none)`` clause.9 10Using ``default(none)`` clause forces developers to explicitly specify data11sharing attributes for the variables referenced in the construct,12thus making it obvious which variables are referenced, and what is their13data sharing attribute, thus increasing readability and possibly making errors14easier to spot.15 16Example17-------18 19.. code-block:: c++20 21  // ``for`` directive cannot have ``default`` clause, no diagnostics.22  void n0(const int a) {23  #pragma omp for24    for (int b = 0; b < a; b++)25      ;26  }27 28  // ``parallel`` directive.29 30  // ``parallel`` directive can have ``default`` clause, but said clause is not31  // specified, diagnosed.32  void p0_0() {33  #pragma omp parallel34    ;35    // WARNING: OpenMP directive ``parallel`` does not specify ``default``36    //          clause. Consider specifying ``default(none)`` clause.37  }38 39  // ``parallel`` directive can have ``default`` clause, and said clause is40  // specified, with ``none`` kind, all good.41  void p0_1() {42  #pragma omp parallel default(none)43    ;44  }45 46  // ``parallel`` directive can have ``default`` clause, and said clause is47  // specified, but with ``shared`` kind, which is not ``none``, diagnose.48  void p0_2() {49  #pragma omp parallel default(shared)50    ;51    // WARNING: OpenMP directive ``parallel`` specifies ``default(shared)``52    //          clause. Consider using ``default(none)`` clause instead.53  }54 55  // ``parallel`` directive can have ``default`` clause, and said clause is56  // specified, but with ``firstprivate`` kind, which is not ``none``, diagnose.57  void p0_3() {58  #pragma omp parallel default(firstprivate)59    ;60    // WARNING: OpenMP directive ``parallel`` specifies ``default(firstprivate)``61    //          clause. Consider using ``default(none)`` clause instead.62  }63