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

Alexey Bataev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Feb 12 14:22:08 PST 2022


ABataev added inline comments.


================
Comment at: clang/lib/Sema/SemaOpenMP.cpp:11320
+  bool MutexClauseEncountered = false;
+  llvm::SmallSet<OpenMPClauseKind, 2> EncounteredAtomicKinds;
   for (const OMPClause *C : Clauses) {
----------------
tianshilei1992 wrote:
> ABataev wrote:
> > tianshilei1992 wrote:
> > > 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`.
> > Use llvm::find
> That is linear time. Why it is better than `SmallSet`?
Because there are only 2 elements, no?


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