[libc-commits] [libc] [libc] fix lint warnings from including <fenv.h> (PR #82695)

Nick Desaulniers via libc-commits libc-commits at lists.llvm.org
Thu Feb 22 14:09:17 PST 2024


https://github.com/nickdesaulniers created https://github.com/llvm/llvm-project/pull/82695

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]


>From 260d8b90e19d095a82bbf7cd32bca7117a0999c0 Mon Sep 17 00:00:00 2001
From: Nick Desaulniers <ndesaulniers at google.com>
Date: Thu, 22 Feb 2024 13:19:05 -0800
Subject: [PATCH] [libc] fix lint warnings from including <fenv.h>

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]
---
 libc/src/__support/FPUtil/FEnvImpl.h         | 2 +-
 libc/src/__support/FPUtil/aarch64/FEnvImpl.h | 3 ++-
 libc/src/__support/FPUtil/arm/FEnvImpl.h     | 3 ++-
 libc/src/__support/FPUtil/riscv/FEnvImpl.h   | 3 ++-
 libc/src/__support/FPUtil/rounding_mode.h    | 3 +--
 libc/src/__support/FPUtil/x86_64/FEnvImpl.h  | 3 ++-
 libc/src/fenv/fegetenv.h                     | 2 +-
 libc/src/fenv/fegetexceptflag.cpp            | 3 +--
 libc/src/fenv/fegetexceptflag.h              | 2 +-
 libc/src/fenv/feholdexcept.cpp               | 5 +++--
 libc/src/fenv/feholdexcept.h                 | 2 +-
 libc/src/fenv/fesetenv.h                     | 2 +-
 libc/src/fenv/fesetexceptflag.cpp            | 5 +++--
 libc/src/fenv/fesetexceptflag.h              | 2 +-
 libc/src/fenv/feupdateenv.cpp                | 3 ++-
 libc/src/fenv/feupdateenv.h                  | 2 +-
 16 files changed, 25 insertions(+), 20 deletions(-)

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 {
 



More information about the libc-commits mailing list