@@ -1479,14 +1479,6 @@ class OmpVisitor : public virtual DeclarationVisitor {
1479
1479
static bool NeedsScope (const parser::OmpBlockConstruct &);
1480
1480
static bool NeedsScope (const parser::OmpClause &);
1481
1481
1482
- bool Pre (const parser::OmpMetadirectiveDirective &x) { //
1483
- ++metaLevel_;
1484
- return true ;
1485
- }
1486
- void Post (const parser::OmpMetadirectiveDirective &) { //
1487
- --metaLevel_;
1488
- }
1489
-
1490
1482
bool Pre (const parser::OpenMPRequiresConstruct &x) {
1491
1483
AddOmpSourceRange (x.source );
1492
1484
return true ;
@@ -1579,10 +1571,11 @@ class OmpVisitor : public virtual DeclarationVisitor {
1579
1571
1580
1572
bool Pre (const parser::OpenMPDeclareReductionConstruct &x) {
1581
1573
AddOmpSourceRange (x.source );
1574
+ parser::OmpClauseList empty (std::list<parser::OmpClause>{});
1575
+ auto &maybeClauses{std::get<std::optional<parser::OmpClauseList>>(x.t )};
1582
1576
ProcessReductionSpecifier (
1583
1577
std::get<Indirection<parser::OmpReductionSpecifier>>(x.t ).value (),
1584
- std::get<std::optional<parser::OmpClauseList>>(x.t ),
1585
- declaratives_.back ());
1578
+ maybeClauses ? *maybeClauses : empty, declaratives_.back ());
1586
1579
return false ;
1587
1580
}
1588
1581
bool Pre (const parser::OmpMapClause &);
@@ -1738,12 +1731,11 @@ class OmpVisitor : public virtual DeclarationVisitor {
1738
1731
void ProcessMapperSpecifier (const parser::OmpMapperSpecifier &spec,
1739
1732
const parser::OmpClauseList &clauses);
1740
1733
void ProcessReductionSpecifier (const parser::OmpReductionSpecifier &spec,
1741
- const std::optional< parser::OmpClauseList> &clauses,
1734
+ const parser::OmpClauseList &clauses,
1742
1735
const parser::OpenMPDeclarativeConstruct *wholeConstruct);
1743
1736
1744
1737
void ResolveCriticalName (const parser::OmpArgument &arg);
1745
1738
1746
- int metaLevel_{0 };
1747
1739
std::vector<const parser::OpenMPDeclarativeConstruct *> declaratives_;
1748
1740
};
1749
1741
@@ -1871,7 +1863,7 @@ std::string MangleDefinedOperator(const parser::CharBlock &name) {
1871
1863
1872
1864
void OmpVisitor::ProcessReductionSpecifier (
1873
1865
const parser::OmpReductionSpecifier &spec,
1874
- const std::optional< parser::OmpClauseList> &clauses,
1866
+ const parser::OmpClauseList &clauses,
1875
1867
const parser::OpenMPDeclarativeConstruct *construct) {
1876
1868
const parser::Name *name{nullptr };
1877
1869
parser::CharBlock mangledName;
@@ -1999,39 +1991,31 @@ void OmpVisitor::ResolveCriticalName(const parser::OmpArgument &arg) {
1999
1991
2000
1992
bool OmpVisitor::Pre (const parser::OmpDirectiveSpecification &x) {
2001
1993
AddOmpSourceRange (x.source );
2002
- if (metaLevel_ == 0 ) {
2003
- // Not in METADIRECTIVE.
2004
- return true ;
2005
- }
2006
1994
2007
- // If OmpDirectiveSpecification (which contains clauses) is a part of
2008
- // METADIRECTIVE, some semantic checks may not be applicable.
2009
- // Disable the semantic analysis for it in such cases to allow the compiler
2010
- // to parse METADIRECTIVE without flagging errors.
2011
- auto &maybeArgs{std::get<std::optional<parser::OmpArgumentList>>(x.t )};
2012
- auto &maybeClauses{std::get<std::optional<parser::OmpClauseList>>(x.t )};
1995
+ const parser::OmpArgumentList &args{x.Arguments ()};
1996
+ const parser::OmpClauseList &clauses{x.Clauses ()};
2013
1997
2014
1998
switch (x.DirId ()) {
2015
1999
case llvm::omp::Directive::OMPD_declare_mapper:
2016
- if (maybeArgs && maybeClauses ) {
2017
- const parser::OmpArgument &first{maybeArgs-> v .front ()};
2000
+ if (!args. v . empty () ) {
2001
+ const parser::OmpArgument &first{args. v .front ()};
2018
2002
if (auto *spec{std::get_if<parser::OmpMapperSpecifier>(&first.u )}) {
2019
- ProcessMapperSpecifier (*spec, *maybeClauses );
2003
+ ProcessMapperSpecifier (*spec, clauses );
2020
2004
}
2021
2005
}
2022
2006
break ;
2023
2007
case llvm::omp::Directive::OMPD_declare_reduction:
2024
- if (maybeArgs && maybeClauses ) {
2025
- const parser::OmpArgument &first{maybeArgs-> v .front ()};
2008
+ if (!args. v . empty () ) {
2009
+ const parser::OmpArgument &first{args. v .front ()};
2026
2010
if (auto *spec{std::get_if<parser::OmpReductionSpecifier>(&first.u )}) {
2027
- ProcessReductionSpecifier (*spec, maybeClauses , declaratives_.back ());
2011
+ ProcessReductionSpecifier (*spec, clauses , declaratives_.back ());
2028
2012
}
2029
2013
}
2030
2014
break ;
2031
2015
default :
2032
2016
// Default processing.
2033
- Walk (maybeArgs );
2034
- Walk (maybeClauses );
2017
+ Walk (args );
2018
+ Walk (clauses );
2035
2019
break ;
2036
2020
}
2037
2021
return false ;
0 commit comments