[PATCH] D112696: CycleInfo: Introduce cycles as a generalization of loops

Sameer Sahasrabuddhe via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 6 22:37:29 PST 2021


sameerds added inline comments.


================
Comment at: llvm/include/llvm/ADT/GenericCycleImpl.h:34
+template <typename ContextT>
+bool GenericCycle<ContextT>::contains(const GenericCycle *B) const {
+  if (!B)
----------------
nhaehnle wrote:
> sameerds wrote:
> > nhaehnle wrote:
> > > Other code in this file uses the new style function definition syntax, so perhaps do so here as well to be consistent?
> > I am not sure what you mean here ... this definition passes clang-format and clang-tidy. If you mean the lowercase `::contains`, then that is valid camelBack where the first letter must be lowercase.
> I meant the `auto foo(...) -> T` syntax.
That's a trailing return type from C++11 ... I am using it in places where the name of the return type is in scope only within the class whose member is being defined. For example:


```
template <typename ContextT>
auto GenericCycleInfo<ContextT>::getCycle(const BlockT *Block) const
    -> CycleT * { ... }
```

The trailing return type ensures DRY because `CycleT` is in scope after declaring the function name. Naming the return type first would require us to use the much more verbose `GenericCycleInfo<ContextT>::CycleT` instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112696



More information about the llvm-commits mailing list