[llvm] r340520 - [Support] Fix some Wundef warnings

Sven van Haastregt via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 23 02:42:58 PDT 2018


Author: svenvh
Date: Thu Aug 23 02:42:58 2018
New Revision: 340520

URL: http://llvm.org/viewvc/llvm-project?rev=340520&view=rev
Log:
[Support] Fix some Wundef warnings

For the _WIN32 macro, it is the definedness that matters rather than
the value.  Most uses of the macro already rely on the definedness.
This commit fixes the few remaining uses that relied on the value.

Differential Revision: https://reviews.llvm.org/D51105

Modified:
    llvm/trunk/lib/Support/COM.cpp
    llvm/trunk/lib/Support/CodeGenCoverage.cpp
    llvm/trunk/lib/Support/Locale.cpp
    llvm/trunk/lib/Support/LockFileManager.cpp

Modified: llvm/trunk/lib/Support/COM.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/COM.cpp?rev=340520&r1=340519&r2=340520&view=diff
==============================================================================
--- llvm/trunk/lib/Support/COM.cpp (original)
+++ llvm/trunk/lib/Support/COM.cpp Thu Aug 23 02:42:58 2018
@@ -18,6 +18,6 @@
 // Include the platform-specific parts of this class.
 #ifdef LLVM_ON_UNIX
 #include "Unix/COM.inc"
-#elif _WIN32
+#elif defined(_WIN32)
 #include "Windows/COM.inc"
 #endif

Modified: llvm/trunk/lib/Support/CodeGenCoverage.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CodeGenCoverage.cpp?rev=340520&r1=340519&r2=340520&view=diff
==============================================================================
--- llvm/trunk/lib/Support/CodeGenCoverage.cpp (original)
+++ llvm/trunk/lib/Support/CodeGenCoverage.cpp Thu Aug 23 02:42:58 2018
@@ -22,7 +22,7 @@
 
 #if LLVM_ON_UNIX
 #include <unistd.h>
-#elif _WIN32
+#elif defined(_WIN32)
 #include <windows.h>
 #endif
 
@@ -93,7 +93,7 @@ bool CodeGenCoverage::emit(StringRef Cov
     std::string Pid =
 #if LLVM_ON_UNIX
         llvm::to_string(::getpid());
-#elif _WIN32
+#elif defined(_WIN32)
         llvm::to_string(::GetCurrentProcessId());
 #else
         "";

Modified: llvm/trunk/lib/Support/Locale.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Locale.cpp?rev=340520&r1=340519&r2=340520&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Locale.cpp (original)
+++ llvm/trunk/lib/Support/Locale.cpp Thu Aug 23 02:42:58 2018
@@ -7,7 +7,7 @@ namespace sys {
 namespace locale {
 
 int columnWidth(StringRef Text) {
-#if _WIN32
+#ifdef _WIN32
   return Text.size();
 #else
   return llvm::sys::unicode::columnWidthUTF8(Text);
@@ -15,7 +15,7 @@ int columnWidth(StringRef Text) {
 }
 
 bool isPrint(int UCS) {
-#if _WIN32
+#ifdef _WIN32
   // Restrict characters that we'll try to print to the lower part of ASCII
   // except for the control characters (0x20 - 0x7E). In general one can not
   // reliably output code points U+0080 and higher using narrow character C/C++

Modified: llvm/trunk/lib/Support/LockFileManager.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/LockFileManager.cpp?rev=340520&r1=340519&r2=340520&view=diff
==============================================================================
--- llvm/trunk/lib/Support/LockFileManager.cpp (original)
+++ llvm/trunk/lib/Support/LockFileManager.cpp Thu Aug 23 02:42:58 2018
@@ -24,7 +24,7 @@
 #include <sys/types.h>
 #include <system_error>
 #include <tuple>
-#if _WIN32
+#ifdef _WIN32
 #include <windows.h>
 #endif
 #if LLVM_ON_UNIX
@@ -295,7 +295,7 @@ LockFileManager::WaitForUnlockResult Loc
   if (getState() != LFS_Shared)
     return Res_Success;
 
-#if _WIN32
+#ifdef _WIN32
   unsigned long Interval = 1;
 #else
   struct timespec Interval;
@@ -310,7 +310,7 @@ LockFileManager::WaitForUnlockResult Loc
     // finish up and remove the lock file.
     // FIXME: Should we hook in to system APIs to get a notification when the
     // lock file is deleted?
-#if _WIN32
+#ifdef _WIN32
     Sleep(Interval);
 #else
     nanosleep(&Interval, nullptr);
@@ -329,7 +329,7 @@ LockFileManager::WaitForUnlockResult Loc
       return Res_OwnerDied;
 
     // Exponentially increase the time we wait for the lock to be removed.
-#if _WIN32
+#ifdef _WIN32
     Interval *= 2;
 #else
     Interval.tv_sec *= 2;
@@ -340,7 +340,7 @@ LockFileManager::WaitForUnlockResult Loc
     }
 #endif
   } while (
-#if _WIN32
+#ifdef _WIN32
            Interval < MaxSeconds * 1000
 #else
            Interval.tv_sec < (time_t)MaxSeconds




More information about the llvm-commits mailing list