[clang][headers] Need a way for math.h to share the definitions of INIFINITY and NAN with float.h (#164348)
In C23 mode, both float.h and math.h are required to define INIFINITY
and NAN. However, with clang modules, there needs to be a single owner
for the declarations. Let that be float.h since that's the suggested
true owner in Annex F.2.2 of ISO/IEC 9899:2024, and introduce
`__need_infinity_nan` so that math.h can pick up the compiler
definitions.
GitOrigin-RevId: 38473c5d351d6b2ae21b5eb1ce66c2bcc2f7c6f7
diff --git a/clang-include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp b/clang-include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp
index 410df12..d43a3ea 100644
--- a/clang-include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp
+++ b/clang-include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp
@@ -13,6 +13,9 @@
const HeaderMapCollector::RegexHeaderMap *getSTLPostfixHeaderMap() {
static const HeaderMapCollector::RegexHeaderMap STLPostfixHeaderMap = {
+ {"include/__float_float.h$", "<cfloat>"},
+ {"include/__float_header_macro.h$", "<cfloat>"},
+ {"include/__float_infinity_nan.h$", "<cfloat>"},
{"include/__stdarg___gnuc_va_list.h$", "<cstdarg>"},
{"include/__stdarg___va_copy.h$", "<cstdarg>"},
{"include/__stdarg_header_macro.h$", "<cstdarg>"},
diff --git a/clangd/index/CanonicalIncludes.cpp b/clangd/index/CanonicalIncludes.cpp
index 1f7b525..cbef64f 100644
--- a/clangd/index/CanonicalIncludes.cpp
+++ b/clangd/index/CanonicalIncludes.cpp
@@ -16,6 +16,9 @@
namespace clangd {
namespace {
const std::pair<llvm::StringRef, llvm::StringRef> IncludeMappings[] = {
+ {"include/__float_float.h", "<cfloat>"},
+ {"include/__float_header_macro.h", "<cfloat>"},
+ {"include/__float_infinity_nan.h", "<cfloat>"},
{"include/__stdarg___gnuc_va_list.h", "<cstdarg>"},
{"include/__stdarg___va_copy.h", "<cstdarg>"},
{"include/__stdarg_header_macro.h", "<cstdarg>"},