[llvm] 94609ae - [Support] Remove an unnecessary include (#123182)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 16 12:47:26 PST 2025


Author: Martin Storsjö
Date: 2025-01-16T22:47:22+02:00
New Revision: 94609aee73d7123bc9afe002a4987d06eba9f452

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

LOG: [Support] Remove an unnecessary include (#123182)

In 1e53f9523d3d5fcb2993b4b6540f1ed8d743380b, the FileSystem.h header was
changed to always include <sys/stat.h>, while it previously only was
included if HAVE_SYS_STAT_H was defined.

HAVE_SYS_STAT_H was defined in llvm/Config/config.h, while FileSystem.h
only included llvm/Config/llvm-config.h. Thus, <sys/stat.h> was only
being included in some but not all cases.

The change to always include <sys/stat.h> broke compiling LLDB for MinGW
targets, because the MinGW <sys/stat.h> header adds an "#define fstat
_fstat64" define, which breaks LLDBs use of a struct with a member named
"fstat".

Remove the include of <sys/stat.h> in FileSystem.h, as it seems to not
be necessary in practice, fixing compilation of LLDB for MinGW targets.

Change one instance of defined(_MSC_VER) into defined(_WIN32) in
ErrorHandling.cpp to get <io.h> included; this source file did include
config.h before transitively including FileSystem.h. The include of
<sys/stat.h> in FileSystem.h would bring in <io.h> (needed for
::write()), explaining why this ifdef didn't need to cover MinGW before.

Added: 
    

Modified: 
    llvm/include/llvm/Support/FileSystem.h
    llvm/lib/Support/ErrorHandling.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Support/FileSystem.h b/llvm/include/llvm/Support/FileSystem.h
index c16ea2dcbb770f..245e4a24c70df1 100644
--- a/llvm/include/llvm/Support/FileSystem.h
+++ b/llvm/include/llvm/Support/FileSystem.h
@@ -44,8 +44,6 @@
 #include <system_error>
 #include <vector>
 
-#include <sys/stat.h>
-
 namespace llvm {
 namespace sys {
 namespace fs {

diff  --git a/llvm/lib/Support/ErrorHandling.cpp b/llvm/lib/Support/ErrorHandling.cpp
index 8659f9492d5a35..afe3b37cc34319 100644
--- a/llvm/lib/Support/ErrorHandling.cpp
+++ b/llvm/lib/Support/ErrorHandling.cpp
@@ -33,7 +33,7 @@
 #if defined(HAVE_UNISTD_H)
 # include <unistd.h>
 #endif
-#if defined(_MSC_VER)
+#if defined(_WIN32)
 # include <io.h>
 # include <fcntl.h>
 #endif


        


More information about the llvm-commits mailing list