[PATCH] D76031: [mlir][CRunnerUtils] Enable compilation with C++11 toolchain on microcontroller platforms.

Nicolas Vasilache via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 12 05:13:54 PDT 2020


nicolasvasilache marked an inline comment as done.
nicolasvasilache added inline comments.


================
Comment at: mlir/include/mlir/ExecutionEngine/CRunnerUtils.h:48
 constexpr unsigned nextPowerOf2(int N) {
-  if (N <= 1)
-    return 1;
-  return isPowerOf2(N) ? N : 2 * nextPowerOf2((N + 1) / 2);
+  return (N <= 1) ? 1 : (isPowerOf2(N) ? N : 2 * nextPowerOf2((N + 1) / 2));
 }
----------------
flaub wrote:
> aartbik wrote:
> > perhaps use () on the part after : too for readability
> > (assuming this does not violate some llvm brevity rule I don't know yet :-)
> Chaining multiple ternary operations just seems less readable than the original.
I agree but I have recollections from olden days that strict C++11 can only deduce the type if the body is a single line return statement.
The person who submitted this internally has a strict C++11 toolchain.
I found a few places that mention this limit (e.g. grep "single line" in https://en.cppreference.com/w/cpp/language/constexpr)
But I didn't go and dig into the standard for a 1-line readability regression.
 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76031





More information about the llvm-commits mailing list