Refactor functions handling memory order clauses. Related tests are already available in omp-atomic01.f90, so I do not add more tests.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
flang/lib/Semantics/check-omp-structure.cpp | ||
---|---|---|
1594 | How about not changing CheckAtomicMemoryOrderClause and call it twice here? And also remove OmpStructureChecker::CheckAtomicMemoryOrderClause(const parser::OmpAtomicClauseList &leftHandClauseList, const parser::OmpAtomicClauseList &rightHandClauseList). Then you will escape from passing the pointer by functions and using the obscure variable names leftHandClauseList an rightHandClauseList. CheckAtomicMemoryOrderClause(std::get<0>(atomicUpdate.t)); CheckAtomicMemoryOrderClause(std::get<2>(atomicUpdate.t)); |
flang/lib/Semantics/check-omp-structure.cpp | ||
---|---|---|
1594 | That could be done. However, then some additional handling would be required for numMemoryOrderClause. For example, !$omp atomic <memory_order_clause> read <memory_order_clause> is invalid since there are > 1 memory order clauses here. Thus I need the information- that we found 1 memory order clause while processing the left hand clause list- while I am working on the right hand clause list. However, I can not make numMemoryOrderClause a static variable, because then !$omp atomic read <memory_order_clause> x = y !$omp atomic write <memory_order_clause> y = 1 will start giving errors, as the variable will persist across several different atomic constructs. I do not have a strong opinion here however. I will do it as you suggest. |
flang/lib/Semantics/check-omp-structure.cpp | ||
---|---|---|
1594 |
Sorry, I didn't notice this case. Your current approach is fine to me. I noticed the memory order check are all for atomic constructs. Maybe put the lambda in the front of void OmpStructureChecker::Enter(const parser::OpenMPAtomicConstruct &x)? This is not one hard comment. |
You can wait for one day before landing if no one has further comments so that we can proceed the review for other patches depending on this.
How about not changing CheckAtomicMemoryOrderClause and call it twice here? And also remove OmpStructureChecker::CheckAtomicMemoryOrderClause(const parser::OmpAtomicClauseList &leftHandClauseList, const parser::OmpAtomicClauseList &rightHandClauseList). Then you will escape from passing the pointer by functions and using the obscure variable names leftHandClauseList an rightHandClauseList.