[clang] [llvm] [clang][OpenMP] Shorten directive classification in ParseOpenMP (PR #94691)
Krzysztof Parzyszek via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 25 09:09:39 PDT 2024
================
@@ -2503,24 +2621,36 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective(
"Not an OpenMP directive!");
ParsingOpenMPDirectiveRAII DirScope(*this);
ParenBraceBracketBalancer BalancerRAIIObj(*this);
- SmallVector<OMPClause *, 5> Clauses;
- std::bitset<llvm::omp::Clause_enumSize + 1> SeenClauses;
- unsigned ScopeFlags = Scope::FnScope | Scope::DeclScope |
- Scope::CompoundStmtScope | Scope::OpenMPDirectiveScope;
SourceLocation Loc = ReadDirectiveWithinMetadirective
? Tok.getLocation()
- : ConsumeAnnotationToken(),
- EndLoc;
+ : ConsumeAnnotationToken();
OpenMPDirectiveKind DKind = parseOpenMPDirectiveKind(*this);
if (ReadDirectiveWithinMetadirective && DKind == OMPD_unknown) {
Diag(Tok, diag::err_omp_unknown_directive);
return StmtError();
}
- OpenMPDirectiveKind CancelRegion = OMPD_unknown;
- // Name of critical directive.
- DeclarationNameInfo DirName;
+
StmtResult Directive = StmtError();
- bool HasAssociatedStatement = true;
+
+ bool IsExecutable = [&]() {
+ if (DKind == OMPD_error) // OMPD_error is handled as executable
+ return true;
+ switch (getDirectiveCategory(DKind)) {
+ case Category::Executable:
+ case Category::Subsidiary:
+ return true;
+ default:
+ break;
+ }
+ return false;
+ }();
+
+ if (IsExecutable) {
+ Directive = ParseOpenMPExecutableDirective(
+ StmtCtx, DKind, Loc, ReadDirectiveWithinMetadirective);
+ assert(!Directive.isUnset());
----------------
kparzysz wrote:
Done
https://github.com/llvm/llvm-project/pull/94691
More information about the cfe-commits
mailing list