[clang] [OpenACC] Implement 'num_workers' clause for compute constructs (PR #89151)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 17 15:20:59 PDT 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 693a458287d019c5c6a66fe3019d099df2978cdb d3894971090921b92c71ba5a18151cb2033c8cfa -- clang/test/SemaOpenACC/compute-construct-intexpr-clause-ast.cpp clang/test/SemaOpenACC/compute-construct-num_workers-clause.c clang/test/SemaOpenACC/compute-construct-num_workers-clause.cpp clang/include/clang/AST/OpenACCClause.h clang/include/clang/Parse/Parser.h clang/include/clang/Sema/SemaOpenACC.h clang/lib/AST/OpenACCClause.cpp clang/lib/AST/StmtProfile.cpp clang/lib/AST/TextNodeDumper.cpp clang/lib/Parse/ParseOpenACC.cpp clang/lib/Sema/SemaOpenACC.cpp clang/lib/Sema/TreeTransform.h clang/lib/Serialization/ASTReader.cpp clang/lib/Serialization/ASTWriter.cpp clang/test/ParserOpenACC/parse-clauses.c clang/tools/libclang/CIndex.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/include/clang/AST/OpenACCClause.h b/clang/include/clang/AST/OpenACCClause.h
index 7a60620d58..aeb359ab7e 100644
--- a/clang/include/clang/AST/OpenACCClause.h
+++ b/clang/include/clang/AST/OpenACCClause.h
@@ -162,18 +162,18 @@ public:
class OpenACCClauseWithIntExprs : public OpenACCClauseWithParams {
llvm::SmallVector<Expr *> IntExprs;
- protected:
- OpenACCClauseWithIntExprs(OpenACCClauseKind K, SourceLocation BeginLoc,
- SourceLocation LParenLoc,
- ArrayRef<Expr *> IntExprs, SourceLocation EndLoc)
- : OpenACCClauseWithParams(K, BeginLoc, LParenLoc, EndLoc),
- IntExprs(IntExprs) {}
-
- /// Gets the entire list of integer expressions, but leave it to the
- /// individual clauses to expose this how they'd like.
- llvm::ArrayRef<Expr *> getIntExprs() const { return IntExprs; }
-
- public:
+protected:
+ OpenACCClauseWithIntExprs(OpenACCClauseKind K, SourceLocation BeginLoc,
+ SourceLocation LParenLoc, ArrayRef<Expr *> IntExprs,
+ SourceLocation EndLoc)
+ : OpenACCClauseWithParams(K, BeginLoc, LParenLoc, EndLoc),
+ IntExprs(IntExprs) {}
+
+ /// Gets the entire list of integer expressions, but leave it to the
+ /// individual clauses to expose this how they'd like.
+ llvm::ArrayRef<Expr *> getIntExprs() const { return IntExprs; }
+
+public:
child_range children() {
return child_range(reinterpret_cast<Stmt **>(IntExprs.begin()),
reinterpret_cast<Stmt **>(IntExprs.end()));
@@ -189,27 +189,29 @@ class OpenACCClauseWithIntExprs : public OpenACCClauseWithParams {
/// A more restrictive version of the IntExprs version that exposes a single
/// integer expression.
class OpenACCClauseWithSingleIntExpr : public OpenACCClauseWithIntExprs {
- protected:
- OpenACCClauseWithSingleIntExpr(OpenACCClauseKind K, SourceLocation BeginLoc,
- SourceLocation LParenLoc, Expr *IntExpr,
- SourceLocation EndLoc)
- : OpenACCClauseWithIntExprs(K, BeginLoc, LParenLoc, IntExpr, EndLoc) {}
-
- public:
- bool hasIntExpr() const { return !getIntExprs().empty(); }
- const Expr *getIntExpr() const {
- return hasIntExpr() ? getIntExprs()[0] : nullptr;
- }
- Expr *getIntExpr() { return hasIntExpr() ? getIntExprs()[0] : nullptr; }
+protected:
+ OpenACCClauseWithSingleIntExpr(OpenACCClauseKind K, SourceLocation BeginLoc,
+ SourceLocation LParenLoc, Expr *IntExpr,
+ SourceLocation EndLoc)
+ : OpenACCClauseWithIntExprs(K, BeginLoc, LParenLoc, IntExpr, EndLoc) {}
+
+public:
+ bool hasIntExpr() const { return !getIntExprs().empty(); }
+ const Expr *getIntExpr() const {
+ return hasIntExpr() ? getIntExprs()[0] : nullptr;
+ }
+ Expr *getIntExpr() { return hasIntExpr() ? getIntExprs()[0] : nullptr; }
};
class OpenACCNumWorkersClause : public OpenACCClauseWithSingleIntExpr {
OpenACCNumWorkersClause(SourceLocation BeginLoc, SourceLocation LParenLoc,
Expr *IntExpr, SourceLocation EndLoc);
- public:
- static OpenACCNumWorkersClause *
- Create(const ASTContext &C, SourceLocation BeginLoc,
- SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc);
+
+public:
+ static OpenACCNumWorkersClause *Create(const ASTContext &C,
+ SourceLocation BeginLoc,
+ SourceLocation LParenLoc,
+ Expr *IntExpr, SourceLocation EndLoc);
};
template <class Impl> class OpenACCClauseVisitor {
diff --git a/clang/include/clang/Sema/SemaOpenACC.h b/clang/include/clang/Sema/SemaOpenACC.h
index eb461fa7db..b995edebe8 100644
--- a/clang/include/clang/Sema/SemaOpenACC.h
+++ b/clang/include/clang/Sema/SemaOpenACC.h
@@ -105,7 +105,7 @@ public:
}
ArrayRef<Expr *> getIntExprs() const {
- return const_cast<OpenACCParsedClause*>(this)->getIntExprs();
+ return const_cast<OpenACCParsedClause *>(this)->getIntExprs();
}
void setLParenLoc(SourceLocation EndLoc) { LParenLoc = EndLoc; }
diff --git a/clang/lib/Sema/SemaOpenACC.cpp b/clang/lib/Sema/SemaOpenACC.cpp
index 316b0f15b0..eb46180de1 100644
--- a/clang/lib/Sema/SemaOpenACC.cpp
+++ b/clang/lib/Sema/SemaOpenACC.cpp
@@ -280,8 +280,8 @@ void SemaOpenACC::ActOnConstruct(OpenACCDirectiveKind K,
}
ExprResult SemaOpenACC::ActOnIntExpr(OpenACCDirectiveKind DK,
- OpenACCClauseKind CK,
- SourceLocation Loc, Expr *IntExpr) {
+ OpenACCClauseKind CK, SourceLocation Loc,
+ Expr *IntExpr) {
assert(((DK != OpenACCDirectiveKind::Invalid &&
CK == OpenACCClauseKind::Invalid) ||
@@ -361,8 +361,7 @@ ExprResult SemaOpenACC::ActOnIntExpr(OpenACCDirectiveKind DK,
return ExprError();
IntExpr = IntExprResult.get();
- if (!IntExpr->isTypeDependent() &&
- !IntExpr->getType()->isIntegerType())
+ if (!IntExpr->isTypeDependent() && !IntExpr->getType()->isIntegerType())
return ExprError();
// TODO OpenACC: Do we want to perform usual unary conversions here? When
``````````
</details>
https://github.com/llvm/llvm-project/pull/89151
More information about the cfe-commits
mailing list