-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[libc] fix lint warnings from including <fenv.h> #82695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Towards the goal of getting ninja libc-lint back to green, fixes just src/ and not test/. Fixes: libc/src/fenv/fegetexceptflag.cpp:13:1: error: system include fenv.h not allowed [llvmlibc-restrict-system-libc-headers,-warnings-as-errors] 13 | #include <fenv.h> | ^~~~~~~~~~~~~~~~~ /android0/llvm-project/libc/src/fenv/feholdexcept.h:12:1: error: system include fenv.h not allowed, transitively included from libc/src/fenv/feholdexcept.h [llvmlibc-restrict-system-libc-headers,-warnings-as-errors] libc/src/__support/FPUtil/FEnvImpl.h:17:1: error: system include fenv.h not allowed, transitively included from libc/src/__support/FPUtil/FEnvImpl.h [llvmlibc-restrict-system-libc-headers,-warnings-as-errors] libc/src/__support/FPUtil/rounding_mode.h:14:1: error: system include fenv.h not allowed, transitively included from libc/src/__support/FPUtil/rounding_mode.h [llvmlibc-restrict-system-libc-headers,-warnings-as-errors] libc/src/__support/FPUtil/x86_64/FEnvImpl.h:19:1: error: system include fenv.h not allowed, transitively included from libc/src/__support/FPUtil/x86_64/FEnvImpl.h [llvmlibc-restrict-system-libc-headers,-warnings-as-errors] libc/src/fenv/fegetexceptflag.h:12:1: error: system include fenv.h not allowed, transitively included from libc/src/fenv/fegetexceptflag.h [llvmlibc-restrict-system-libc-headers,-warnings-as-errors] libc/src/fenv/feholdexcept.cpp:13:1: error: system include fenv.h not allowed [llvmlibc-restrict-system-libc-headers,-warnings-as-errors] libc/src/fenv/fesetenv.h:12:1: error: system include fenv.h not allowed, transitively included from libc/src/fenv/fesetenv.h [llvmlibc-restrict-system-libc-headers,-warnings-as-errors] libc/src/fenv/fesetexceptflag.cpp:13:1: error: system include fenv.h not allowed [llvmlibc-restrict-system-libc-headers,-warnings-as-errors] libc/src/fenv/fesetexceptflag.h:12:1: error: system include fenv.h not allowed, transitively included from libc/src/fenv/fesetexceptflag.h [llvmlibc-restrict-system-libc-headers,-warnings-as-errors] libc/src/fenv/feupdateenv.cpp:13:1: error: system include fenv.h not allowed [llvmlibc-restrict-system-libc-headers,-warnings-as-errors] libc/src/fenv/feupdateenv.h:12:1: error: system include fenv.h not allowed, transitively included from libc/src/fenv/feupdateenv.h [llvmlibc-restrict-system-libc-headers,-warnings-as-errors]
@llvm/pr-subscribers-libc Author: Nick Desaulniers (nickdesaulniers) ChangesTowards the goal of getting ninja libc-lint back to green, fixes just src/ and
Full diff: https://github.com/llvm/llvm-project/pull/82695.diff 16 Files Affected:
diff --git a/libc/src/__support/FPUtil/FEnvImpl.h b/libc/src/__support/FPUtil/FEnvImpl.h
index 6810659733de2c..ad5cc907188536 100644
--- a/libc/src/__support/FPUtil/FEnvImpl.h
+++ b/libc/src/__support/FPUtil/FEnvImpl.h
@@ -9,12 +9,12 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_FPUTIL_FENVIMPL_H
#define LLVM_LIBC_SRC___SUPPORT_FPUTIL_FENVIMPL_H
+#include "include/llvm-libc-types/fenv_t.h"
#include "src/__support/macros/attributes.h" // LIBC_INLINE
#include "src/__support/macros/config.h" // LIBC_HAS_BUILTIN
#include "src/__support/macros/properties/architectures.h"
#include "src/errno/libc_errno.h"
-#include <fenv.h>
#include <math.h>
#if defined(LIBC_TARGET_ARCH_IS_AARCH64)
diff --git a/libc/src/__support/FPUtil/aarch64/FEnvImpl.h b/libc/src/__support/FPUtil/aarch64/FEnvImpl.h
index e0eec17e038c63..14fc4d336da191 100644
--- a/libc/src/__support/FPUtil/aarch64/FEnvImpl.h
+++ b/libc/src/__support/FPUtil/aarch64/FEnvImpl.h
@@ -9,6 +9,8 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_FPUTIL_AARCH64_FENVIMPL_H
#define LLVM_LIBC_SRC___SUPPORT_FPUTIL_AARCH64_FENVIMPL_H
+#include "include/llvm-libc-macros/fenv-macros.h"
+#include "include/llvm-libc-types/fenv_t.h"
#include "src/__support/macros/attributes.h" // LIBC_INLINE
#include "src/__support/macros/properties/architectures.h"
@@ -17,7 +19,6 @@
#endif
#include <arm_acle.h>
-#include <fenv.h>
#include <stdint.h>
#include "src/__support/FPUtil/FPBits.h"
diff --git a/libc/src/__support/FPUtil/arm/FEnvImpl.h b/libc/src/__support/FPUtil/arm/FEnvImpl.h
index ac4673cf20f632..163976daadb85b 100644
--- a/libc/src/__support/FPUtil/arm/FEnvImpl.h
+++ b/libc/src/__support/FPUtil/arm/FEnvImpl.h
@@ -9,10 +9,11 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_FPUTIL_ARM_FENVIMPL_H
#define LLVM_LIBC_SRC___SUPPORT_FPUTIL_ARM_FENVIMPL_H
+#include "include/llvm-libc-macros/fenv-macros.h"
+#include "include/llvm-libc-types/fenv_t.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/macros/attributes.h" // For LIBC_INLINE
-#include <fenv.h>
#include <stdint.h>
namespace LIBC_NAMESPACE {
diff --git a/libc/src/__support/FPUtil/riscv/FEnvImpl.h b/libc/src/__support/FPUtil/riscv/FEnvImpl.h
index b73c4798b0539a..a00570a9422ec4 100644
--- a/libc/src/__support/FPUtil/riscv/FEnvImpl.h
+++ b/libc/src/__support/FPUtil/riscv/FEnvImpl.h
@@ -9,11 +9,12 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_FPUTIL_RISCV_FENVIMPL_H
#define LLVM_LIBC_SRC___SUPPORT_FPUTIL_RISCV_FENVIMPL_H
+#include "include/llvm-libc-macros/fenv-macros.h"
+#include "include/llvm-libc-types/fenv_t.h"
#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/macros/attributes.h" // For LIBC_INLINE_ASM
#include "src/__support/macros/config.h" // For LIBC_INLINE
-#include <fenv.h>
#include <stdint.h>
namespace LIBC_NAMESPACE {
diff --git a/libc/src/__support/FPUtil/rounding_mode.h b/libc/src/__support/FPUtil/rounding_mode.h
index 91a5b9c50e7c2b..ab90037eb4d895 100644
--- a/libc/src/__support/FPUtil/rounding_mode.h
+++ b/libc/src/__support/FPUtil/rounding_mode.h
@@ -9,10 +9,9 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_FPUTIL_ROUNDING_MODE_H
#define LLVM_LIBC_SRC___SUPPORT_FPUTIL_ROUNDING_MODE_H
+#include "include/llvm-libc-macros/fenv-macros.h"
#include "src/__support/macros/attributes.h" // LIBC_INLINE
-#include <fenv.h>
-
namespace LIBC_NAMESPACE::fputil {
// Quick free-standing test whether fegetround() == FE_UPWARD.
diff --git a/libc/src/__support/FPUtil/x86_64/FEnvImpl.h b/libc/src/__support/FPUtil/x86_64/FEnvImpl.h
index b73b70e907790f..b8e7b58256cda8 100644
--- a/libc/src/__support/FPUtil/x86_64/FEnvImpl.h
+++ b/libc/src/__support/FPUtil/x86_64/FEnvImpl.h
@@ -9,6 +9,8 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_FPUTIL_X86_64_FENVIMPL_H
#define LLVM_LIBC_SRC___SUPPORT_FPUTIL_X86_64_FENVIMPL_H
+#include "include/llvm-libc-macros/fenv-macros.h"
+#include "include/llvm-libc-types/fenv_t.h"
#include "src/__support/macros/attributes.h" // LIBC_INLINE
#include "src/__support/macros/properties/architectures.h"
@@ -16,7 +18,6 @@
#error "Invalid include"
#endif
-#include <fenv.h>
#include <stdint.h>
#include "src/__support/macros/sanitizer.h"
diff --git a/libc/src/fenv/fegetenv.h b/libc/src/fenv/fegetenv.h
index 658316482984e1..27fdfe2440db81 100644
--- a/libc/src/fenv/fegetenv.h
+++ b/libc/src/fenv/fegetenv.h
@@ -9,7 +9,7 @@
#ifndef LLVM_LIBC_SRC_FENV_FEGETENV_H
#define LLVM_LIBC_SRC_FENV_FEGETENV_H
-#include <fenv.h>
+#include "include/llvm-libc-types/fenv_t.h"
namespace LIBC_NAMESPACE {
diff --git a/libc/src/fenv/fegetexceptflag.cpp b/libc/src/fenv/fegetexceptflag.cpp
index 71b87ce7315d1a..1f9aae6085ed8c 100644
--- a/libc/src/fenv/fegetexceptflag.cpp
+++ b/libc/src/fenv/fegetexceptflag.cpp
@@ -6,12 +6,11 @@
//
//===----------------------------------------------------------------------===//
+#include "include/llvm-libc-types/fexcept_t.h"
#include "src/fenv/fegetexceptflag.h"
#include "src/__support/FPUtil/FEnvImpl.h"
#include "src/__support/common.h"
-#include <fenv.h>
-
namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(int, fegetexceptflag, (fexcept_t * flagp, int excepts)) {
diff --git a/libc/src/fenv/fegetexceptflag.h b/libc/src/fenv/fegetexceptflag.h
index ad72161e536f83..aaf5184acce1e3 100644
--- a/libc/src/fenv/fegetexceptflag.h
+++ b/libc/src/fenv/fegetexceptflag.h
@@ -9,7 +9,7 @@
#ifndef LLVM_LIBC_SRC_FENV_FEGETEXCEPTFLAG_H
#define LLVM_LIBC_SRC_FENV_FEGETEXCEPTFLAG_H
-#include <fenv.h>
+#include "include/llvm-libc-types/fexcept_t.h"
namespace LIBC_NAMESPACE {
diff --git a/libc/src/fenv/feholdexcept.cpp b/libc/src/fenv/feholdexcept.cpp
index 3c73b1f4217798..543320cc858463 100644
--- a/libc/src/fenv/feholdexcept.cpp
+++ b/libc/src/fenv/feholdexcept.cpp
@@ -7,11 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/fenv/feholdexcept.h"
+
+#include "include/llvm-libc-macros/fenv-macros.h"
+#include "include/llvm-libc-types/fenv_t.h"
#include "src/__support/FPUtil/FEnvImpl.h"
#include "src/__support/common.h"
-#include <fenv.h>
-
namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(int, feholdexcept, (fenv_t * envp)) {
diff --git a/libc/src/fenv/feholdexcept.h b/libc/src/fenv/feholdexcept.h
index bbefc4ecbd41b2..0405c6fc1e91d5 100644
--- a/libc/src/fenv/feholdexcept.h
+++ b/libc/src/fenv/feholdexcept.h
@@ -9,7 +9,7 @@
#ifndef LLVM_LIBC_SRC_FENV_FEHOLDEXCEPT_H
#define LLVM_LIBC_SRC_FENV_FEHOLDEXCEPT_H
-#include <fenv.h>
+#include "include/llvm-libc-types/fenv_t.h"
namespace LIBC_NAMESPACE {
diff --git a/libc/src/fenv/fesetenv.h b/libc/src/fenv/fesetenv.h
index 8b56bebc2e36d4..f52fc1de753cf8 100644
--- a/libc/src/fenv/fesetenv.h
+++ b/libc/src/fenv/fesetenv.h
@@ -9,7 +9,7 @@
#ifndef LLVM_LIBC_SRC_FENV_FESETENV_H
#define LLVM_LIBC_SRC_FENV_FESETENV_H
-#include <fenv.h>
+#include "include/llvm-libc-types/fenv_t.h"
namespace LIBC_NAMESPACE {
diff --git a/libc/src/fenv/fesetexceptflag.cpp b/libc/src/fenv/fesetexceptflag.cpp
index 2fe7cb571a8ddd..98d33c5b9db489 100644
--- a/libc/src/fenv/fesetexceptflag.cpp
+++ b/libc/src/fenv/fesetexceptflag.cpp
@@ -7,11 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/fenv/fesetexceptflag.h"
+
+#include "include/llvm-libc-macros/fenv-macros.h"
+#include "include/llvm-libc-types/fexcept_t.h"
#include "src/__support/FPUtil/FEnvImpl.h"
#include "src/__support/common.h"
-#include <fenv.h>
-
namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(int, fesetexceptflag,
diff --git a/libc/src/fenv/fesetexceptflag.h b/libc/src/fenv/fesetexceptflag.h
index 15e62eda1b840c..89bff8aeb01180 100644
--- a/libc/src/fenv/fesetexceptflag.h
+++ b/libc/src/fenv/fesetexceptflag.h
@@ -9,7 +9,7 @@
#ifndef LLVM_LIBC_SRC_FENV_FESETEXCEPTFLAG_H
#define LLVM_LIBC_SRC_FENV_FESETEXCEPTFLAG_H
-#include <fenv.h>
+#include "include/llvm-libc-types/fexcept_t.h"
namespace LIBC_NAMESPACE {
diff --git a/libc/src/fenv/feupdateenv.cpp b/libc/src/fenv/feupdateenv.cpp
index 7e81b9476da91b..8eeec26c305a04 100644
--- a/libc/src/fenv/feupdateenv.cpp
+++ b/libc/src/fenv/feupdateenv.cpp
@@ -6,11 +6,12 @@
//
//===----------------------------------------------------------------------===//
+#include "include/llvm-libc-macros/fenv-macros.h"
+#include "include/llvm-libc-types/fenv_t.h"
#include "src/fenv/feupdateenv.h"
#include "src/__support/FPUtil/FEnvImpl.h"
#include "src/__support/common.h"
-#include <fenv.h>
namespace LIBC_NAMESPACE {
diff --git a/libc/src/fenv/feupdateenv.h b/libc/src/fenv/feupdateenv.h
index 294c041ddeae79..4c737cc406e609 100644
--- a/libc/src/fenv/feupdateenv.h
+++ b/libc/src/fenv/feupdateenv.h
@@ -9,7 +9,7 @@
#ifndef LLVM_LIBC_SRC_FENV_FEUPDATEENV_H
#define LLVM_LIBC_SRC_FENV_FEUPDATEENV_H
-#include <fenv.h>
+#include "include/llvm-libc-types/fenv_t.h"
namespace LIBC_NAMESPACE {
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
I think we need to double-check that this is doing the right thing for cases like Fuchsia. The same might apply to the "overlay mode" builds too. In Fuchsia, we're using the llvm-libc sources, but entirely our legacy public API headers for the types users are really using. I think it may well be that |
I think the restrict system headers check should probably be removed at this point. There are too many cases where we do actually need to include system header (such as what's mentioned above). It's important for overlay mode that we include the system's definitions of various structs, such as for fenv or epoll_wait. In fullbuild mode our headers will be used regardless of how we include them. |
I'm happy to do so. Can you point me to where in the Fuchsia sources fenv.h lives? Is it:
|
That's correct. |
Towards the goal of getting ninja libc-lint back to green, fixes just src/ and
not test/. Fixes: