Is this the rounding mode that we use? Also, you might need to check this against some sort of current state for rounding mode. I know that there is an effort to do FENV_ACCESS, which this might change, right?

It's attempting to compute the number of good base-10 digits (59/196 ~= log2(10)). We should really just make APFloat print the shortest round-trippable digit sequence instead. Yes, this is tricky to implement, but we don't need to implement it. There are two recent high-quality implementations available, which are both significantly faster than previous algorithms: Ryu and Swift's (https://github.com/apple/swift/blob/master/stdlib/public/runtime/SwiftDtoa.cpp). Swift's has the virtue of already being used in LLVM-family languages and having a tidy single-file implementation, but either would be perfectly usable, I think.

Neither supports float128 yet, but we could simply drop them in for float, double, and float80.

LLVM will need to carry an implementation of the "shortest round-trippable digit sequence" soon regardless of what we do here, because it's part of the C++17 standard library. We should aim for an implementation that can be shared by APFloat and libc++.

As noted, this in under LiteralConversion (-Wconversion). GCC has it too under -Wconversion, so I think it is fine as is, or? @rsmith

It's not so much about "which flag group do i need to enable to get the warning";
it's about "which flag do i need to disable to silence it", and "how fine-grained that flag is, how many warnings will get disabled".
The flags should be pretty fine-grained.

Are you sure check-clang passes with this patch?
It looks like some bots weren't happy before the revert.
(Also, is this warning enabled when building llvm? If yes, you might want to double-check stage2 build.)

This changes the behavior of your patch -- I think it made sense to not trigger this diagnostic in a system macro. I was suggesting that you replace the early return with braces and flip the logic around so that you only do the diagnostic work if you're not in a system macro.