This makes infinities and NaNs return the new, more explicit formats
added in 8d9299cd7a
and extends the base decimal output literal to support non-double types.
In addition, the legacy hexadecimal floating-point literal format is no
longer output in any circumstance.
In general, this means that NaNs are reported as +/-qnan,
+/-nan(payload), or +/-snan(payload), depending on their payload and
infinities as +/-inf. The hexadecimal output generally changes to `f0x...`
notation, and is used when 6 decimal digits are insufficient to accurately
represent the number, or for noncanonical ppc_fp128 values.
A script to change the output for most test files is available at
https://gist.github.com/jcranmer-intel/d279296ad91884c98b77fb23a9112a5a.
Full disclosure: the python portion of the script was written with the
use of AI tools. The C++ portion was written entirely by hand, reusing
LLVM's existing helpers for output.
The test changes included in this commit are *only* those which do not
work with that script, either because the script mangled the conversion
(e.g., intentionally matching only a prefix to allow some imprecision)
or because the tests were too unusual for the script to find the
floating-point literals being compared against.
32 lines
1.1 KiB
C++
32 lines
1.1 KiB
C++
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm --std=c++17 %s -o - | FileCheck %s
|
|
|
|
struct stream {
|
|
friend const stream &operator<<(const stream &, const float &);
|
|
};
|
|
|
|
void foo() {
|
|
constexpr float f_zero = 0.0f;
|
|
constexpr float f_one = 1.0f;
|
|
constexpr float f_two = 2.0f;
|
|
|
|
stream s;
|
|
[=]() {
|
|
s << f_zero << f_one << f_two;
|
|
}();
|
|
}
|
|
|
|
// CHECK: define{{.*}} void @_Z3foov
|
|
// CHECK: getelementptr inbounds nuw %{{.+}}, ptr %{{.+}}, i32 0, i32 1
|
|
// CHECK-NEXT: store float 0.000000e+00
|
|
// CHECK-NEXT: getelementptr inbounds nuw %{{.+}}, ptr %{{.+}}, i32 0, i32 2
|
|
// CHECK-NEXT: store float 1.000000e+00
|
|
// CHECK-NEXT: getelementptr inbounds nuw %{{.+}}, ptr %{{.+}}, i32 0, i32 3
|
|
// CHECK-NEXT: store float 2.000000e+00
|
|
|
|
// The lambda body. Reverse iteration when the captures aren't deterministic
|
|
// causes these to be laid out differently in the lambda.
|
|
// CHECK: define internal void
|
|
// CHECK: getelementptr inbounds nuw %{{.+}}, ptr %{{.+}}, i32 0, i32 1
|
|
// CHECK: getelementptr inbounds nuw %{{.+}}, ptr %{{.+}}, i32 0, i32 2
|
|
// CHECK: getelementptr inbounds nuw %{{.+}}, ptr %{{.+}}, i32 0, i32 3
|