62class OmpStructureChecker :
public OmpStructureCheckerBase {
64 using Base = OmpStructureCheckerBase;
68 using llvmOmpClause =
const llvm::omp::Clause;
79 bool Enter(
const parser::EndSubroutineStmt &);
81 bool Enter(
const parser::EndFunctionStmt &);
87 void Enter(
const parser::ExecutionPart &);
88 void Leave(
const parser::ExecutionPart &);
176 void Enter(
const parser::OmpContextSelector &);
177 void Leave(
const parser::OmpContextSelector &);
179#define GEN_FLANG_CLAUSE_CHECK_ENTER
180#include "llvm/Frontend/OpenMP/OMP.inc"
183 bool CheckAllowedClause(llvmOmpClause clause);
184 void CheckVariableListItem(
const SymbolSourceMap &symbols);
185 void CheckDirectiveSpelling(
189 void CheckMultipleOccurrence(semantics::UnorderedSymbolSet &listVars,
191 const std::string &clauseName);
192 void CheckMultListItems();
193 void CheckStructureComponent(
195 bool HasInvalidWorksharingNesting(
197 bool IsCloselyNestedRegion(
const OmpDirectiveSet &set);
198 bool IsNestedInDirective(llvm::omp::Directive directive);
199 bool InTargetRegion();
200 void HasInvalidTeamsNesting(
204 bool HasRequires(llvm::omp::Clause req);
206 void CheckAllowedMapTypes(
209 const std::list<parser::OmpTraitProperty> &GetTraitPropertyList(
211 std::optional<llvm::omp::Clause> GetClauseFromProperty(
214 void CheckTraitSelectorList(
const std::list<parser::OmpTraitSelector> &);
217 bool VerifyTraitPropertyLists(
219 void CheckTraitSelector(
223 void CheckTraitCondition(
225 void CheckTraitDeviceNum(
227 void CheckTraitRequires(
232 llvm::StringRef getClauseName(llvm::omp::Clause clause)
override;
233 llvm::StringRef getDirectiveName(llvm::omp::Directive directive)
override;
236 typename LessTy,
typename RangeTy,
237 typename IterTy =
decltype(std::declval<RangeTy>().begin())>
238 std::optional<IterTy> FindDuplicate(RangeTy &&);
241 void CheckDependArraySection(
250 void CheckThreadprivateOrDeclareTargetVar(
const parser::Name &);
253 void CheckSymbolName(
255 void CheckSymbolNames(
257 void CheckIntentInPointer(SymbolSourceMap &,
const llvm::omp::Clause);
258 void CheckProcedurePointer(SymbolSourceMap &,
const llvm::omp::Clause);
260 llvm::StringRef clause,
bool suggestToUseCrayPointer =
true);
262 void CheckDefinableObjects(SymbolSourceMap &,
const llvm::omp::Clause);
263 void CheckCopyingPolymorphicAllocatable(
264 SymbolSourceMap &,
const llvm::omp::Clause);
265 void CheckPrivateSymbolsInOuterCxt(
266 SymbolSourceMap &, DirectivesClauseTriple &,
const llvm::omp::Clause);
269 void CheckIsLoopIvPartOfClause(
271 bool CheckTargetBlockOnlyTeams(
const parser::Block &);
274 void CheckIndividualAllocateDirective(
283 template <
typename T,
typename D>
bool IsOperatorValid(
const T &,
const D &);
289 std::string_view name,
bool checkTypeOnPointer =
true);
298 void CheckAtomicReadAssignment(
300 void CheckAtomicWriteAssignment(
302 std::optional<evaluate::Assignment> CheckAtomicUpdateAssignment(
304 std::pair<bool, bool> CheckAtomicUpdateAssignmentRhs(
const SomeExpr &atom,
306 void CheckAtomicConditionalUpdateAssignment(
const SomeExpr &cond,
309 void CheckAtomicConditionalUpdateStmt(
317 void CheckAtomicConditionalUpdateCapture(
329 const parser::Block &body,
size_t &nestedCount);
333 void CheckTargetUpdate();
335 void CheckDependenceType(
const parser::OmpDependenceType::Value &x);
336 void CheckTaskDependenceType(
const parser::OmpTaskDependenceType::Value &x);
337 std::optional<llvm::omp::Directive> GetCancelType(
339 const std::optional<parser::OmpClauseList> &maybeClauses);
340 void CheckCancellationNest(
343 void CheckReductionObjects(
352 void ChecksOnOrderedAsBlock();
355 void ChecksOnOrderedAsStandalone();
356 void CheckOrderedDependClause(std::optional<std::int64_t> orderedValue);
357 void CheckReductionArraySection(
360 const parser::Name &name,
const llvm::omp::Clause clause);
361 void CheckSharedBindingInOuterContext(
366 void CheckAllowedRequiresClause(llvmOmpClause clause);
367 bool deviceConstructFound_{
false};
371 void EnterDirectiveNest(
const int index) { directiveNest_[index]++; }
372 void ExitDirectiveNest(
const int index) { directiveNest_[index]--; }
373 int GetDirectiveNest(
const int index) {
return directiveNest_[index]; }
375 inline void ErrIfLHSAndRHSSymbolsMatch(
377 inline void ErrIfNonScalarAssignmentStmt(
379 enum directiveNestType :
int {
381 TargetBlockOnlyTeams,
386 LastType = MetadirectiveNest,
388 int directiveNest_[LastType + 1] = {0};
390 int allocateDirectiveLevel{0};
392 SymbolSourceMap deferredNonVariables_;
396 std::vector<LoopConstruct> loopStack_;
398 std::vector<const Scope *> scopeStack_;
400 enum class PartKind :
int {
406 std::vector<PartKind> partStack_;