-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[clang][OpenMP] Add AST node for root of compound directive #118878
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
base: users/kparzysz/spr/p03-a01-clang-opaque-directive
Are you sure you want to change the base?
[clang][OpenMP] Add AST node for root of compound directive #118878
Conversation
This will be used to print the original directive source from the AST after splitting compound directives.
You can test this locally with the following command:git-clang-format --diff 5f1cc61eaf6df0f74dfe6871d089f5a1f2e405ad 283b0b527836bee29cf633964fa0474f931a9bfc --extensions cpp,h -- clang/include/clang-c/Index.h clang/include/clang/AST/RecursiveASTVisitor.h clang/include/clang/AST/StmtOpenMP.h clang/include/clang/AST/TextNodeDumper.h clang/include/clang/Sema/SemaOpenMP.h clang/include/clang/Serialization/ASTBitCodes.h clang/lib/AST/StmtOpenMP.cpp clang/lib/AST/StmtPrinter.cpp clang/lib/AST/StmtProfile.cpp clang/lib/AST/TextNodeDumper.cpp clang/lib/CodeGen/CGStmt.cpp clang/lib/Sema/SemaExceptionSpec.cpp clang/lib/Sema/SemaOpenMP.cpp clang/lib/Sema/TreeTransform.h clang/lib/Serialization/ASTReaderStmt.cpp clang/lib/Serialization/ASTWriterStmt.cpp clang/lib/StaticAnalyzer/Core/ExprEngine.cpp View the diff from clang-format here.diff --git a/clang/include/clang/AST/StmtOpenMP.h b/clang/include/clang/AST/StmtOpenMP.h
index 0d05dfd795..df43f348b4 100644
--- a/clang/include/clang/AST/StmtOpenMP.h
+++ b/clang/include/clang/AST/StmtOpenMP.h
@@ -1613,9 +1613,9 @@ public:
/// \param DKind The OpenMP directive kind.
/// \param NumClauses Number of clauses.
///
- static OMPCompoundRootDirective *
- CreateEmpty(const ASTContext &C, OpenMPDirectiveKind DKind,
- unsigned NumClauses, EmptyShell);
+ static OMPCompoundRootDirective *CreateEmpty(const ASTContext &C,
+ OpenMPDirectiveKind DKind,
+ unsigned NumClauses, EmptyShell);
static bool classof(const Stmt *T) {
return T->getStmtClass() == OMPCompoundRootDirectiveClass;
diff --git a/clang/lib/AST/StmtOpenMP.cpp b/clang/lib/AST/StmtOpenMP.cpp
index f86bbff57d..a1add69be5 100644
--- a/clang/lib/AST/StmtOpenMP.cpp
+++ b/clang/lib/AST/StmtOpenMP.cpp
@@ -269,9 +269,10 @@ OMPCompoundRootDirective *OMPCompoundRootDirective::Create(
return Dir;
}
-OMPCompoundRootDirective *OMPCompoundRootDirective::CreateEmpty(
- const ASTContext &C, OpenMPDirectiveKind DKind, unsigned NumClauses,
- EmptyShell) {
+OMPCompoundRootDirective *
+OMPCompoundRootDirective::CreateEmpty(const ASTContext &C,
+ OpenMPDirectiveKind DKind,
+ unsigned NumClauses, EmptyShell) {
return createEmptyDirective<OMPCompoundRootDirective>(
C, NumClauses, /*HasAssociatedStmt=*/true, /*NumChildren=*/1, DKind);
}
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index a19a692edb..9518614c2e 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -23312,8 +23312,8 @@ static bool checkScanScope(Sema &S, Scope *CurrentS, SourceLocation Loc);
StmtResult SemaOpenMP::ActOnOpenMPCompoundRootDirective(
OpenMPDirectiveKind DKind, ArrayRef<OMPClause *> Clauses, Stmt *AStmt,
Stmt *UStmt, SourceLocation StartLoc, SourceLocation EndLoc) {
- return OMPCompoundRootDirective::Create(
- getASTContext(), StartLoc, EndLoc, DKind, Clauses, AStmt, UStmt);
+ return OMPCompoundRootDirective::Create(getASTContext(), StartLoc, EndLoc,
+ DKind, Clauses, AStmt, UStmt);
}
StmtResult SemaOpenMP::ActOnOpenMPOpaqueBlockDirective(
|
That statement will be ignored for all purposes, except for regenerating the original source code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks reasonable to me. I left one comment and I believe you can verify what is best yourself.
OMPCompoundRootDirective *D) { | ||
// This function should never be found in a template. Directive splitting | ||
// only happens in non-template functions. | ||
llvm_unreachable("TransformOMPCompoundRootDirective in a template"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure llvm_unreachable is the right kind of error here. Maybe it is. Is there precedent?
This will be used to print the original directive source from the AST after splitting compound directives.