Skip to content

[flang][OpenMP] Pass OpenMP version to getOpenMPDirectiveName #139131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
May 9, 2025
Prev Previous commit
Next Next commit
Don't put OpenMP "Version" in StmtPrinter
  • Loading branch information
kparzysz committed May 8, 2025
commit 49be4a458512a1cf312c40bdf5cf88541a4b1243
17 changes: 10 additions & 7 deletions clang/lib/AST/StmtPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,13 @@ namespace {
PrintingPolicy Policy;
std::string NL;
const ASTContext *Context;
unsigned Version;

public:
StmtPrinter(raw_ostream &os, PrinterHelper *helper,
const PrintingPolicy &Policy, unsigned Indentation = 0,
StringRef NL = "\n", const ASTContext *Context = nullptr)
: OS(os), IndentLevel(Indentation), Helper(helper), Policy(Policy),
NL(NL), Context(Context),
Version(Context ? Context->getLangOpts().OpenMP
: llvm::omp::FallbackVersion) {}
NL(NL), Context(Context) {}

void PrintStmt(Stmt *S) { PrintStmt(S, Policy.Indentation); }

Expand Down Expand Up @@ -740,7 +737,9 @@ void StmtPrinter::VisitOMPCanonicalLoop(OMPCanonicalLoop *Node) {

void StmtPrinter::PrintOMPExecutableDirective(OMPExecutableDirective *S,
bool ForceNoStmt) {
OMPClausePrinter Printer(OS, Policy, Version);
unsigned OpenMPVersion =
Context ? Context->getLangOpts().OpenMP : llvm::omp::FallbackVersion;
OMPClausePrinter Printer(OS, Policy, OpenMPVersion);
ArrayRef<OMPClause *> Clauses = S->clauses();
for (auto *Clause : Clauses)
if (Clause && !Clause->isImplicit()) {
Expand Down Expand Up @@ -967,14 +966,18 @@ void StmtPrinter::VisitOMPTeamsDirective(OMPTeamsDirective *Node) {

void StmtPrinter::VisitOMPCancellationPointDirective(
OMPCancellationPointDirective *Node) {
unsigned OpenMPVersion =
Context ? Context->getLangOpts().OpenMP : llvm::omp::FallbackVersion;
Indent() << "#pragma omp cancellation point "
<< getOpenMPDirectiveName(Node->getCancelRegion(), Version);
<< getOpenMPDirectiveName(Node->getCancelRegion(), OpenMPVersion);
PrintOMPExecutableDirective(Node);
}

void StmtPrinter::VisitOMPCancelDirective(OMPCancelDirective *Node) {
unsigned OpenMPVersion =
Context ? Context->getLangOpts().OpenMP : llvm::omp::FallbackVersion;
Indent() << "#pragma omp cancel "
<< getOpenMPDirectiveName(Node->getCancelRegion(), Version);
<< getOpenMPDirectiveName(Node->getCancelRegion(), OpenMPVersion);
PrintOMPExecutableDirective(Node);
}

Expand Down