[PATCH] D116261: [Clang][OpenMP] Add support for compare capture in parser

Shilei Tian via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Feb 12 13:55:39 PST 2022


tianshilei1992 marked an inline comment as done.
tianshilei1992 added inline comments.


================
Comment at: clang/lib/Sema/SemaOpenMP.cpp:11320
+  bool MutexClauseEncountered = false;
+  llvm::SmallSet<OpenMPClauseKind, 2> EncounteredAtomicKinds;
   for (const OMPClause *C : Clauses) {
----------------
ABataev wrote:
> SmallVector with 2 elements should be enough, no need to use SmallSet here.
`SmallVector` doesn't provide `contains`, which we use to check if `OMPC_compare` and `OMPC_capture` exist at the same time. Using `SmallVector` requires us to have a complicated comparison, for example:
```
(EncounteredAtomicKinds[0] == OMPC_compare && EncounteredAtomicKinds[1] == OMPC_capture) || (EncounteredAtomicKinds[1] == OMPC_compare && EncounteredAtomicKinds[0] == OMPC_capture)
```
which is not as neat as `SmallSet`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D116261/new/

https://reviews.llvm.org/D116261



More information about the cfe-commits mailing list