24
24
#include " clang/Sema/SemaAMDGPU.h"
25
25
#include " clang/Sema/SemaCodeCompletion.h"
26
26
#include " clang/Sema/SemaOpenMP.h"
27
- #include " llvm/ADT/PointerIntPair.h"
28
27
#include " llvm/ADT/StringSwitch.h"
29
28
#include " llvm/Frontend/OpenMP/OMPAssume.h"
30
29
#include " llvm/Frontend/OpenMP/OMPContext.h"
30
+ #include < bitset>
31
31
#include < optional>
32
32
33
33
using namespace clang ;
@@ -1646,19 +1646,17 @@ bool Parser::parseOMPDeclareVariantMatchClause(SourceLocation Loc,
1646
1646
void Parser::ParseOpenMPClauses (OpenMPDirectiveKind DKind,
1647
1647
SmallVectorImpl<OMPClause *> &Clauses,
1648
1648
SourceLocation Loc) {
1649
- SmallVector<llvm::PointerIntPair<OMPClause *, 1 , bool >,
1650
- llvm::omp::Clause_enumSize + 1 >
1651
- FirstClauses (llvm::omp::Clause_enumSize + 1 );
1649
+ std::bitset<llvm::omp::Clause_enumSize + 1 > SeenClauses;
1652
1650
while (Tok.isNot (tok::annot_pragma_openmp_end)) {
1653
1651
OpenMPClauseKind CKind = Tok.isAnnotation ()
1654
1652
? OMPC_unknown
1655
1653
: getOpenMPClauseKind (PP.getSpelling (Tok));
1656
1654
Actions.OpenMP ().StartOpenMPClause (CKind);
1657
- OMPClause *Clause = ParseOpenMPClause (
1658
- DKind, CKind, !FirstClauses [unsigned (CKind)]. getInt () );
1655
+ OMPClause *Clause =
1656
+ ParseOpenMPClause ( DKind, CKind, !SeenClauses [unsigned (CKind)]);
1659
1657
SkipUntil (tok::comma, tok::identifier, tok::annot_pragma_openmp_end,
1660
1658
StopBeforeMatch);
1661
- FirstClauses [unsigned (CKind)]. setInt ( true ) ;
1659
+ SeenClauses [unsigned (CKind)] = true ;
1662
1660
if (Clause != nullptr )
1663
1661
Clauses.push_back (Clause);
1664
1662
if (Tok.is (tok::annot_pragma_openmp_end)) {
@@ -2114,19 +2112,17 @@ Parser::DeclGroupPtrTy Parser::ParseOpenMPDeclarativeDirectiveWithExtDecl(
2114
2112
/* AllowScopeSpecifier=*/ true )) {
2115
2113
SmallVector<OMPClause *, 1 > Clauses;
2116
2114
if (Tok.isNot (tok::annot_pragma_openmp_end)) {
2117
- SmallVector<llvm::PointerIntPair<OMPClause *, 1 , bool >,
2118
- llvm::omp::Clause_enumSize + 1 >
2119
- FirstClauses (llvm::omp::Clause_enumSize + 1 );
2115
+ std::bitset<llvm::omp::Clause_enumSize + 1 > SeenClauses;
2120
2116
while (Tok.isNot (tok::annot_pragma_openmp_end)) {
2121
2117
OpenMPClauseKind CKind =
2122
2118
Tok.isAnnotation () ? OMPC_unknown
2123
2119
: getOpenMPClauseKind (PP.getSpelling (Tok));
2124
2120
Actions.OpenMP ().StartOpenMPClause (CKind);
2125
- OMPClause *Clause = ParseOpenMPClause (
2126
- OMPD_allocate, CKind, !FirstClauses [unsigned (CKind)]. getInt () );
2121
+ OMPClause *Clause = ParseOpenMPClause (OMPD_allocate, CKind,
2122
+ !SeenClauses [unsigned (CKind)]);
2127
2123
SkipUntil (tok::comma, tok::identifier, tok::annot_pragma_openmp_end,
2128
2124
StopBeforeMatch);
2129
- FirstClauses [unsigned (CKind)]. setInt ( true ) ;
2125
+ SeenClauses [unsigned (CKind)] = true ;
2130
2126
if (Clause != nullptr )
2131
2127
Clauses.push_back (Clause);
2132
2128
if (Tok.is (tok::annot_pragma_openmp_end)) {
@@ -2150,9 +2146,7 @@ Parser::DeclGroupPtrTy Parser::ParseOpenMPDeclarativeDirectiveWithExtDecl(
2150
2146
case OMPD_requires: {
2151
2147
SourceLocation StartLoc = ConsumeToken ();
2152
2148
SmallVector<OMPClause *, 5 > Clauses;
2153
- SmallVector<llvm::PointerIntPair<OMPClause *, 1 , bool >,
2154
- llvm::omp::Clause_enumSize + 1 >
2155
- FirstClauses (llvm::omp::Clause_enumSize + 1 );
2149
+ std::bitset<llvm::omp::Clause_enumSize + 1 > SeenClauses;
2156
2150
if (Tok.is (tok::annot_pragma_openmp_end)) {
2157
2151
Diag (Tok, diag::err_omp_expected_clause)
2158
2152
<< getOpenMPDirectiveName (OMPD_requires);
@@ -2163,11 +2157,11 @@ Parser::DeclGroupPtrTy Parser::ParseOpenMPDeclarativeDirectiveWithExtDecl(
2163
2157
? OMPC_unknown
2164
2158
: getOpenMPClauseKind (PP.getSpelling (Tok));
2165
2159
Actions.OpenMP ().StartOpenMPClause (CKind);
2166
- OMPClause *Clause = ParseOpenMPClause (
2167
- OMPD_requires, CKind, !FirstClauses [unsigned (CKind)]. getInt () );
2160
+ OMPClause *Clause = ParseOpenMPClause (OMPD_requires, CKind,
2161
+ !SeenClauses [unsigned (CKind)]);
2168
2162
SkipUntil (tok::comma, tok::identifier, tok::annot_pragma_openmp_end,
2169
2163
StopBeforeMatch);
2170
- FirstClauses [unsigned (CKind)]. setInt ( true ) ;
2164
+ SeenClauses [unsigned (CKind)] = true ;
2171
2165
if (Clause != nullptr )
2172
2166
Clauses.push_back (Clause);
2173
2167
if (Tok.is (tok::annot_pragma_openmp_end)) {
@@ -2510,9 +2504,7 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective(
2510
2504
ParsingOpenMPDirectiveRAII DirScope (*this );
2511
2505
ParenBraceBracketBalancer BalancerRAIIObj (*this );
2512
2506
SmallVector<OMPClause *, 5 > Clauses;
2513
- SmallVector<llvm::PointerIntPair<OMPClause *, 1 , bool >,
2514
- llvm::omp::Clause_enumSize + 1 >
2515
- FirstClauses (llvm::omp::Clause_enumSize + 1 );
2507
+ std::bitset<llvm::omp::Clause_enumSize + 1 > SeenClauses;
2516
2508
unsigned ScopeFlags = Scope::FnScope | Scope::DeclScope |
2517
2509
Scope::CompoundStmtScope | Scope::OpenMPDirectiveScope;
2518
2510
SourceLocation Loc = ReadDirectiveWithinMetadirective
@@ -2717,19 +2709,17 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective(
2717
2709
/* AllowScopeSpecifier=*/ false )) {
2718
2710
SmallVector<OMPClause *, 1 > Clauses;
2719
2711
if (Tok.isNot (tok::annot_pragma_openmp_end)) {
2720
- SmallVector<llvm::PointerIntPair<OMPClause *, 1 , bool >,
2721
- llvm::omp::Clause_enumSize + 1 >
2722
- FirstClauses (llvm::omp::Clause_enumSize + 1 );
2712
+ std::bitset<llvm::omp::Clause_enumSize + 1 > SeenClauses;
2723
2713
while (Tok.isNot (tok::annot_pragma_openmp_end)) {
2724
2714
OpenMPClauseKind CKind =
2725
2715
Tok.isAnnotation () ? OMPC_unknown
2726
2716
: getOpenMPClauseKind (PP.getSpelling (Tok));
2727
2717
Actions.OpenMP ().StartOpenMPClause (CKind);
2728
- OMPClause *Clause = ParseOpenMPClause (
2729
- OMPD_allocate, CKind, !FirstClauses [unsigned (CKind)]. getInt () );
2718
+ OMPClause *Clause = ParseOpenMPClause (OMPD_allocate, CKind,
2719
+ !SeenClauses [unsigned (CKind)]);
2730
2720
SkipUntil (tok::comma, tok::identifier, tok::annot_pragma_openmp_end,
2731
2721
StopBeforeMatch);
2732
- FirstClauses [unsigned (CKind)]. setInt ( true ) ;
2722
+ SeenClauses [unsigned (CKind)] = true ;
2733
2723
if (Clause != nullptr )
2734
2724
Clauses.push_back (Clause);
2735
2725
if (Tok.is (tok::annot_pragma_openmp_end)) {
@@ -2926,13 +2916,11 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective(
2926
2916
ImplicitClauseAllowed = false ;
2927
2917
Actions.OpenMP ().StartOpenMPClause (CKind);
2928
2918
HasImplicitClause = false ;
2929
- OMPClause *Clause = ParseOpenMPClause (
2930
- DKind, CKind, !FirstClauses[unsigned (CKind)].getInt ());
2931
- FirstClauses[unsigned (CKind)].setInt (true );
2932
- if (Clause) {
2933
- FirstClauses[unsigned (CKind)].setPointer (Clause);
2919
+ OMPClause *Clause =
2920
+ ParseOpenMPClause (DKind, CKind, !SeenClauses[unsigned (CKind)]);
2921
+ SeenClauses[unsigned (CKind)] = true ;
2922
+ if (Clause)
2934
2923
Clauses.push_back (Clause);
2935
- }
2936
2924
2937
2925
// Skip ',' if any.
2938
2926
if (Tok.is (tok::comma))
@@ -2948,7 +2936,7 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective(
2948
2936
// If the depend or doacross clause is specified, the ordered construct
2949
2937
// is a stand-alone directive.
2950
2938
for (auto CK : {OMPC_depend, OMPC_doacross}) {
2951
- if (FirstClauses [unsigned (CK)]. getInt () ) {
2939
+ if (SeenClauses [unsigned (CK)]) {
2952
2940
if ((StmtCtx & ParsedStmtContext::AllowStandaloneOpenMPDirectives) ==
2953
2941
ParsedStmtContext ()) {
2954
2942
Diag (Loc, diag::err_omp_immediate_directive)
@@ -2960,7 +2948,7 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective(
2960
2948
}
2961
2949
}
2962
2950
2963
- if (DKind == OMPD_tile && !FirstClauses [unsigned (OMPC_sizes)]. getInt () ) {
2951
+ if (DKind == OMPD_tile && !SeenClauses [unsigned (OMPC_sizes)]) {
2964
2952
Diag (Loc, diag::err_omp_required_clause)
2965
2953
<< getOpenMPDirectiveName (OMPD_tile) << " sizes" ;
2966
2954
}
0 commit comments