[PATCH] D99905: [OPENMP51]Initial parsing/sema for adjust_args clause for 'declare variant'

Aaron Ballman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 5 05:43:01 PDT 2021


aaron.ballman added inline comments.


================
Comment at: clang/lib/Parse/ParseOpenMP.cpp:1447-1448
+    if (IsError) {
+      while (!SkipUntil(tok::annot_pragma_openmp_end, StopBeforeMatch))
+        ;
+      // Skip the last annot_pragma_openmp_end.
----------------
ABataev wrote:
> aaron.ballman wrote:
> > I know this is code that existed previously, but why the `while` loop? This strikes me as a potential infinite loop because `SkipUntil` returns `false` when the token is not found, so if the token is not found the first time, I'd be surprised if a second pass at it finds the token.
> It may return early because of parens/braces etc. counting. In this case, it will return `false` while if `annot_pragma_openmp_end` is found, it returns `true`. We need to iterate to the end of the directive here, that's why there is a loop.
Thank you for the explanation -- that sure sounds like a bug with `SkipUntil` to me, and looking through the code base, the only code that seems to do this dance is OpenMP code. Do you happen to have a code example that requires the loop behavior?

(Not suggesting a change needs to be made in this patch, I'm mostly wondering if there's a change we can make in a follow-up and remove these loops.)


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

https://reviews.llvm.org/D99905



More information about the llvm-commits mailing list