[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 14:18:18 PST 2022


tianshilei1992 marked 2 inline comments 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:
> 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`?


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