From cf73d3f07b5b0ff83a852dfdf8857500e86f9952 Mon Sep 17 00:00:00 2001 From: Ben Langmuir Date: Wed, 8 Feb 2023 13:24:07 -0800 Subject: [clang][deps] Ensure module invocation can be serialized When reseting modular options, propagate the values from certain options that have ImpliedBy relations instead of setting to the default. Also, verify in clang-scan-deps that the command line produced round trips exactly. Ideally we would automatically derive the set of options that need this kind of propagation, but for now there aren't very many impacted. rdar://105148590 Differential Revision: https://reviews.llvm.org/D143446 --- clang/lib/Basic/LangOptions.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'clang/lib/Basic/LangOptions.cpp') diff --git a/clang/lib/Basic/LangOptions.cpp b/clang/lib/Basic/LangOptions.cpp index 753b6bf..f22fe9a 100644 --- a/clang/lib/Basic/LangOptions.cpp +++ b/clang/lib/Basic/LangOptions.cpp @@ -29,6 +29,14 @@ void LangOptions::resetNonModularOptions() { Name = static_cast(Default); #include "clang/Basic/LangOptions.def" + // Reset "benign" options with implied values (Options.td ImpliedBy relations) + // rather than their defaults. This avoids unexpected combinations and + // invocations that cannot be round-tripped to arguments. + // FIXME: we should derive this automatically from ImpliedBy in tablegen. + AllowFPReassoc = UnsafeFPMath; + NoHonorNaNs = FiniteMathOnly; + NoHonorInfs = FiniteMathOnly; + // These options do not affect AST generation. NoSanitizeFiles.clear(); XRayAlwaysInstrumentFiles.clear(); -- cgit v1.1