jrtc27 added inline comments.
================ Comment at: clang/lib/Frontend/TextDiagnostic.cpp:1121-1138 +static unsigned getNumDisplayWidth(unsigned N) { + if (N < 10) + return 1; + if (N < 100) + return 2; + if (N < 1'000) + return 3; ---------------- kwk wrote: > This function screamed at me to be generalized so I gave it a try: > https://gist.github.com/kwk/7e408065ea291e49fea4a83cf90a9cdf I don't think I want floating point arithmetic in my compiler... Something like: ``` unsigned L, M; for (L = 1U, M = 10U; N >= M && M != ~0U; ++L) M = (M > ((~0U) / 10U)) ? (~0U) : (M * 10U); return (L); ``` is the generalised form (without all the redundant parentheses I added during debugging). CHANGES SINCE LAST ACTION https://reviews.llvm.org/D147875/new/ https://reviews.llvm.org/D147875 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits