[clang] [OpenACC] Implement 'var' parsing correctly, support array sections (PR #77617)

via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 10 07:32:14 PST 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 6876fe53afabfc6f0c3b5e7c838f32a282da6f77 d38a6b7ac88d2e97eaf2f479b01be00e042d545b -- clang/include/clang/Parse/Parser.h clang/lib/AST/ASTContext.cpp clang/lib/Parse/ParseExpr.cpp clang/lib/Parse/ParseOpenACC.cpp clang/test/ParserOpenACC/parse-cache-construct.c clang/test/ParserOpenACC/parse-cache-construct.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index d3c51a3609..dcfd290d39 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -2013,8 +2013,7 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {
           ColonLocFirst = ConsumeToken();
           Length = Actions.CorrectDelayedTyposInExpr(ParseExpression());
         }
-      }
-      else if (ArgExprs.size() <= 1 && getLangOpts().OpenMP) {
+      } else if (ArgExprs.size() <= 1 && getLangOpts().OpenMP) {
         ColonProtectionRAIIObject RAII(*this);
         if (Tok.is(tok::colon)) {
           // Consume ':'
@@ -2052,8 +2051,7 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {
           // well.
           LHS = Actions.ActOnOMPArraySectionExpr(
               LHS.get(), Loc, ArgExprs.empty() ? nullptr : ArgExprs[0],
-              ColonLocFirst, ColonLocSecond, Length.get(), Stride.get(),
-              RLoc);
+              ColonLocFirst, ColonLocSecond, Length.get(), Stride.get(), RLoc);
         } else {
           LHS = Actions.ActOnArraySubscriptExpr(getCurScope(), LHS.get(), Loc,
                                                 ArgExprs, RLoc);
diff --git a/clang/lib/Parse/ParseOpenACC.cpp b/clang/lib/Parse/ParseOpenACC.cpp
index 4134c236b9..fc82324e23 100644
--- a/clang/lib/Parse/ParseOpenACC.cpp
+++ b/clang/lib/Parse/ParseOpenACC.cpp
@@ -598,9 +598,9 @@ void Parser::ParseOpenACCCacheVarList() {
 
     // OpenACC 3.3, section 2.10:
     // A 'var' in a cache directive must be a single array element or a simple
-    // subarray.  In C and C++, a simple subarray is an array name followed by an
-    // extended array range specification in brackets, with a start and length such
-    // as:
+    // subarray.  In C and C++, a simple subarray is an array name followed by
+    // an extended array range specification in brackets, with a start and
+    // length such as:
     //
     // arr[lower:length]
     //

``````````

</details>


https://github.com/llvm/llvm-project/pull/77617


More information about the cfe-commits mailing list