[flang-commits] [flang] [llvm] [flang][OpenMP] Apply modifier representation to semantic checks (PR #116658)
Krzysztof Parzyszek via flang-commits
flang-commits at lists.llvm.org
Wed Nov 20 09:00:43 PST 2024
================
@@ -3440,6 +3440,16 @@ struct OmpObject {
WRAPPER_CLASS(OmpObjectList, std::list<OmpObject>);
+#define MODIFIER_BOILERPLATE(...) \
+ struct Modifier { \
+ using Variant = std::variant<__VA_ARGS__>; \
+ UNION_CLASS_BOILERPLATE(Modifier); \
+ CharBlock source; \
+ Variant u; \
+ }
+
+#define MODIFIERS() std::optional<std::list<Modifier>>
----------------
kparzysz wrote:
The purpose of the `MODIFIERS()` macro is to hide the name "Modifier" that the boilerplate macro introduces.
The `MODIFIER_BOILERPLATE(type1, type2, ...)` macro expands to (roughly)
```
struct Modifier {
std::variant<type1, type2, ...> u;
};
```
So inside a clause class it will be
```
struct OmpSomeClause {
struct Modifier {
std::variant<...> u;
};
std::tuple<std::optional<std::list<Modifier>>, ClauseArg1, ClauseArg2...> t;
};
```
The `std::optional<std::list<Modifier>>` here is what the `MODIFIERS()` macro inserts. It's always the same string (hence no arguments to the macro), but the "Modifier" word in it refers to a different thing each time.
With the alias you suggested, the user would always have to say
```
struct OmpSomeClause {
MODIFIER_BOILERPLATE(type1, type2, ...)
std::tuple<Modifiers<Modifier>, ClauseArg1, ClauseArg2, ...> t;
};
```
and explicitly use the word "Modifier".
https://github.com/llvm/llvm-project/pull/116658
More information about the flang-commits
mailing list