[clang] ae500e4 - Always keep unset fields in FPOptionsOverride zeroed.

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Sun Aug 16 17:02:02 PDT 2020


Author: Richard Smith
Date: 2020-08-16T15:44:51-07:00
New Revision: ae500e4d0964adea69372d083416b0f13e9a87eb

URL: https://github.com/llvm/llvm-project/commit/ae500e4d0964adea69372d083416b0f13e9a87eb
DIFF: https://github.com/llvm/llvm-project/commit/ae500e4d0964adea69372d083416b0f13e9a87eb.diff

LOG: Always keep unset fields in FPOptionsOverride zeroed.

There are three fields that the FPOptions default constructor sets to
non-zero values; those fields previously could have been zero or
non-zero depending on whether they'd been explicitly removed from the
FPOptionsOverride set. However, that doesn't seem to ever actually
happen, so this is NFC, except that it makes the AST file representation
of FPOptionsOverride make more sense.

Added: 
    

Modified: 
    clang/include/clang/Basic/LangOptions.h
    clang/test/PCH/determinism.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/LangOptions.h b/clang/include/clang/Basic/LangOptions.h
index 31e8af4589b4..f1601aaa9d39 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -475,7 +475,7 @@ class FPOptions {
 /// The is implemented as a value of the new FPOptions plus a mask showing which
 /// fields are actually set in it.
 class FPOptionsOverride {
-  FPOptions Options;
+  FPOptions Options = FPOptions(0);
   FPOptions::storage_type OverrideMask = 0;
 
 public:

diff  --git a/clang/test/PCH/determinism.cpp b/clang/test/PCH/determinism.cpp
index 540088e2c91b..ea52971e3b26 100644
--- a/clang/test/PCH/determinism.cpp
+++ b/clang/test/PCH/determinism.cpp
@@ -6,6 +6,10 @@
 // RUN: cmp %t/a.pch %t/b.pch
 
 #pragma float_control(push)
+double fp_control_0(double x) {
+  return -x + x;
+}
+
 double fp_control_1(double x) {
 #pragma float_control(precise, on)
   return -x + x;


        


More information about the cfe-commits mailing list