[clang] [OpenACC] Implement 'if' clause for Compute Constructs (PR #88411)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 11 09:36:45 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 44718311dee486f1823876e8af9100afcc50041b 408f39f8ed0ee121aeaeb15c02603bb127e8cb73 -- clang/test/SemaOpenACC/compute-construct-if-clause.c clang/test/SemaOpenACC/compute-construct-if-clause.cpp clang/include/clang/AST/ASTNodeTraverser.h 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/test/SemaOpenACC/compute-construct-clause-ast.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/include/clang/AST/ASTNodeTraverser.h b/clang/include/clang/AST/ASTNodeTraverser.h
index 37fe030fb8..995528fc88 100644
--- a/clang/include/clang/AST/ASTNodeTraverser.h
+++ b/clang/include/clang/AST/ASTNodeTraverser.h
@@ -244,7 +244,7 @@ public:
getNodeDelegate().AddChild([=] {
getNodeDelegate().Visit(C);
for (const auto *S : C->children())
- Visit(S);
+ Visit(S);
});
}
diff --git a/clang/include/clang/AST/OpenACCClause.h b/clang/include/clang/AST/OpenACCClause.h
index 6e3c006141..b8879328a9 100644
--- a/clang/include/clang/AST/OpenACCClause.h
+++ b/clang/include/clang/AST/OpenACCClause.h
@@ -14,8 +14,8 @@
#ifndef LLVM_CLANG_AST_OPENACCCLAUSE_H
#define LLVM_CLANG_AST_OPENACCCLAUSE_H
#include "clang/AST/ASTContext.h"
-#include "clang/Basic/OpenACCKinds.h"
#include "clang/AST/StmtIterator.h"
+#include "clang/Basic/OpenACCKinds.h"
namespace clang {
/// This is the base type for all OpenACC Clauses.
@@ -68,7 +68,6 @@ public:
const_child_range children() const {
return const_child_range(const_child_iterator(), const_child_iterator());
}
-
};
/// A 'default' clause, has the optional 'none' or 'present' argument.
@@ -106,14 +105,14 @@ public:
class OpenACCClauseWithCondition : public OpenACCClauseWithParams {
Expr *ConditionExpr;
- protected:
- OpenACCClauseWithCondition(OpenACCClauseKind K, SourceLocation BeginLoc,
- SourceLocation LParenLoc,
- Expr *ConditionExpr, SourceLocation EndLoc)
- : OpenACCClauseWithParams(K, BeginLoc, LParenLoc, EndLoc),
- ConditionExpr(ConditionExpr) {}
+protected:
+ OpenACCClauseWithCondition(OpenACCClauseKind K, SourceLocation BeginLoc,
+ SourceLocation LParenLoc, Expr *ConditionExpr,
+ SourceLocation EndLoc)
+ : OpenACCClauseWithParams(K, BeginLoc, LParenLoc, EndLoc),
+ ConditionExpr(ConditionExpr) {}
- public:
+public:
bool hasConditionExpr() const { return ConditionExpr; }
const Expr *getConditionExpr() const { return ConditionExpr; }
Expr *getConditionExpr() { return ConditionExpr; }
@@ -142,8 +141,7 @@ protected:
public:
static OpenACCIfClause *Create(const ASTContext &C, SourceLocation BeginLoc,
- SourceLocation LParenLoc,
- Expr *ConditionExpr,
+ SourceLocation LParenLoc, Expr *ConditionExpr,
SourceLocation EndLoc);
};
@@ -215,8 +213,8 @@ public:
#define VISIT_CLAUSE(CLAUSE_NAME) \
void VisitOpenACC##CLAUSE_NAME##Clause( \
- const OpenACC##CLAUSE_NAME##Clause &Clause) {\
- return getDerived().VisitOpenACC##CLAUSE_NAME##Clause(Clause); \
+ const OpenACC##CLAUSE_NAME##Clause &Clause) { \
+ return getDerived().VisitOpenACC##CLAUSE_NAME##Clause(Clause); \
}
#include "clang/Basic/OpenACCClauses.def"
@@ -239,7 +237,7 @@ public:
#define VISIT_CLAUSE(CLAUSE_NAME) \
void VisitOpenACC##CLAUSE_NAME##Clause( \
- const OpenACC##CLAUSE_NAME##Clause &Clause);
+ const OpenACC##CLAUSE_NAME##Clause &Clause);
#include "clang/Basic/OpenACCClauses.def"
};
diff --git a/clang/include/clang/Parse/Parser.h b/clang/include/clang/Parse/Parser.h
index 9d83a52929..db90d38c7d 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -3662,6 +3662,7 @@ private:
bool ParseOpenACCGangArg();
/// Parses a 'condition' expr, ensuring it results in a
ExprResult ParseOpenACCConditionExpr();
+
private:
//===--------------------------------------------------------------------===//
// C++ 14: Templates [temp]
diff --git a/clang/lib/AST/OpenACCClause.cpp b/clang/lib/AST/OpenACCClause.cpp
index 0a512d4825..2bc8d14fa1 100644
--- a/clang/lib/AST/OpenACCClause.cpp
+++ b/clang/lib/AST/OpenACCClause.cpp
@@ -12,8 +12,8 @@
//===----------------------------------------------------------------------===//
#include "clang/AST/OpenACCClause.h"
-#include "clang/AST/Expr.h"
#include "clang/AST/ASTContext.h"
+#include "clang/AST/Expr.h"
using namespace clang;
@@ -38,8 +38,7 @@ OpenACCIfClause *OpenACCIfClause::Create(const ASTContext &C,
}
OpenACCIfClause::OpenACCIfClause(SourceLocation BeginLoc,
- SourceLocation LParenLoc,
- Expr *ConditionExpr,
+ SourceLocation LParenLoc, Expr *ConditionExpr,
SourceLocation EndLoc)
: OpenACCClauseWithCondition(OpenACCClauseKind::If, BeginLoc, LParenLoc,
ConditionExpr, EndLoc) {
@@ -51,12 +50,12 @@ OpenACCIfClause::OpenACCIfClause(SourceLocation BeginLoc,
OpenACCClause::child_range OpenACCClause::children() {
switch (getClauseKind()) {
- default:
- assert(false && "Clause children function not implemented");
- break;
+ default:
+ assert(false && "Clause children function not implemented");
+ break;
#define VISIT_CLAUSE(CLAUSE_NAME) \
- case OpenACCClauseKind::CLAUSE_NAME: \
- return cast<OpenACC##CLAUSE_NAME##Clause>(this)->children();
+ case OpenACCClauseKind::CLAUSE_NAME: \
+ return cast<OpenACC##CLAUSE_NAME##Clause>(this)->children();
#include "clang/Basic/OpenACCClauses.def"
}
@@ -71,7 +70,6 @@ void OpenACCClausePrinter::VisitOpenACCDefaultClause(
OS << "default(" << C.getDefaultClauseKind() << ")";
}
-void OpenACCClausePrinter::VisitOpenACCIfClause(
- const OpenACCIfClause &C) {
+void OpenACCClausePrinter::VisitOpenACCIfClause(const OpenACCIfClause &C) {
OS << "if(" << C.getConditionExpr() << ")";
}
diff --git a/clang/lib/AST/StmtProfile.cpp b/clang/lib/AST/StmtProfile.cpp
index 24593fd2f4..44b635bfb8 100644
--- a/clang/lib/AST/StmtProfile.cpp
+++ b/clang/lib/AST/StmtProfile.cpp
@@ -2445,10 +2445,10 @@ void StmtProfiler::VisitTemplateArgument(const TemplateArgument &Arg) {
namespace {
class OpenACCClauseProfiler
: public OpenACCClauseVisitor<OpenACCClauseProfiler> {
- StmtProfiler &Profiler;
+ StmtProfiler &Profiler;
public:
- OpenACCClauseProfiler(StmtProfiler &P) :Profiler(P) {}
+ OpenACCClauseProfiler(StmtProfiler &P) : Profiler(P) {}
void VisitOpenACCClauseList(ArrayRef<const OpenACCClause *> Clauses) {
for (const OpenACCClause *Clause : Clauses) {
@@ -2472,9 +2472,9 @@ void OpenACCClauseProfiler::VisitOpenACCDefaultClause(
void OpenACCClauseProfiler::VisitOpenACCIfClause(
const OpenACCIfClause &Clause) {
assert(Clause.hasConditionExpr() &&
- "if clause requires a valid condition expr");
+ "if clause requires a valid condition expr");
Profiler.VisitStmt(Clause.getConditionExpr());
- }
+}
} // namespace
void StmtProfiler::VisitOpenACCComputeConstruct(
diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp
index 56650f9913..e9cae15f38 100644
--- a/clang/lib/AST/TextNodeDumper.cpp
+++ b/clang/lib/AST/TextNodeDumper.cpp
@@ -401,7 +401,7 @@ void TextNodeDumper::Visit(const OpenACCClause *C) {
// The condition expression will be printed as a part of the 'children',
// but print 'clause' here so it is clear what is happening from the dump.
OS << " clause";
- break;
+ break;
default:
// Nothing to do here.
break;
diff --git a/clang/lib/Parse/ParseOpenACC.cpp b/clang/lib/Parse/ParseOpenACC.cpp
index 6192afa854..91f2b8afcf 100644
--- a/clang/lib/Parse/ParseOpenACC.cpp
+++ b/clang/lib/Parse/ParseOpenACC.cpp
@@ -601,7 +601,7 @@ ExprResult Parser::ParseOpenACCConditionExpr() {
getActions().ActOnCondition(getCurScope(), ER.get()->getExprLoc(),
ER.get(), Sema::ConditionKind::Boolean);
- return R.isInvalid() ? ExprError () : R.get().second;
+ return R.isInvalid() ? ExprError() : R.get().second;
}
// OpenACC 3.3, section 1.7:
@@ -852,8 +852,8 @@ Parser::OpenACCClauseParseResult Parser::ParseOpenACCClauseParams(
}
case OpenACCClauseKind::If: {
ExprResult CondExpr = ParseOpenACCConditionExpr();
- ParsedClause.setConditionDetails(
- CondExpr.isUsable() ? CondExpr.get() : nullptr);
+ ParsedClause.setConditionDetails(CondExpr.isUsable() ? CondExpr.get()
+ : nullptr);
if (CondExpr.isInvalid()) {
Parens.skipToEnd();
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp
index a5cb7c6812..b4f0704c63 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -7428,7 +7428,7 @@ void ASTRecordWriter::writeOpenACCClause(const OpenACCClause *C) {
case OpenACCClauseKind::If: {
const auto *IC = cast<OpenACCIfClause>(C);
writeSourceLocation(IC->getLParenLoc());
- AddStmt(const_cast<Expr*>(IC->getConditionExpr()));
+ AddStmt(const_cast<Expr *>(IC->getConditionExpr()));
return;
}
case OpenACCClauseKind::Finalize:
``````````
</details>
https://github.com/llvm/llvm-project/pull/88411
More information about the cfe-commits
mailing list