jdoerfert created this revision.
jdoerfert added a reviewer: rnk.
Herald added subscribers: guansong, bollu.
Herald added a project: clang.
See rational here: https://reviews.llvm.org/D76173#1922916
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D76184
Files:
clang/include/clang/AST/Attr.h
clang/include/clang/AST/OpenMPClause.h
clang/include/clang/Parse/Parser.h
clang/lib/AST/OpenMPClause.cpp
clang/lib/Parse/ParseOpenMP.cpp
Index: clang/lib/Parse/ParseOpenMP.cpp
===================================================================
--- clang/lib/Parse/ParseOpenMP.cpp
+++ clang/lib/Parse/ParseOpenMP.cpp
@@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===//
#include "clang/AST/ASTContext.h"
+#include "clang/AST/OpenMPClause.h"
#include "clang/AST/StmtOpenMP.h"
#include "clang/Basic/OpenMPKinds.h"
#include "clang/Parse/ParseDiagnostic.h"
@@ -862,7 +863,7 @@
} // namespace
void Parser::parseOMPTraitPropertyKind(
- OMPTraitInfo::OMPTraitProperty &TIProperty, llvm::omp::TraitSet Set,
+ OMPTraitProperty &TIProperty, llvm::omp::TraitSet Set,
llvm::omp::TraitSelector Selector, llvm::StringMap<SourceLocation> &Seen) {
TIProperty.Kind = TraitProperty::invalid;
@@ -931,14 +932,14 @@
<< CONTEXT_TRAIT_LVL << listOpenMPContextTraitProperties(Set, Selector);
}
-void Parser::parseOMPContextProperty(OMPTraitInfo::OMPTraitSelector &TISelector,
+void Parser::parseOMPContextProperty(OMPTraitSelector &TISelector,
llvm::omp::TraitSet Set,
llvm::StringMap<SourceLocation> &Seen) {
assert(TISelector.Kind != TraitSelector::user_condition &&
"User conditions are special properties not handled here!");
SourceLocation PropertyLoc = Tok.getLocation();
- OMPTraitInfo::OMPTraitProperty TIProperty;
+ OMPTraitProperty TIProperty;
parseOMPTraitPropertyKind(TIProperty, Set, TISelector.Kind, Seen);
// If we have an invalid property here we already issued a warning.
@@ -972,7 +973,7 @@
}
void Parser::parseOMPTraitSelectorKind(
- OMPTraitInfo::OMPTraitSelector &TISelector, llvm::omp::TraitSet Set,
+ OMPTraitSelector &TISelector, llvm::omp::TraitSet Set,
llvm::StringMap<SourceLocation> &Seen) {
TISelector.Kind = TraitSelector::invalid;
@@ -1051,7 +1052,7 @@
///
/// <trait-selector-name> ['('[<trait-score>] <trait-property> [, <t-p>]* ')']
void Parser::parseOMPContextSelector(
- OMPTraitInfo::OMPTraitSelector &TISelector, llvm::omp::TraitSet Set,
+ OMPTraitSelector &TISelector, llvm::omp::TraitSet Set,
llvm::StringMap<SourceLocation> &SeenSelectors) {
unsigned short OuterPC = ParenCount;
@@ -1151,7 +1152,7 @@
BDT.consumeClose();
}
-void Parser::parseOMPTraitSetKind(OMPTraitInfo::OMPTraitSet &TISet,
+void Parser::parseOMPTraitSetKind(OMPTraitSet &TISet,
llvm::StringMap<SourceLocation> &Seen) {
TISet.Kind = TraitSet::invalid;
@@ -1215,7 +1216,7 @@
///
/// <trait-set-selector-name> '=' '{' <trait-selector> [, <trait-selector>]* '}'
void Parser::parseOMPContextSelectorSet(
- OMPTraitInfo::OMPTraitSet &TISet,
+ OMPTraitSet &TISet,
llvm::StringMap<SourceLocation> &SeenSets) {
auto OuterBC = BraceCount;
@@ -1270,7 +1271,7 @@
llvm::StringMap<SourceLocation> SeenSelectors;
do {
- OMPTraitInfo::OMPTraitSelector TISelector;
+ OMPTraitSelector TISelector;
parseOMPContextSelector(TISelector, TISet.Kind, SeenSelectors);
if (TISelector.Kind != TraitSelector::invalid &&
!TISelector.Properties.empty())
@@ -1292,10 +1293,10 @@
/// Parse OpenMP context selectors:
///
/// <trait-set-selector> [, <trait-set-selector>]*
-bool Parser::parseOMPContextSelectors(SourceLocation Loc, OMPTraitInfo &TI) {
+bool Parser::parseOMPContextSelectors(SourceLocation Loc, OMPTraitInfo& TI) {
llvm::StringMap<SourceLocation> SeenSets;
do {
- OMPTraitInfo::OMPTraitSet TISet;
+ OMPTraitSet TISet;
parseOMPContextSelectorSet(TISet, SeenSets);
if (TISet.Kind != TraitSet::invalid && !TISet.Selectors.empty())
TI.Sets.push_back(TISet);
Index: clang/lib/AST/OpenMPClause.cpp
===================================================================
--- clang/lib/AST/OpenMPClause.cpp
+++ clang/lib/AST/OpenMPClause.cpp
@@ -1841,14 +1841,14 @@
void OMPTraitInfo::print(llvm::raw_ostream &OS,
const PrintingPolicy &Policy) const {
bool FirstSet = true;
- for (const OMPTraitInfo::OMPTraitSet &Set : Sets) {
+ for (const OMPTraitSet &Set : Sets) {
if (!FirstSet)
OS << ", ";
FirstSet = false;
OS << llvm::omp::getOpenMPContextTraitSetName(Set.Kind) << "={";
bool FirstSelector = true;
- for (const OMPTraitInfo::OMPTraitSelector &Selector : Set.Selectors) {
+ for (const OMPTraitSelector &Selector : Set.Selectors) {
if (!FirstSelector)
OS << ", ";
FirstSelector = false;
@@ -1874,7 +1874,7 @@
}
bool FirstProperty = true;
- for (const OMPTraitInfo::OMPTraitProperty &Property :
+ for (const OMPTraitProperty &Property :
Selector.Properties) {
if (!FirstProperty)
OS << ", ";
Index: clang/include/clang/Parse/Parser.h
===================================================================
--- clang/include/clang/Parse/Parser.h
+++ clang/include/clang/Parse/Parser.h
@@ -13,7 +13,6 @@
#ifndef LLVM_CLANG_PARSE_PARSER_H
#define LLVM_CLANG_PARSE_PARSER_H
-#include "clang/AST/OpenMPClause.h"
#include "clang/AST/Availability.h"
#include "clang/Basic/BitmaskEnum.h"
#include "clang/Basic/OpenMPKinds.h"
@@ -49,6 +48,10 @@
class OMPClause;
class ObjCTypeParamList;
class ObjCTypeParameter;
+ struct OMPTraitProperty;
+ struct OMPTraitSelector;
+ struct OMPTraitSet;
+ class OMPTraitInfo;
/// Parser - This implements a parser for the C family of languages. After
/// parsing units of the grammar, productions are invoked to handle whatever has
@@ -2928,32 +2931,32 @@
/// Parse a property kind into \p TIProperty for the selector set \p Set and
/// selector \p Selector.
- void parseOMPTraitPropertyKind(OMPTraitInfo::OMPTraitProperty &TIProperty,
+ void parseOMPTraitPropertyKind(OMPTraitProperty &TIProperty,
llvm::omp::TraitSet Set,
llvm::omp::TraitSelector Selector,
llvm::StringMap<SourceLocation> &Seen);
/// Parse a selector kind into \p TISelector for the selector set \p Set.
- void parseOMPTraitSelectorKind(OMPTraitInfo::OMPTraitSelector &TISelector,
+ void parseOMPTraitSelectorKind(OMPTraitSelector &TISelector,
llvm::omp::TraitSet Set,
llvm::StringMap<SourceLocation> &Seen);
/// Parse a selector set kind into \p TISet.
- void parseOMPTraitSetKind(OMPTraitInfo::OMPTraitSet &TISet,
+ void parseOMPTraitSetKind(OMPTraitSet &TISet,
llvm::StringMap<SourceLocation> &Seen);
/// Parses an OpenMP context property.
- void parseOMPContextProperty(OMPTraitInfo::OMPTraitSelector &TISelector,
+ void parseOMPContextProperty(OMPTraitSelector &TISelector,
llvm::omp::TraitSet Set,
llvm::StringMap<SourceLocation> &Seen);
/// Parses an OpenMP context selector.
- void parseOMPContextSelector(OMPTraitInfo::OMPTraitSelector &TISelector,
+ void parseOMPContextSelector(OMPTraitSelector &TISelector,
llvm::omp::TraitSet Set,
llvm::StringMap<SourceLocation> &SeenSelectors);
/// Parses an OpenMP context selector set.
- void parseOMPContextSelectorSet(OMPTraitInfo::OMPTraitSet &TISet,
+ void parseOMPContextSelectorSet(OMPTraitSet &TISet,
llvm::StringMap<SourceLocation> &SeenSets);
/// Parses OpenMP context selectors.
Index: clang/include/clang/AST/OpenMPClause.h
===================================================================
--- clang/include/clang/AST/OpenMPClause.h
+++ clang/include/clang/AST/OpenMPClause.h
@@ -6879,6 +6879,19 @@
#include "clang/Basic/OpenMPKinds.def"
};
+struct OMPTraitProperty {
+ llvm::omp::TraitProperty Kind = llvm::omp::TraitProperty::invalid;
+};
+struct OMPTraitSelector {
+ Expr *ScoreOrCondition = nullptr;
+ llvm::omp::TraitSelector Kind = llvm::omp::TraitSelector::invalid;
+ llvm::SmallVector<OMPTraitProperty, 1> Properties;
+};
+struct OMPTraitSet {
+ llvm::omp::TraitSet Kind = llvm::omp::TraitSet::invalid;
+ llvm::SmallVector<OMPTraitSelector, 2> Selectors;
+};
+
/// Helper data structure representing the traits in a match clause of an
/// `declare variant` or `metadirective`. The outer level is an ordered
/// collection of selector sets, each with an associated kind and an ordered
@@ -6890,27 +6903,14 @@
friend class ASTContext;
public:
- struct OMPTraitProperty {
- llvm::omp::TraitProperty Kind = llvm::omp::TraitProperty::invalid;
- };
- struct OMPTraitSelector {
- Expr *ScoreOrCondition = nullptr;
- llvm::omp::TraitSelector Kind = llvm::omp::TraitSelector::invalid;
- llvm::SmallVector<OMPTraitProperty, 1> Properties;
- };
- struct OMPTraitSet {
- llvm::omp::TraitSet Kind = llvm::omp::TraitSet::invalid;
- llvm::SmallVector<OMPTraitSelector, 2> Selectors;
- };
-
/// The outermost level of selector sets.
llvm::SmallVector<OMPTraitSet, 2> Sets;
bool anyScoreOrCondition(
const llvm::function_ref<bool(Expr *&, bool /* IsScore */)> &Cond) {
- return llvm::any_of(Sets, [&Cond](OMPTraitInfo::OMPTraitSet &Set) {
+ return llvm::any_of(Sets, [&Cond](OMPTraitSet &Set) {
return llvm::any_of(
- Set.Selectors, [&Cond](OMPTraitInfo::OMPTraitSelector &Selector) {
+ Set.Selectors, [&Cond](OMPTraitSelector &Selector) {
return Cond(Selector.ScoreOrCondition,
/* IsScore */ Selector.Kind !=
llvm::omp::TraitSelector::user_condition);
Index: clang/include/clang/AST/Attr.h
===================================================================
--- clang/include/clang/AST/Attr.h
+++ clang/include/clang/AST/Attr.h
@@ -16,10 +16,10 @@
#include "clang/AST/ASTFwd.h"
#include "clang/AST/AttrIterator.h"
#include "clang/AST/Decl.h"
-#include "clang/AST/OpenMPClause.h"
#include "clang/AST/Type.h"
#include "clang/Basic/AttrKinds.h"
#include "clang/Basic/AttributeCommonInfo.h"
+#include "clang/Basic/LangOptions.h"
#include "clang/Basic/LLVM.h"
#include "clang/Basic/OpenMPKinds.h"
#include "clang/Basic/Sanitizers.h"
@@ -40,6 +40,7 @@
class QualType;
class FunctionDecl;
class TypeSourceInfo;
+class OMPTraitInfo;
/// Attr - This represents one attribute.
class Attr : public AttributeCommonInfo {
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits