[PATCH] D96418: [clang] Refactor mustprogress handling, add it to all loops in c++11+.

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 11 04:53:15 PST 2021


aaron.ballman added inline comments.


================
Comment at: clang/lib/CodeGen/CodeGenFunction.h:523
     return getLangOpts().C11 || getLangOpts().C17 || getLangOpts().C2x;
   }
 
----------------
fhahn wrote:
> aaron.ballman wrote:
> > jdoerfert wrote:
> > > fhahn wrote:
> > > > jdoerfert wrote:
> > > > > Can you modify the documentation to talk about what loops must make progress, this is the code below transcribed. 
> > > > > 
> > > > > Also, I don't see how this works. Should the const-ness of the condition not be related to the standard/language to make a decision?
> > > > > Can you modify the documentation to talk about what loops must make progress, this is the code below transcribed.
> > > > 
> > > > I added some comments. I hope they make things clearer.
> > > > 
> > > > > Also, I don't see how this works. Should the const-ness of the condition not be related to the standard/language to make a decision?
> > > > 
> > > > The `functionMustProgress` call applies the C++ rules. So C++11 and above is already handled by the call.
> > > > 
> > > > Afterwards, loops with constant conditions never have to make progress (C++ before 11, any C version). Loops with non-constant conditions have to make progress in C11 and later.
> > > > 
> > > > Hopefully the comment makes that clearer.
> > > Now, even I understand this. Thanks :)
> > >  Loops with non-constant conditions have to make progress in C11 and later.
> > 
> > Can you point me to the part of the C11 (or later) standards that state this? I don't see wording like http://eel.is/c++draft/intro.progress#1 in 5.1.2.4 in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2596.pdf
> For C11 and later, it should be 6.8.5.6, which says:
> 
> ```
> An iteration statement may be assumed by the implementation to terminate if its controlling expression is not a constant expression,171) and none of the following operations are performed in its body, controlling expression or (in the case of a for statement) its expression-3:172)
> — input/output operations
> — accessing a volatile object
> — synchronization or atomic operations.
> ```
> 
> It would probably be good to refer to C11 6.8.5.6 here, and the equivalent for C++ (6.9.2.3.1)?
Ah, thank you for that -- my brain was hung up on the atomic progress guarantees not the loop ones specifically. Having a standards reference in the comments would be handy, but I don't insist.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96418



More information about the cfe-commits mailing list