DAWN_PLATFORM and DAWN_COMPILER macro improvements

Change #if DAWN_PLATFORM_XXX to #if DAWN_PLATFORM_IS(XXX)
To prevent #ifdef usage and reference without including
dawn/common/Platform.h

Also change #if DAWN_COMPILER_XXX to # if DAWN_COMPILER_IS(XXX)

Bug: dawn:1447
Change-Id: If6c9dab15fd2676f9a087507f5efcceeff468d33
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92625
Commit-Queue: Shrek Shao <shrekshao@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/include/dawn/native/VulkanBackend.h b/include/dawn/native/VulkanBackend.h
index 410dfcc..9ee4125 100644
--- a/include/dawn/native/VulkanBackend.h
+++ b/include/dawn/native/VulkanBackend.h
@@ -69,7 +69,7 @@
     using ExternalImageExportInfo::ExternalImageExportInfo;
 };
 
-// Can't use DAWN_PLATFORM_LINUX since header included in both Dawn and Chrome
+// Can't use DAWN_PLATFORM_IS(LINUX) since header included in both Dawn and Chrome
 #ifdef __linux__
 
 // Common properties of external images represented by FDs. On successful import the file
diff --git a/src/dawn/common/Assert.h b/src/dawn/common/Assert.h
index ba4a429..244cd41 100644
--- a/src/dawn/common/Assert.h
+++ b/src/dawn/common/Assert.h
@@ -31,7 +31,7 @@
 
 // MSVC triggers a warning in /W4 for do {} while(0). SDL worked around this by using (0,0) and
 // points out that it looks like an owl face.
-#if defined(DAWN_COMPILER_MSVC)
+#if DAWN_COMPILER_IS(MSVC)
 #define DAWN_ASSERT_LOOP_CONDITION (0, 0)
 #else
 #define DAWN_ASSERT_LOOP_CONDITION (0)
@@ -48,9 +48,9 @@
         }                                                         \
     } while (DAWN_ASSERT_LOOP_CONDITION)
 #else
-#if defined(DAWN_COMPILER_MSVC)
+#if DAWN_COMPILER_IS(MSVC)
 #define DAWN_ASSERT_CALLSITE_HELPER(file, func, line, condition) __assume(condition)
-#elif defined(DAWN_COMPILER_CLANG) && defined(__builtin_assume)
+#elif DAWN_COMPILER_IS(CLANG) && defined(__builtin_assume)
 #define DAWN_ASSERT_CALLSITE_HELPER(file, func, line, condition) __builtin_assume(condition)
 #else
 #define DAWN_ASSERT_CALLSITE_HELPER(file, func, line, condition) \
diff --git a/src/dawn/common/Compiler.h b/src/dawn/common/Compiler.h
index fc29c40..eb7e623 100644
--- a/src/dawn/common/Compiler.h
+++ b/src/dawn/common/Compiler.h
@@ -16,7 +16,7 @@
 #define SRC_DAWN_COMMON_COMPILER_H_
 
 // Defines macros for compiler-specific functionality
-//  - DAWN_COMPILER_[CLANG|GCC|MSVC]: Compiler detection
+//  - DAWN_COMPILER_IS(CLANG|GCC|MSVC): Compiler detection
 //  - DAWN_BREAKPOINT(): Raises an exception and breaks in the debugger
 //  - DAWN_BUILTIN_UNREACHABLE(): Hints the compiler that a code path is unreachable
 //  - DAWN_(UN)?LIKELY(EXPR): Where available, hints the compiler that the expression will be true
@@ -30,9 +30,9 @@
 // Clang and GCC, check for __clang__ too to catch clang-cl masquarading as MSVC
 #if defined(__GNUC__) || defined(__clang__)
 #if defined(__clang__)
-#define DAWN_COMPILER_CLANG
+#define DAWN_COMPILER_IS_CLANG 1
 #else
-#define DAWN_COMPILER_GCC
+#define DAWN_COMPILER_IS_GCC 1
 #endif
 
 #if defined(__i386__) || defined(__x86_64__)
@@ -58,7 +58,7 @@
 
 // MSVC
 #elif defined(_MSC_VER)
-#define DAWN_COMPILER_MSVC
+#define DAWN_COMPILER_IS_MSVC 1
 
 extern void __cdecl __debugbreak(void);
 #define DAWN_BREAKPOINT() __debugbreak()
@@ -75,6 +75,23 @@
 #error "Unsupported compiler"
 #endif
 
+// This section defines other compiler macros to 0 to avoid undefined macro usage error.
+#if !defined(DAWN_COMPILER_IS_CLANG)
+#define DAWN_COMPILER_IS_CLANG 0
+#endif
+#if !defined(DAWN_COMPILER_IS_GCC)
+#define DAWN_COMPILER_IS_GCC 0
+#endif
+#if !defined(DAWN_COMPILER_IS_MSVC)
+#define DAWN_COMPILER_IS_MSVC 0
+#endif
+
+// Use #if DAWN_COMPILER_IS(XXX) for compiler specific code.
+// Do not use #ifdef or the naked macro DAWN_COMPILER_IS_XXX.
+// This can help avoid common mistakes like not including "Compiler.h" and falling into unwanted
+// code block as usage of undefined macro "function" will be blocked by the compiler.
+#define DAWN_COMPILER_IS(X) (1 == DAWN_COMPILER_IS_##X)
+
 // It seems that (void) EXPR works on all compilers to silence the unused variable warning.
 #define DAWN_UNUSED(EXPR) (void)EXPR
 // Likewise using static asserting on sizeof(&FUNC) seems to make it tagged as used
diff --git a/src/dawn/common/DynamicLib.cpp b/src/dawn/common/DynamicLib.cpp
index 8767ec4..479ca65 100644
--- a/src/dawn/common/DynamicLib.cpp
+++ b/src/dawn/common/DynamicLib.cpp
@@ -18,12 +18,12 @@
 
 #include "dawn/common/Platform.h"
 
-#if DAWN_PLATFORM_WINDOWS
+#if DAWN_PLATFORM_IS(WINDOWS)
 #include "dawn/common/windows_with_undefs.h"
-#if DAWN_PLATFORM_WINUWP
+#if DAWN_PLATFORM_IS(WINUWP)
 #include "dawn/common/WindowsUtils.h"
 #endif
-#elif DAWN_PLATFORM_POSIX
+#elif DAWN_PLATFORM_IS(POSIX)
 #include <dlfcn.h>
 #else
 #error "Unsupported platform for DynamicLib"
@@ -47,8 +47,8 @@
 }
 
 bool DynamicLib::Open(const std::string& filename, std::string* error) {
-#if DAWN_PLATFORM_WINDOWS
-#if DAWN_PLATFORM_WINUWP
+#if DAWN_PLATFORM_IS(WINDOWS)
+#if DAWN_PLATFORM_IS(WINUWP)
     mHandle = LoadPackagedLibrary(UTF8ToWStr(filename.c_str()).c_str(), 0);
 #else
     mHandle = LoadLibraryA(filename.c_str());
@@ -56,7 +56,7 @@
     if (mHandle == nullptr && error != nullptr) {
         *error = "Windows Error: " + std::to_string(GetLastError());
     }
-#elif DAWN_PLATFORM_POSIX
+#elif DAWN_PLATFORM_IS(POSIX)
     mHandle = dlopen(filename.c_str(), RTLD_NOW);
 
     if (mHandle == nullptr && error != nullptr) {
@@ -74,9 +74,9 @@
         return;
     }
 
-#if DAWN_PLATFORM_WINDOWS
+#if DAWN_PLATFORM_IS(WINDOWS)
     FreeLibrary(static_cast<HMODULE>(mHandle));
-#elif DAWN_PLATFORM_POSIX
+#elif DAWN_PLATFORM_IS(POSIX)
     dlclose(mHandle);
 #else
 #error "Unsupported platform for DynamicLib"
@@ -88,13 +88,13 @@
 void* DynamicLib::GetProc(const std::string& procName, std::string* error) const {
     void* proc = nullptr;
 
-#if DAWN_PLATFORM_WINDOWS
+#if DAWN_PLATFORM_IS(WINDOWS)
     proc = reinterpret_cast<void*>(GetProcAddress(static_cast<HMODULE>(mHandle), procName.c_str()));
 
     if (proc == nullptr && error != nullptr) {
         *error = "Windows Error: " + std::to_string(GetLastError());
     }
-#elif DAWN_PLATFORM_POSIX
+#elif DAWN_PLATFORM_IS(POSIX)
     proc = reinterpret_cast<void*>(dlsym(mHandle, procName.c_str()));
 
     if (proc == nullptr && error != nullptr) {
diff --git a/src/dawn/common/HashUtils.h b/src/dawn/common/HashUtils.h
index 342c9b6..e8d1782 100644
--- a/src/dawn/common/HashUtils.h
+++ b/src/dawn/common/HashUtils.h
@@ -45,9 +45,9 @@
 //    return hash;
 template <typename T>
 void HashCombine(size_t* hash, const T& value) {
-#if defined(DAWN_PLATFORM_64_BIT)
+#if DAWN_PLATFORM_IS(64_BIT)
     const size_t offset = 0x9e3779b97f4a7c16;
-#elif defined(DAWN_PLATFORM_32_BIT)
+#elif DAWN_PLATFORM_IS(32_BIT)
     const size_t offset = 0x9e3779b9;
 #else
 #error "Unsupported platform"
diff --git a/src/dawn/common/Log.cpp b/src/dawn/common/Log.cpp
index 6034fe1..5edc40e 100644
--- a/src/dawn/common/Log.cpp
+++ b/src/dawn/common/Log.cpp
@@ -20,7 +20,7 @@
 #include "dawn/common/Assert.h"
 #include "dawn/common/Platform.h"
 
-#if defined(DAWN_PLATFORM_ANDROID)
+#if DAWN_PLATFORM_IS(ANDROID)
 #include <android/log.h>
 #endif
 
@@ -44,7 +44,7 @@
     }
 }
 
-#if defined(DAWN_PLATFORM_ANDROID)
+#if DAWN_PLATFORM_IS(ANDROID)
 android_LogPriority AndroidLogPriority(LogSeverity severity) {
     switch (severity) {
         case LogSeverity::Debug:
@@ -60,7 +60,7 @@
             return ANDROID_LOG_ERROR;
     }
 }
-#endif  // defined(DAWN_PLATFORM_ANDROID)
+#endif  // DAWN_PLATFORM_IS(ANDROID)
 
 }  // anonymous namespace
 
@@ -85,10 +85,10 @@
 
     const char* severityName = SeverityName(mSeverity);
 
-#if defined(DAWN_PLATFORM_ANDROID)
+#if DAWN_PLATFORM_IS(ANDROID)
     android_LogPriority androidPriority = AndroidLogPriority(mSeverity);
     __android_log_print(androidPriority, "Dawn", "%s: %s\n", severityName, fullMessage.c_str());
-#else   // defined(DAWN_PLATFORM_ANDROID)
+#else   // DAWN_PLATFORM_IS(ANDROID)
     FILE* outputStream = stdout;
     if (mSeverity == LogSeverity::Warning || mSeverity == LogSeverity::Error) {
         outputStream = stderr;
@@ -97,7 +97,7 @@
     // Note: we use fprintf because <iostream> includes static initializers.
     fprintf(outputStream, "%s: %s\n", severityName, fullMessage.c_str());
     fflush(outputStream);
-#endif  // defined(DAWN_PLATFORM_ANDROID)
+#endif  // DAWN_PLATFORM_IS(ANDROID)
 }
 
 LogMessage DebugLog() {
diff --git a/src/dawn/common/Math.cpp b/src/dawn/common/Math.cpp
index 3ee1ba3..a3794e2 100644
--- a/src/dawn/common/Math.cpp
+++ b/src/dawn/common/Math.cpp
@@ -21,13 +21,13 @@
 #include "dawn/common/Assert.h"
 #include "dawn/common/Platform.h"
 
-#if defined(DAWN_COMPILER_MSVC)
+#if DAWN_COMPILER_IS(MSVC)
 #include <intrin.h>
 #endif
 
 uint32_t ScanForward(uint32_t bits) {
     ASSERT(bits != 0);
-#if defined(DAWN_COMPILER_MSVC)
+#if DAWN_COMPILER_IS(MSVC)
     // NOLINTNEXTLINE(runtime/int)
     unsigned long firstBitIndex = 0ul;
     unsigned char ret = _BitScanForward(&firstBitIndex, bits);
@@ -40,7 +40,7 @@
 
 uint32_t Log2(uint32_t value) {
     ASSERT(value != 0);
-#if defined(DAWN_COMPILER_MSVC)
+#if DAWN_COMPILER_IS(MSVC)
     // NOLINTNEXTLINE(runtime/int)
     unsigned long firstBitIndex = 0ul;
     unsigned char ret = _BitScanReverse(&firstBitIndex, value);
@@ -53,14 +53,14 @@
 
 uint32_t Log2(uint64_t value) {
     ASSERT(value != 0);
-#if defined(DAWN_COMPILER_MSVC)
-#if defined(DAWN_PLATFORM_64_BIT)
+#if DAWN_COMPILER_IS(MSVC)
+#if DAWN_PLATFORM_IS(64_BIT)
     // NOLINTNEXTLINE(runtime/int)
     unsigned long firstBitIndex = 0ul;
     unsigned char ret = _BitScanReverse64(&firstBitIndex, value);
     ASSERT(ret != 0);
     return firstBitIndex;
-#else   // defined(DAWN_PLATFORM_64_BIT)
+#else   // DAWN_PLATFORM_IS(64_BIT)
     // NOLINTNEXTLINE(runtime/int)
     unsigned long firstBitIndex = 0ul;
     if (_BitScanReverse(&firstBitIndex, value >> 32)) {
@@ -69,10 +69,10 @@
     unsigned char ret = _BitScanReverse(&firstBitIndex, value & 0xFFFFFFFF);
     ASSERT(ret != 0);
     return firstBitIndex;
-#endif  // defined(DAWN_PLATFORM_64_BIT)
-#else   // defined(DAWN_COMPILER_MSVC)
+#endif  // DAWN_PLATFORM_IS(64_BIT)
+#else   // DAWN_COMPILER_IS(MSVC)
     return 63 - static_cast<uint32_t>(__builtin_clzll(value));
-#endif  // defined(DAWN_COMPILER_MSVC)
+#endif  // DAWN_COMPILER_IS(MSVC)
 }
 
 uint64_t NextPowerOfTwo(uint64_t n) {
diff --git a/src/dawn/common/Platform.h b/src/dawn/common/Platform.h
index 8e81b48..2a86434 100644
--- a/src/dawn/common/Platform.h
+++ b/src/dawn/common/Platform.h
@@ -17,41 +17,41 @@
 
 #if defined(_WIN32) || defined(_WIN64)
 #include <winapifamily.h>
-#define DAWN_PLATFORM_WINDOWS 1
+#define DAWN_PLATFORM_IS_WINDOWS 1
 #if WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP
-#define DAWN_PLATFORM_WIN32 1
+#define DAWN_PLATFORM_IS_WIN32 1
 #elif WINAPI_FAMILY == WINAPI_FAMILY_PC_APP
-#define DAWN_PLATFORM_WINUWP 1
+#define DAWN_PLATFORM_IS_WINUWP 1
 #else
 #error "Unsupported Windows platform."
 #endif
 
 #elif defined(__linux__)
-#define DAWN_PLATFORM_LINUX 1
-#define DAWN_PLATFORM_POSIX 1
+#define DAWN_PLATFORM_IS_LINUX 1
+#define DAWN_PLATFORM_IS_POSIX 1
 #if defined(__ANDROID__)
-#define DAWN_PLATFORM_ANDROID 1
+#define DAWN_PLATFORM_IS_ANDROID 1
 #endif
 
 #elif defined(__APPLE__)
-#define DAWN_PLATFORM_APPLE 1
-#define DAWN_PLATFORM_POSIX 1
+#define DAWN_PLATFORM_IS_APPLE 1
+#define DAWN_PLATFORM_IS_POSIX 1
 #include <TargetConditionals.h>
 #if TARGET_OS_IPHONE
-#define DAWN_PLATFORM_IOS
+#define DAWN_PLATFORM_IS_IOS 1
 #elif TARGET_OS_MAC
-#define DAWN_PLATFORM_MACOS
+#define DAWN_PLATFORM_IS_MACOS 1
 #else
 #error "Unsupported Apple platform."
 #endif
 
 #elif defined(__Fuchsia__)
-#define DAWN_PLATFORM_FUCHSIA 1
-#define DAWN_PLATFORM_POSIX 1
+#define DAWN_PLATFORM_IS_FUCHSIA 1
+#define DAWN_PLATFORM_IS_POSIX 1
 
 #elif defined(__EMSCRIPTEN__)
-#define DAWN_PLATFORM_EMSCRIPTEN 1
-#define DAWN_PLATFORM_POSIX 1
+#define DAWN_PLATFORM_IS_EMSCRIPTEN 1
+#define DAWN_PLATFORM_IS_POSIX 1
 
 #else
 #error "Unsupported platform."
@@ -69,14 +69,66 @@
 
 #if defined(_WIN64) || defined(__aarch64__) || defined(__x86_64__) || defined(__mips64__) || \
     defined(__s390x__) || defined(__PPC64__)
-#define DAWN_PLATFORM_64_BIT 1
+#define DAWN_PLATFORM_IS_64_BIT 1
 static_assert(sizeof(sizeof(char)) == 8, "Expect sizeof(size_t) == 8");
 #elif defined(_WIN32) || defined(__arm__) || defined(__i386__) || defined(__mips32__) || \
     defined(__s390__) || defined(__EMSCRIPTEN__)
-#define DAWN_PLATFORM_32_BIT 1
+#define DAWN_PLATFORM_IS_32_BIT 1
 static_assert(sizeof(sizeof(char)) == 4, "Expect sizeof(size_t) == 4");
 #else
 #error "Unsupported platform"
 #endif
 
+// This section define other platform macros to 0 to avoid undefined macro usage error.
+#if !defined(DAWN_PLATFORM_IS_WINDOWS)
+#define DAWN_PLATFORM_IS_WINDOWS 0
+#endif
+#if !defined(DAWN_PLATFORM_IS_WIN32)
+#define DAWN_PLATFORM_IS_WIN32 0
+#endif
+#if !defined(DAWN_PLATFORM_IS_WINUWP)
+#define DAWN_PLATFORM_IS_WINUWP 0
+#endif
+
+#if !defined(DAWN_PLATFORM_IS_POSIX)
+#define DAWN_PLATFORM_IS_POSIX 0
+#endif
+
+#if !defined(DAWN_PLATFORM_IS_LINUX)
+#define DAWN_PLATFORM_IS_LINUX 0
+#endif
+#if !defined(DAWN_PLATFORM_IS_ANDROID)
+#define DAWN_PLATFORM_IS_ANDROID 0
+#endif
+
+#if !defined(DAWN_PLATFORM_IS_APPLE)
+#define DAWN_PLATFORM_IS_APPLE 0
+#endif
+#if !defined(DAWN_PLATFORM_IS_IOS)
+#define DAWN_PLATFORM_IS_IOS 0
+#endif
+#if !defined(DAWN_PLATFORM_IS_MACOS)
+#define DAWN_PLATFORM_IS_MACOS 0
+#endif
+
+#if !defined(DAWN_PLATFORM_IS_FUCHSIA)
+#define DAWN_PLATFORM_IS_FUCHSIA 0
+#endif
+#if !defined(DAWN_PLATFORM_IS_EMSCRIPTEN)
+#define DAWN_PLATFORM_IS_EMSCRIPTEN 0
+#endif
+
+#if !defined(DAWN_PLATFORM_IS_64_BIT)
+#define DAWN_PLATFORM_IS_64_BIT 0
+#endif
+#if !defined(DAWN_PLATFORM_IS_32_BIT)
+#define DAWN_PLATFORM_IS_32_BIT 0
+#endif
+
+// Use #if DAWN_PLATFORM_IS(XXX) for platform specific code.
+// Do not use #ifdef or the naked macro DAWN_PLATFORM_IS_XXX.
+// This can help avoid common mistakes like not including "Platform.h" and falling into unwanted
+// code block as usage of undefined macro "function" will be blocked by the compiler.
+#define DAWN_PLATFORM_IS(X) (1 == DAWN_PLATFORM_IS_##X)
+
 #endif  // SRC_DAWN_COMMON_PLATFORM_H_
diff --git a/src/dawn/common/StackContainer.h b/src/dawn/common/StackContainer.h
index a69c3f1..1d1d7ca 100644
--- a/src/dawn/common/StackContainer.h
+++ b/src/dawn/common/StackContainer.h
@@ -51,7 +51,7 @@
         // constructors and destructors to be automatically called. Define a POD
         // buffer of the right size instead.
         alignas(T) char stack_buffer_[sizeof(T[stack_capacity])];
-#if defined(DAWN_COMPILER_GCC) && !defined(__x86_64__) && !defined(__i386__)
+#if DAWN_COMPILER_IS(GCC) && !defined(__x86_64__) && !defined(__i386__)
         static_assert(alignof(T) <= 16, "http://crbug.com/115612");
 #endif
 
diff --git a/src/dawn/common/SystemUtils.cpp b/src/dawn/common/SystemUtils.cpp
index dcdb6f0..cad3595 100644
--- a/src/dawn/common/SystemUtils.cpp
+++ b/src/dawn/common/SystemUtils.cpp
@@ -17,15 +17,15 @@
 #include "dawn/common/Assert.h"
 #include "dawn/common/Log.h"
 
-#if defined(DAWN_PLATFORM_WINDOWS)
+#if DAWN_PLATFORM_IS(WINDOWS)
 #include <Windows.h>
 #include <vector>
-#elif defined(DAWN_PLATFORM_LINUX)
+#elif DAWN_PLATFORM_IS(LINUX)
 #include <dlfcn.h>
 #include <limits.h>
 #include <unistd.h>
 #include <cstdlib>
-#elif defined(DAWN_PLATFORM_MACOS) || defined(DAWN_PLATFORM_IOS)
+#elif DAWN_PLATFORM_IS(MACOS) || DAWN_PLATFORM_IS(IOS)
 #include <dlfcn.h>
 #include <mach-o/dyld.h>
 #include <vector>
@@ -33,7 +33,7 @@
 
 #include <array>
 
-#if defined(DAWN_PLATFORM_WINDOWS)
+#if DAWN_PLATFORM_IS(WINDOWS)
 const char* GetPathSeparator() {
     return "\\";
 }
@@ -66,7 +66,7 @@
 bool SetEnvironmentVar(const char* variableName, const char* value) {
     return SetEnvironmentVariableA(variableName, value) == TRUE;
 }
-#elif defined(DAWN_PLATFORM_POSIX)
+#elif DAWN_PLATFORM_IS(POSIX)
 const char* GetPathSeparator() {
     return "/";
 }
@@ -87,7 +87,7 @@
 #error "Implement Get/SetEnvironmentVar for your platform."
 #endif
 
-#if defined(DAWN_PLATFORM_WINDOWS)
+#if DAWN_PLATFORM_IS(WINDOWS)
 std::optional<std::string> GetHModulePath(HMODULE module) {
     std::array<char, MAX_PATH> executableFileBuf;
     DWORD executablePathLen = GetModuleFileNameA(nullptr, executableFileBuf.data(),
@@ -100,7 +100,7 @@
 std::optional<std::string> GetExecutablePath() {
     return GetHModulePath(nullptr);
 }
-#elif defined(DAWN_PLATFORM_LINUX)
+#elif DAWN_PLATFORM_IS(LINUX)
 std::optional<std::string> GetExecutablePath() {
     std::array<char, PATH_MAX> path;
     ssize_t result = readlink("/proc/self/exe", path.data(), PATH_MAX - 1);
@@ -111,7 +111,7 @@
     path[result] = '\0';
     return path.data();
 }
-#elif defined(DAWN_PLATFORM_MACOS) || defined(DAWN_PLATFORM_IOS)
+#elif DAWN_PLATFORM_IS(MACOS) || DAWN_PLATFORM_IS(IOS)
 std::optional<std::string> GetExecutablePath() {
     uint32_t size = 0;
     _NSGetExecutablePath(nullptr, &size);
@@ -124,12 +124,12 @@
     buffer[size] = '\0';
     return buffer.data();
 }
-#elif defined(DAWN_PLATFORM_FUCHSIA)
+#elif DAWN_PLATFORM_IS(FUCHSIA)
 std::optional<std::string> GetExecutablePath() {
     // UNIMPLEMENTED
     return {};
 }
-#elif defined(DAWN_PLATFORM_EMSCRIPTEN)
+#elif DAWN_PLATFORM_IS(EMSCRIPTEN)
 std::optional<std::string> GetExecutablePath() {
     return {};
 }
@@ -149,7 +149,7 @@
     return exePath->substr(0, lastPathSepLoc + 1);
 }
 
-#if defined(DAWN_PLATFORM_LINUX) || defined(DAWN_PLATFORM_MACOS) || defined(DAWN_PLATFORM_IOS)
+#if DAWN_PLATFORM_IS(LINUX) || DAWN_PLATFORM_IS(MACOS) || DAWN_PLATFORM_IS(IOS)
 std::optional<std::string> GetModulePath() {
     static int placeholderSymbol = 0;
     Dl_info dlInfo;
@@ -163,7 +163,7 @@
     }
     return absolutePath.data();
 }
-#elif defined(DAWN_PLATFORM_WINDOWS)
+#elif DAWN_PLATFORM_IS(WINDOWS)
 std::optional<std::string> GetModulePath() {
     static int placeholderSymbol = 0;
     HMODULE module = nullptr;
@@ -179,11 +179,11 @@
 #endif
     return GetHModulePath(module);
 }
-#elif defined(DAWN_PLATFORM_FUCHSIA)
+#elif DAWN_PLATFORM_IS(FUCHSIA)
 std::optional<std::string> GetModulePath() {
     return {};
 }
-#elif defined(DAWN_PLATFORM_EMSCRIPTEN)
+#elif DAWN_PLATFORM_IS(EMSCRIPTEN)
 std::optional<std::string> GetModulePath() {
     return {};
 }
diff --git a/src/dawn/common/SystemUtils.h b/src/dawn/common/SystemUtils.h
index 021e70e..ed37085 100644
--- a/src/dawn/common/SystemUtils.h
+++ b/src/dawn/common/SystemUtils.h
@@ -33,7 +33,7 @@
 std::optional<std::string> GetExecutableDirectory();
 std::optional<std::string> GetModuleDirectory();
 
-#ifdef DAWN_PLATFORM_MACOS
+#if DAWN_PLATFORM_IS(MACOS)
 void GetMacOSVersion(int32_t* majorVersion, int32_t* minorVersion = nullptr);
 bool IsMacOSVersionAtLeast(uint32_t majorVersion, uint32_t minorVersion = 0);
 #endif
diff --git a/src/dawn/common/ityp_bitset.h b/src/dawn/common/ityp_bitset.h
index e9cfa05..0be94a7 100644
--- a/src/dawn/common/ityp_bitset.h
+++ b/src/dawn/common/ityp_bitset.h
@@ -16,6 +16,7 @@
 #define SRC_DAWN_COMMON_ITYP_BITSET_H_
 
 #include "dawn/common/BitSetIterator.h"
+#include "dawn/common/Platform.h"
 #include "dawn/common/TypedInteger.h"
 #include "dawn/common/UnderlyingType.h"
 
@@ -124,9 +125,9 @@
 template <typename Index, size_t N>
 Index GetHighestBitIndexPlusOne(const ityp::bitset<Index, N>& bitset) {
     using I = UnderlyingType<Index>;
-#if defined(DAWN_COMPILER_MSVC)
+#if DAWN_COMPILER_IS(MSVC)
     if constexpr (N > 32) {
-#if defined(DAWN_PLATFORM_64_BIT)
+#if DAWN_PLATFORM_IS(64_BIT)
         // NOLINTNEXTLINE(runtime/int)
         unsigned long firstBitIndex = 0ul;
         unsigned char ret = _BitScanReverse64(&firstBitIndex, bitset.to_ullong());
@@ -134,7 +135,7 @@
             return Index(static_cast<I>(0));
         }
         return Index(static_cast<I>(firstBitIndex + 1));
-#else   // defined(DAWN_PLATFORM_64_BIT)
+#else   // DAWN_PLATFORM_IS(64_BIT)
         if (bitset.none()) {
             return Index(static_cast<I>(0));
         }
@@ -144,7 +145,7 @@
             }
         }
         UNREACHABLE();
-#endif  // defined(DAWN_PLATFORM_64_BIT)
+#endif  // DAWN_PLATFORM_IS(64_BIT)
     } else {
         // NOLINTNEXTLINE(runtime/int)
         unsigned long firstBitIndex = 0ul;
@@ -154,7 +155,7 @@
         }
         return Index(static_cast<I>(firstBitIndex + 1));
     }
-#else   // defined(DAWN_COMPILER_MSVC)
+#else   // DAWN_COMPILER_IS(MSVC)
     if (bitset.none()) {
         return Index(static_cast<I>(0));
     }
@@ -164,7 +165,7 @@
     } else {
         return Index(static_cast<I>(32 - static_cast<uint32_t>(__builtin_clz(bitset.to_ulong()))));
     }
-#endif  // defined(DAWN_COMPILER_MSVC)
+#endif  // DAWN_COMPILER_IS(MSVC)
 }
 
 #endif  // SRC_DAWN_COMMON_ITYP_BITSET_H_
diff --git a/src/dawn/common/vulkan_platform.h b/src/dawn/common/vulkan_platform.h
index 848ee75..d38d4ca 100644
--- a/src/dawn/common/vulkan_platform.h
+++ b/src/dawn/common/vulkan_platform.h
@@ -35,7 +35,7 @@
 // redefined to be nullptr). This keeps the type-safety of having the handles be different types
 // (like vulkan.h on 64 bit) but makes sure the types are different on 32 bit architectures.
 
-#if defined(DAWN_PLATFORM_64_BIT)
+#if DAWN_PLATFORM_IS(64_BIT)
 #define DAWN_DEFINE_NATIVE_NON_DISPATCHABLE_HANDLE(object) using object = struct object##_T*;
 // This function is needed because MSVC doesn't accept reinterpret_cast from uint64_t from uint64_t
 // TODO(cwallez@chromium.org): Remove this once we rework vulkan_platform.h
@@ -43,7 +43,7 @@
 T NativeNonDispatachableHandleFromU64(uint64_t u64) {
     return reinterpret_cast<T>(u64);
 }
-#elif defined(DAWN_PLATFORM_32_BIT)
+#elif DAWN_PLATFORM_IS(32_BIT)
 #define DAWN_DEFINE_NATIVE_NON_DISPATCHABLE_HANDLE(object) using object = uint64_t;
 template <typename T>
 T NativeNonDispatachableHandleFromU64(uint64_t u64) {
@@ -138,12 +138,12 @@
 // headers that vulkan.h includes that we have "undefs" for. Note that some of the VK_USE_PLATFORM_*
 // defines are defined already in the Vulkan-Header BUILD.gn, but are needed when building with
 // CMake, hence they cannot be removed at the moment.
-#if defined(DAWN_PLATFORM_WINDOWS)
+#if DAWN_PLATFORM_IS(WINDOWS)
 #ifndef VK_USE_PLATFORM_WIN32_KHR
 #define VK_USE_PLATFORM_WIN32_KHR
 #endif
 #include "dawn/common/windows_with_undefs.h"
-#endif  // DAWN_PLATFORM_WINDOWS
+#endif  // DAWN_PLATFORM_IS(WINDOWS)
 
 #if defined(DAWN_USE_X11)
 #define VK_USE_PLATFORM_XLIB_KHR
@@ -165,17 +165,17 @@
 #endif
 #endif  // defined(DAWN_ENABLE_BACKEND_METAL)
 
-#if defined(DAWN_PLATFORM_ANDROID)
+#if DAWN_PLATFORM_IS(ANDROID)
 #ifndef VK_USE_PLATFORM_ANDROID_KHR
 #define VK_USE_PLATFORM_ANDROID_KHR
 #endif
-#endif  // defined(DAWN_PLATFORM_ANDROID)
+#endif  // DAWN_PLATFORM_IS(ANDROID)
 
-#if defined(DAWN_PLATFORM_FUCHSIA)
+#if DAWN_PLATFORM_IS(FUCHSIA)
 #ifndef VK_USE_PLATFORM_FUCHSIA
 #define VK_USE_PLATFORM_FUCHSIA
 #endif
-#endif  // defined(DAWN_PLATFORM_FUCHSIA)
+#endif  // DAWN_PLATFORM_IS(FUCHSIA)
 
 // The actual inclusion of vulkan.h!
 #define VK_NO_PROTOTYPES
diff --git a/src/dawn/common/windows_with_undefs.h b/src/dawn/common/windows_with_undefs.h
index 63c27db..858234f 100644
--- a/src/dawn/common/windows_with_undefs.h
+++ b/src/dawn/common/windows_with_undefs.h
@@ -17,7 +17,7 @@
 
 #include "dawn/common/Platform.h"
 
-#if !defined(DAWN_PLATFORM_WINDOWS)
+#if !DAWN_PLATFORM_IS(WINDOWS)
 #error "windows_with_undefs.h included on non-Windows"
 #endif
 
diff --git a/src/dawn/common/xlib_with_undefs.h b/src/dawn/common/xlib_with_undefs.h
index f9db481..4835513 100644
--- a/src/dawn/common/xlib_with_undefs.h
+++ b/src/dawn/common/xlib_with_undefs.h
@@ -17,7 +17,7 @@
 
 #include "dawn/common/Platform.h"
 
-#if !defined(DAWN_PLATFORM_LINUX)
+#if !DAWN_PLATFORM_IS(LINUX)
 #error "xlib_with_undefs.h included on non-Linux"
 #endif
 
diff --git a/src/dawn/native/Surface.cpp b/src/dawn/native/Surface.cpp
index c340ccf..6822dbb 100644
--- a/src/dawn/native/Surface.cpp
+++ b/src/dawn/native/Surface.cpp
@@ -19,10 +19,10 @@
 #include "dawn/native/Instance.h"
 #include "dawn/native/SwapChain.h"
 
-#if defined(DAWN_PLATFORM_WINDOWS)
+#if DAWN_PLATFORM_IS(WINDOWS)
 #include <windows.ui.core.h>
 #include <windows.ui.xaml.controls.h>
-#endif  // defined(DAWN_PLATFORM_WINDOWS)
+#endif  // DAWN_PLATFORM_IS(WINDOWS)
 
 #if defined(DAWN_USE_X11)
 #include "dawn/common/xlib_with_undefs.h"
@@ -87,7 +87,7 @@
     }
 #endif  // defined(DAWN_ENABLE_BACKEND_METAL)
 
-#if defined(DAWN_PLATFORM_ANDROID)
+#if DAWN_PLATFORM_IS(ANDROID)
     const SurfaceDescriptorFromAndroidNativeWindow* androidDesc = nullptr;
     FindInChain(descriptor->nextInChain, &androidDesc);
     // Currently the best validation we can do since it's not possible to check if the pointer
@@ -96,17 +96,17 @@
         DAWN_INVALID_IF(androidDesc->window == nullptr, "Android window is not set.");
         return {};
     }
-#endif  // defined(DAWN_PLATFORM_ANDROID)
+#endif  // DAWN_PLATFORM_IS(ANDROID)
 
-#if defined(DAWN_PLATFORM_WINDOWS)
-#if defined(DAWN_PLATFORM_WIN32)
+#if DAWN_PLATFORM_IS(WINDOWS)
+#if DAWN_PLATFORM_IS(WIN32)
     const SurfaceDescriptorFromWindowsHWND* hwndDesc = nullptr;
     FindInChain(descriptor->nextInChain, &hwndDesc);
     if (hwndDesc) {
         DAWN_INVALID_IF(IsWindow(static_cast<HWND>(hwndDesc->hwnd)) == 0, "Invalid HWND");
         return {};
     }
-#endif  // defined(DAWN_PLATFORM_WIN32)
+#endif  // DAWN_PLATFORM_IS(WIN32)
     const SurfaceDescriptorFromWindowsCoreWindow* coreWindowDesc = nullptr;
     FindInChain(descriptor->nextInChain, &coreWindowDesc);
     if (coreWindowDesc) {
@@ -129,7 +129,7 @@
                         "Invalid SwapChainPanel");
         return {};
     }
-#endif  // defined(DAWN_PLATFORM_WINDOWS)
+#endif  // DAWN_PLATFORM_IS(WINDOWS)
 
 #if defined(DAWN_USE_WAYLAND)
     const SurfaceDescriptorFromWaylandSurface* waylandDesc = nullptr;
@@ -203,15 +203,15 @@
         mHInstance = hwndDesc->hinstance;
         mHWND = hwndDesc->hwnd;
     } else if (coreWindowDesc) {
-#if defined(DAWN_PLATFORM_WINDOWS)
+#if DAWN_PLATFORM_IS(WINDOWS)
         mType = Type::WindowsCoreWindow;
         mCoreWindow = static_cast<IUnknown*>(coreWindowDesc->coreWindow);
-#endif  // defined(DAWN_PLATFORM_WINDOWS)
+#endif  // DAWN_PLATFORM_IS(WINDOWS)
     } else if (swapChainPanelDesc) {
-#if defined(DAWN_PLATFORM_WINDOWS)
+#if DAWN_PLATFORM_IS(WINDOWS)
         mType = Type::WindowsSwapChainPanel;
         mSwapChainPanel = static_cast<IUnknown*>(swapChainPanelDesc->swapChainPanel);
-#endif  // defined(DAWN_PLATFORM_WINDOWS)
+#endif  // DAWN_PLATFORM_IS(WINDOWS)
     } else if (xDesc) {
         mType = Type::XlibWindow;
         mXDisplay = xDesc->display;
@@ -283,7 +283,7 @@
 IUnknown* Surface::GetCoreWindow() const {
     ASSERT(!IsError());
     ASSERT(mType == Type::WindowsCoreWindow);
-#if defined(DAWN_PLATFORM_WINDOWS)
+#if DAWN_PLATFORM_IS(WINDOWS)
     return mCoreWindow.Get();
 #else
     return nullptr;
@@ -293,7 +293,7 @@
 IUnknown* Surface::GetSwapChainPanel() const {
     ASSERT(!IsError());
     ASSERT(mType == Type::WindowsSwapChainPanel);
-#if defined(DAWN_PLATFORM_WINDOWS)
+#if DAWN_PLATFORM_IS(WINDOWS)
     return mSwapChainPanel.Get();
 #else
     return nullptr;
diff --git a/src/dawn/native/Surface.h b/src/dawn/native/Surface.h
index 865d33b..96da3c2 100644
--- a/src/dawn/native/Surface.h
+++ b/src/dawn/native/Surface.h
@@ -23,9 +23,9 @@
 
 #include "dawn/common/Platform.h"
 
-#if defined(DAWN_PLATFORM_WINDOWS)
+#if DAWN_PLATFORM_IS(WINDOWS)
 #include "dawn/native/d3d12/d3d12_platform.h"
-#endif  // defined(DAWN_PLATFORM_WINDOWS)
+#endif  // DAWN_PLATFORM_IS(WINDOWS)
 
 // Forward declare IUnknown
 // GetCoreWindow needs to return an IUnknown pointer
@@ -112,13 +112,13 @@
     void* mHInstance = nullptr;
     void* mHWND = nullptr;
 
-#if defined(DAWN_PLATFORM_WINDOWS)
+#if DAWN_PLATFORM_IS(WINDOWS)
     // WindowsCoreWindow
     ComPtr<IUnknown> mCoreWindow;
 
     // WindowsSwapChainPanel
     ComPtr<IUnknown> mSwapChainPanel;
-#endif  // defined(DAWN_PLATFORM_WINDOWS)
+#endif  // DAWN_PLATFORM_IS(WINDOWS)
 
     // Xlib
     void* mXDisplay = nullptr;
diff --git a/src/dawn/native/SwapChain.cpp b/src/dawn/native/SwapChain.cpp
index daa5f32..1908929 100644
--- a/src/dawn/native/SwapChain.cpp
+++ b/src/dawn/native/SwapChain.cpp
@@ -73,11 +73,11 @@
 // TODO(crbug.com/dawn/160): Lift this restriction once wgpu::Instance::GetPreferredSurfaceFormat is
 // implemented.
 // TODO(dawn:286):
-#if defined(DAWN_PLATFORM_ANDROID)
+#if DAWN_PLATFORM_IS(ANDROID)
         constexpr wgpu::TextureFormat kRequireSwapChainFormat = wgpu::TextureFormat::RGBA8Unorm;
 #else
         constexpr wgpu::TextureFormat kRequireSwapChainFormat = wgpu::TextureFormat::BGRA8Unorm;
-#endif  // !defined(DAWN_PLATFORM_ANDROID)
+#endif  // !DAWN_PLATFORM_IS(ANDROID)
         DAWN_INVALID_IF(descriptor->format != kRequireSwapChainFormat,
                         "Format (%s) is not %s, which is (currently) the only accepted format.",
                         descriptor->format, kRequireSwapChainFormat);
diff --git a/src/dawn/native/d3d12/PlatformFunctions.cpp b/src/dawn/native/d3d12/PlatformFunctions.cpp
index ffd65c3..70b66d8 100644
--- a/src/dawn/native/d3d12/PlatformFunctions.cpp
+++ b/src/dawn/native/d3d12/PlatformFunctions.cpp
@@ -111,7 +111,7 @@
 }
 
 MaybeError PlatformFunctions::LoadD3D12() {
-#if DAWN_PLATFORM_WINUWP
+#if DAWN_PLATFORM_IS(WINUWP)
     d3d12CreateDevice = &D3D12CreateDevice;
     d3d12GetDebugInterface = &D3D12GetDebugInterface;
     d3d12SerializeRootSignature = &D3D12SerializeRootSignature;
@@ -138,7 +138,7 @@
 }
 
 MaybeError PlatformFunctions::LoadD3D11() {
-#if DAWN_PLATFORM_WINUWP
+#if DAWN_PLATFORM_IS(WINUWP)
     d3d11on12CreateDevice = &D3D11On12CreateDevice;
 #else
     std::string error;
@@ -152,7 +152,7 @@
 }
 
 MaybeError PlatformFunctions::LoadDXGI() {
-#if DAWN_PLATFORM_WINUWP
+#if DAWN_PLATFORM_IS(WINUWP)
 #if defined(_DEBUG)
     // DXGIGetDebugInterface1 is tagged as a development-only capability
     // which implies that linking to this function will cause
@@ -226,7 +226,7 @@
 }
 
 MaybeError PlatformFunctions::LoadFXCompiler() {
-#if DAWN_PLATFORM_WINUWP
+#if DAWN_PLATFORM_IS(WINUWP)
     d3dCompile = &D3DCompile;
     d3dDisassemble = &D3DDisassemble;
 #else
diff --git a/src/dawn/native/metal/BackendMTL.mm b/src/dawn/native/metal/BackendMTL.mm
index 63d21b1..4d5d854 100644
--- a/src/dawn/native/metal/BackendMTL.mm
+++ b/src/dawn/native/metal/BackendMTL.mm
@@ -25,7 +25,7 @@
 #include "dawn/native/metal/BufferMTL.h"
 #include "dawn/native/metal/DeviceMTL.h"
 
-#if defined(DAWN_PLATFORM_MACOS)
+#if DAWN_PLATFORM_IS(MACOS)
 #import <IOKit/IOKitLib.h>
 #include "dawn/common/IOKitRef.h"
 #endif
@@ -46,7 +46,7 @@
     uint32_t vendorId;
 };
 
-#if defined(DAWN_PLATFORM_MACOS)
+#if DAWN_PLATFORM_IS(MACOS)
 const Vendor kVendors[] = {{"AMD", gpu_info::kVendorID_AMD},
                            {"Radeon", gpu_info::kVendorID_AMD},
                            {"Intel", gpu_info::kVendorID_Intel},
@@ -159,7 +159,7 @@
     // TODO(dawn:1181): Dawn native should allow non-conformant WebGPU on macOS 10.11
     return IsMacOSVersionAtLeast(10, 12);
 }
-#elif defined(DAWN_PLATFORM_IOS)
+#elif DAWN_PLATFORM_IS(IOS)
 MaybeError GetDevicePCIInfo(id<MTLDevice> device, PCIIDs* ids) {
     DAWN_UNUSED(device);
     *ids = PCIIDs{0, 0};
@@ -277,10 +277,10 @@
             mDeviceId = ids.deviceId;
         }
 
-#if defined(DAWN_PLATFORM_IOS)
+#if DAWN_PLATFORM_IS(IOS)
         mAdapterType = wgpu::AdapterType::IntegratedGPU;
         const char* systemName = "iOS ";
-#elif defined(DAWN_PLATFORM_MACOS)
+#elif DAWN_PLATFORM_IS(MACOS)
         if ([device isLowPower]) {
             mAdapterType = wgpu::AdapterType::IntegratedGPU;
         } else {
@@ -310,12 +310,12 @@
 
     MaybeError InitializeSupportedFeaturesImpl() override {
         // Check compressed texture format with deprecated MTLFeatureSet way.
-#if defined(DAWN_PLATFORM_MACOS)
+#if DAWN_PLATFORM_IS(MACOS)
         if ([*mDevice supportsFeatureSet:MTLFeatureSet_macOS_GPUFamily1_v1]) {
             mSupportedFeatures.EnableFeature(Feature::TextureCompressionBC);
         }
 #endif
-#if defined(DAWN_PLATFORM_IOS)
+#if DAWN_PLATFORM_IS(IOS)
         if ([*mDevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily1_v1]) {
             mSupportedFeatures.EnableFeature(Feature::TextureCompressionETC2);
         }
@@ -350,7 +350,7 @@
                                       {MTLCommonCounterTimestamp})) {
                 bool enableTimestampQuery = true;
 
-#if defined(DAWN_PLATFORM_MACOS)
+#if DAWN_PLATFORM_IS(MACOS)
                 // Disable timestamp query on < macOS 11.0 on AMD GPU because WriteTimestamp
                 // fails to call without any copy commands on MTLBlitCommandEncoder. This issue
                 // has been fixed on macOS 11.0. See crbug.com/dawn/545.
@@ -379,7 +379,7 @@
             mSupportedFeatures.EnableFeature(Feature::MultiPlanarFormats);
         }
 
-#if defined(DAWN_PLATFORM_MACOS)
+#if DAWN_PLATFORM_IS(MACOS)
         // MTLPixelFormatDepth24Unorm_Stencil8 is only available on macOS 10.11+
         if ([*mDevice isDepth24Stencil8PixelFormatSupported]) {
             mSupportedFeatures.EnableFeature(Feature::Depth24UnormStencil8);
@@ -628,7 +628,7 @@
 
     std::vector<Ref<AdapterBase>> adapters;
     BOOL supportedVersion = NO;
-#if defined(DAWN_PLATFORM_MACOS)
+#if DAWN_PLATFORM_IS(MACOS)
     if (@available(macOS 10.11, *)) {
         supportedVersion = YES;
 
@@ -643,7 +643,7 @@
     }
 #endif
 
-#if defined(DAWN_PLATFORM_IOS)
+#if DAWN_PLATFORM_IS(IOS)
     if (@available(iOS 8.0, *)) {
         supportedVersion = YES;
         // iOS only has a single device so MTLCopyAllDevices doesn't exist there.
diff --git a/src/dawn/native/metal/BufferMTL.mm b/src/dawn/native/metal/BufferMTL.mm
index e49fc2e..92a8088 100644
--- a/src/dawn/native/metal/BufferMTL.mm
+++ b/src/dawn/native/metal/BufferMTL.mm
@@ -15,6 +15,7 @@
 #include "dawn/native/metal/BufferMTL.h"
 
 #include "dawn/common/Math.h"
+#include "dawn/common/Platform.h"
 #include "dawn/native/CommandBuffer.h"
 #include "dawn/native/metal/CommandRecordingContext.h"
 #include "dawn/native/metal/DeviceMTL.h"
@@ -41,7 +42,7 @@
 
     // Earlier versions of Metal had maximums defined in the Metal feature set tables
     // https://metalbyexample.com/wp-content/uploads/Metal-Feature-Set-Tables-2018.pdf
-#if defined(DAWN_PLATFORM_MACOS)
+#if DAWN_PLATFORM_IS(MACOS)
     // 10.12 and 10.13 have a 1Gb limit.
     if (@available(macOS 10.12, *)) {
         // |maxBufferLength| isn't always available on older systems. If available, use
@@ -72,7 +73,7 @@
     }
 
     uint32_t alignment = 1;
-#ifdef DAWN_PLATFORM_MACOS
+#if DAWN_PLATFORM_IS(MACOS)
     // [MTLBlitCommandEncoder fillBuffer] requires the size to be a multiple of 4 on MacOS.
     alignment = 4;
 #endif
diff --git a/src/dawn/native/metal/DeviceMTL.mm b/src/dawn/native/metal/DeviceMTL.mm
index 32550d5..0a7d496 100644
--- a/src/dawn/native/metal/DeviceMTL.mm
+++ b/src/dawn/native/metal/DeviceMTL.mm
@@ -158,26 +158,26 @@
 void Device::InitTogglesFromDriver() {
     {
         bool haveStoreAndMSAAResolve = false;
-#if defined(DAWN_PLATFORM_MACOS)
+#if DAWN_PLATFORM_IS(MACOS)
         if (@available(macOS 10.12, *)) {
             haveStoreAndMSAAResolve =
                 [*mMtlDevice supportsFeatureSet:MTLFeatureSet_macOS_GPUFamily1_v2];
         }
-#elif defined(DAWN_PLATFORM_IOS)
+#elif DAWN_PLATFORM_IS(IOS)
         haveStoreAndMSAAResolve = [*mMtlDevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily3_v2];
 #endif
         // On tvOS, we would need MTLFeatureSet_tvOS_GPUFamily2_v1.
         SetToggle(Toggle::EmulateStoreAndMSAAResolve, !haveStoreAndMSAAResolve);
 
         bool haveSamplerCompare = true;
-#if defined(DAWN_PLATFORM_IOS)
+#if DAWN_PLATFORM_IS(IOS)
         haveSamplerCompare = [*mMtlDevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily3_v1];
 #endif
         // TODO(crbug.com/dawn/342): Investigate emulation -- possibly expensive.
         SetToggle(Toggle::MetalDisableSamplerCompare, !haveSamplerCompare);
 
         bool haveBaseVertexBaseInstance = true;
-#if defined(DAWN_PLATFORM_IOS)
+#if DAWN_PLATFORM_IS(IOS)
         haveBaseVertexBaseInstance =
             [*mMtlDevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily3_v1];
 #endif
diff --git a/src/dawn/native/metal/SwapChainMTL.mm b/src/dawn/native/metal/SwapChainMTL.mm
index d9435dd..60fb77e 100644
--- a/src/dawn/native/metal/SwapChainMTL.mm
+++ b/src/dawn/native/metal/SwapChainMTL.mm
@@ -108,11 +108,11 @@
     [*mLayer setDevice:ToBackend(GetDevice())->GetMTLDevice()];
     [*mLayer setPixelFormat:MetalPixelFormat(GetFormat())];
 
-#if defined(DAWN_PLATFORM_MACOS)
+#if DAWN_PLATFORM_IS(MACOS)
     if (@available(macos 10.13, *)) {
         [*mLayer setDisplaySyncEnabled:(GetPresentMode() != wgpu::PresentMode::Immediate)];
     }
-#endif  // defined(DAWN_PLATFORM_MACOS)
+#endif  // DAWN_PLATFORM_IS(MACOS)
 
     // There is no way to control Fifo vs. Mailbox in Metal.
 
diff --git a/src/dawn/native/metal/TextureMTL.mm b/src/dawn/native/metal/TextureMTL.mm
index a629d9d..cf1b7a8 100644
--- a/src/dawn/native/metal/TextureMTL.mm
+++ b/src/dawn/native/metal/TextureMTL.mm
@@ -156,7 +156,7 @@
         case MTLPixelFormatBGRA8Unorm_sRGB:
             return reinterpretation == MTLPixelFormatRGBA8Unorm_sRGB ||
                    reinterpretation == MTLPixelFormatBGRA8Unorm;
-#if defined(DAWN_PLATFORM_MACOS)
+#if DAWN_PLATFORM_IS(MACOS)
         case MTLPixelFormatBC1_RGBA:
             return reinterpretation == MTLPixelFormatBC1_RGBA_sRGB;
         case MTLPixelFormatBC1_RGBA_sRGB:
@@ -216,9 +216,9 @@
     }
 }
 
-#if defined(DAWN_PLATFORM_MACOS)
+#if DAWN_PLATFORM_IS(MACOS)
 MTLStorageMode kIOSurfaceStorageMode = MTLStorageModeManaged;
-#elif defined(DAWN_PLATFORM_IOS)
+#elif DAWN_PLATFORM_IS(IOS)
 MTLStorageMode kIOSurfaceStorageMode = MTLStorageModePrivate;
 #else
 #error "Unsupported Apple platform."
@@ -321,7 +321,7 @@
         case wgpu::TextureFormat::Stencil8:
             return MTLPixelFormatStencil8;
 
-#if defined(DAWN_PLATFORM_MACOS)
+#if DAWN_PLATFORM_IS(MACOS)
         case wgpu::TextureFormat::Depth24UnormStencil8:
             return MTLPixelFormatDepth24Unorm_Stencil8;
 
@@ -1069,7 +1069,7 @@
                 if (textureFormat == MTLPixelFormatDepth32Float_Stencil8) {
                     viewFormat = MTLPixelFormatX32_Stencil8;
                 }
-#if defined(DAWN_PLATFORM_MACOS)
+#if DAWN_PLATFORM_IS(MACOS)
                 else if (textureFormat == MTLPixelFormatDepth24Unorm_Stencil8) {
                     viewFormat = MTLPixelFormatX24_Stencil8;
                 }
diff --git a/src/dawn/native/opengl/DeviceGL.h b/src/dawn/native/opengl/DeviceGL.h
index fb1f235..d915895 100644
--- a/src/dawn/native/opengl/DeviceGL.h
+++ b/src/dawn/native/opengl/DeviceGL.h
@@ -29,7 +29,7 @@
 #include "dawn/native/opengl/OpenGLFunctions.h"
 
 // Remove windows.h macros after glad's include of windows.h
-#if defined(DAWN_PLATFORM_WINDOWS)
+#if DAWN_PLATFORM_IS(WINDOWS)
 #include "dawn/common/windows_with_undefs.h"
 #endif
 
diff --git a/src/dawn/native/vulkan/BackendVk.cpp b/src/dawn/native/vulkan/BackendVk.cpp
index ebd2372..fccf600 100644
--- a/src/dawn/native/vulkan/BackendVk.cpp
+++ b/src/dawn/native/vulkan/BackendVk.cpp
@@ -30,28 +30,28 @@
 
 // TODO(crbug.com/dawn/283): Link against the Vulkan Loader and remove this.
 #if defined(DAWN_ENABLE_SWIFTSHADER)
-#if defined(DAWN_PLATFORM_LINUX) || defined(DAWN_PLATFORM_FUSCHIA)
+#if DAWN_PLATFORM_IS(LINUX) || DAWN_PLATFORM_IS(FUSCHIA)
 constexpr char kSwiftshaderLibName[] = "libvk_swiftshader.so";
-#elif defined(DAWN_PLATFORM_WINDOWS)
+#elif DAWN_PLATFORM_IS(WINDOWS)
 constexpr char kSwiftshaderLibName[] = "vk_swiftshader.dll";
-#elif defined(DAWN_PLATFORM_MACOS)
+#elif DAWN_PLATFORM_IS(MACOS)
 constexpr char kSwiftshaderLibName[] = "libvk_swiftshader.dylib";
 #else
 #error "Unimplemented Swiftshader Vulkan backend platform"
 #endif
 #endif
 
-#if defined(DAWN_PLATFORM_LINUX)
-#if defined(DAWN_PLATFORM_ANDROID)
+#if DAWN_PLATFORM_IS(LINUX)
+#if DAWN_PLATFORM_IS(ANDROID)
 constexpr char kVulkanLibName[] = "libvulkan.so";
 #else
 constexpr char kVulkanLibName[] = "libvulkan.so.1";
 #endif
-#elif defined(DAWN_PLATFORM_WINDOWS)
+#elif DAWN_PLATFORM_IS(WINDOWS)
 constexpr char kVulkanLibName[] = "vulkan-1.dll";
-#elif defined(DAWN_PLATFORM_MACOS)
+#elif DAWN_PLATFORM_IS(MACOS)
 constexpr char kVulkanLibName[] = "libvulkan.dylib";
-#elif defined(DAWN_PLATFORM_FUCHSIA)
+#elif DAWN_PLATFORM_IS(FUCHSIA)
 constexpr char kVulkanLibName[] = "libvulkan.so";
 #else
 #error "Unimplemented Vulkan backend platform"
@@ -445,12 +445,12 @@
 
     InstanceBase* instance = GetInstance();
     for (ICD icd : kICDs) {
-#if defined(DAWN_PLATFORM_MACOS)
+#if DAWN_PLATFORM_IS(MACOS)
         // On Mac, we don't expect non-Swiftshader Vulkan to be available.
         if (icd == ICD::None) {
             continue;
         }
-#endif  // defined(DAWN_PLATFORM_MACOS)
+#endif  // DAWN_PLATFORM_IS(MACOS)
         if (options->forceSwiftShader && icd != ICD::SwiftShader) {
             continue;
         }
diff --git a/src/dawn/native/vulkan/ExternalHandle.h b/src/dawn/native/vulkan/ExternalHandle.h
index 309262d..c2d1433 100644
--- a/src/dawn/native/vulkan/ExternalHandle.h
+++ b/src/dawn/native/vulkan/ExternalHandle.h
@@ -19,12 +19,12 @@
 
 namespace dawn::native::vulkan {
 
-#if DAWN_PLATFORM_LINUX
+#if DAWN_PLATFORM_IS(LINUX)
 // File descriptor
 using ExternalMemoryHandle = int;
 // File descriptor
 using ExternalSemaphoreHandle = int;
-#elif DAWN_PLATFORM_FUCHSIA
+#elif DAWN_PLATFORM_IS(FUCHSIA)
 // Really a Zircon vmo handle.
 using ExternalMemoryHandle = zx_handle_t;
 // Really a Zircon event handle.
diff --git a/src/dawn/native/vulkan/NativeSwapChainImplVk.cpp b/src/dawn/native/vulkan/NativeSwapChainImplVk.cpp
index 375db0e..6a6f4e2 100644
--- a/src/dawn/native/vulkan/NativeSwapChainImplVk.cpp
+++ b/src/dawn/native/vulkan/NativeSwapChainImplVk.cpp
@@ -184,7 +184,7 @@
     }
 
     nextTexture->texture.u64 =
-#if defined(DAWN_PLATFORM_64_BIT)
+#if DAWN_PLATFORM_IS(64_BIT)
         reinterpret_cast<uint64_t>
 #endif
         (*mSwapChainImages[mLastImageIndex]);
diff --git a/src/dawn/native/vulkan/SwapChainVk.cpp b/src/dawn/native/vulkan/SwapChainVk.cpp
index 9f35655..0a17baf 100644
--- a/src/dawn/native/vulkan/SwapChainVk.cpp
+++ b/src/dawn/native/vulkan/SwapChainVk.cpp
@@ -115,7 +115,7 @@
             break;
 #endif  // defined(DAWN_ENABLE_BACKEND_METAL)
 
-#if defined(DAWN_PLATFORM_WINDOWS)
+#if DAWN_PLATFORM_IS(WINDOWS)
         case Surface::Type::WindowsHWND:
             if (info.HasExt(InstanceExt::Win32Surface)) {
                 VkWin32SurfaceCreateInfoKHR createInfo;
@@ -132,9 +132,9 @@
                 return vkSurface;
             }
             break;
-#endif  // defined(DAWN_PLATFORM_WINDOWS)
+#endif  // DAWN_PLATFORM_IS(WINDOWS)
 
-#if defined(DAWN_PLATFORM_ANDROID)
+#if DAWN_PLATFORM_IS(ANDROID)
         case Surface::Type::AndroidWindow: {
             if (info.HasExt(InstanceExt::AndroidSurface)) {
                 ASSERT(surface->GetAndroidNativeWindow() != nullptr);
@@ -156,7 +156,7 @@
             break;
         }
 
-#endif  // defined(DAWN_PLATFORM_ANDROID)
+#endif  // DAWN_PLATFORM_IS(ANDROID)
 
 #if defined(DAWN_USE_WAYLAND)
         case Surface::Type::WaylandSurface: {
@@ -449,7 +449,7 @@
     config.transform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR;
 
     config.alphaMode = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
-#if !defined(DAWN_PLATFORM_ANDROID)
+#if !DAWN_PLATFORM_IS(ANDROID)
     DAWN_INVALID_IF(
         (surfaceInfo.capabilities.supportedCompositeAlpha & VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR) == 0,
         "Vulkan SwapChain must support opaque alpha.");
@@ -467,7 +467,7 @@
             break;
         }
     }
-#endif  // #if !defined(DAWN_PLATFORM_ANDROID)
+#endif  // #if !DAWN_PLATFORM_IS(ANDROID)
 
     // Choose the number of images for the swapchain= and clamp it to the min and max from the
     // surface capabilities. maxImageCount = 0 means there is no limit.
diff --git a/src/dawn/native/vulkan/VulkanBackend.cpp b/src/dawn/native/vulkan/VulkanBackend.cpp
index 1b18e45..0f460ab 100644
--- a/src/dawn/native/vulkan/VulkanBackend.cpp
+++ b/src/dawn/native/vulkan/VulkanBackend.cpp
@@ -60,7 +60,7 @@
 AdapterDiscoveryOptions::AdapterDiscoveryOptions()
     : AdapterDiscoveryOptionsBase(WGPUBackendType_Vulkan) {}
 
-#if defined(DAWN_PLATFORM_LINUX)
+#if DAWN_PLATFORM_IS(LINUX)
 ExternalImageDescriptorOpaqueFD::ExternalImageDescriptorOpaqueFD()
     : ExternalImageDescriptorFD(ExternalImageType::OpaqueFD) {}
 
@@ -72,10 +72,10 @@
 
 ExternalImageExportInfoDmaBuf::ExternalImageExportInfoDmaBuf()
     : ExternalImageExportInfoFD(ExternalImageType::DmaBuf) {}
-#endif  // DAWN_PLATFORM_LINUX
+#endif  // DAWN_PLATFORM_IS(LINUX)
 
 WGPUTexture WrapVulkanImage(WGPUDevice device, const ExternalImageDescriptorVk* descriptor) {
-#if defined(DAWN_PLATFORM_LINUX)
+#if DAWN_PLATFORM_IS(LINUX)
     switch (descriptor->GetType()) {
         case ExternalImageType::OpaqueFD:
         case ExternalImageType::DmaBuf: {
@@ -91,7 +91,7 @@
     }
 #else
     return nullptr;
-#endif  // DAWN_PLATFORM_LINUX
+#endif  // DAWN_PLATFORM_IS(LINUX)
 }
 
 bool ExportVulkanImage(WGPUTexture texture,
@@ -100,7 +100,7 @@
     if (texture == nullptr) {
         return false;
     }
-#if defined(DAWN_PLATFORM_LINUX)
+#if DAWN_PLATFORM_IS(LINUX)
     switch (info->GetType()) {
         case ExternalImageType::OpaqueFD:
         case ExternalImageType::DmaBuf: {
@@ -116,7 +116,7 @@
     }
 #else
     return false;
-#endif  // DAWN_PLATFORM_LINUX
+#endif  // DAWN_PLATFORM_IS(LINUX)
 }
 
 }  // namespace dawn::native::vulkan
diff --git a/src/dawn/native/vulkan/VulkanFunctions.cpp b/src/dawn/native/vulkan/VulkanFunctions.cpp
index 1b629e6..1bb1637 100644
--- a/src/dawn/native/vulkan/VulkanFunctions.cpp
+++ b/src/dawn/native/vulkan/VulkanFunctions.cpp
@@ -195,18 +195,18 @@
     }
 #endif  // defined(DAWN_USE_WAYLAND)
 
-#if defined(DAWN_PLATFORM_WINDOWS)
+#if DAWN_PLATFORM_IS(WINDOWS)
     if (globalInfo.HasExt(InstanceExt::Win32Surface)) {
         GET_INSTANCE_PROC(CreateWin32SurfaceKHR);
         GET_INSTANCE_PROC(GetPhysicalDeviceWin32PresentationSupportKHR);
     }
-#endif  // defined(DAWN_PLATFORM_WINDOWS)
+#endif  // DAWN_PLATFORM_IS(WINDOWS)
 
-#if defined(DAWN_PLATFORM_ANDROID)
+#if DAWN_PLATFORM_IS(ANDROID)
     if (globalInfo.HasExt(InstanceExt::AndroidSurface)) {
         GET_INSTANCE_PROC(CreateAndroidSurfaceKHR);
     }
-#endif  // defined(DAWN_PLATFORM_ANDROID)
+#endif  // DAWN_PLATFORM_IS(ANDROID)
 
 #if defined(DAWN_USE_X11)
     if (globalInfo.HasExt(InstanceExt::XlibSurface)) {
diff --git a/src/dawn/native/vulkan/VulkanFunctions.h b/src/dawn/native/vulkan/VulkanFunctions.h
index 0e26114..c4988e9 100644
--- a/src/dawn/native/vulkan/VulkanFunctions.h
+++ b/src/dawn/native/vulkan/VulkanFunctions.h
@@ -15,6 +15,7 @@
 #ifndef SRC_DAWN_NATIVE_VULKAN_VULKANFUNCTIONS_H_
 #define SRC_DAWN_NATIVE_VULKAN_VULKANFUNCTIONS_H_
 
+#include "dawn/common/Compiler.h"
 #include "dawn/common/vulkan_platform.h"
 
 #include "dawn/native/Error.h"
@@ -26,7 +27,7 @@
 struct VulkanGlobalInfo;
 struct VulkanDeviceInfo;
 
-#if defined(UNDEFINED_SANITIZER) && defined(DAWN_COMPILER_CLANG)
+#if defined(UNDEFINED_SANITIZER) && DAWN_COMPILER_IS(CLANG)
 #define DAWN_NO_SANITIZE_VK_FN 1
 #else
 #define DAWN_NO_SANITIZE_VK_FN 0
@@ -156,16 +157,16 @@
         GetPhysicalDeviceWaylandPresentationSupportKHR = nullptr;
 #endif  // defined(DAWN_USE_WAYLAND)
 
-#if defined(DAWN_PLATFORM_WINDOWS)
+#if DAWN_PLATFORM_IS(WINDOWS)
     // KHR_win32_surface
     VkFn<PFN_vkCreateWin32SurfaceKHR> CreateWin32SurfaceKHR = nullptr;
     VkFn<PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR>
         GetPhysicalDeviceWin32PresentationSupportKHR = nullptr;
-#endif  // defined(DAWN_PLATFORM_WINDOWS)
+#endif  // DAWN_PLATFORM_IS(WINDOWS)
 
-#if defined(DAWN_PLATFORM_ANDROID)
+#if DAWN_PLATFORM_IS(ANDROID)
     VkFn<PFN_vkCreateAndroidSurfaceKHR> CreateAndroidSurfaceKHR = nullptr;
-#endif  // defined(DAWN_PLATFORM_ANDROID)
+#endif  // DAWN_PLATFORM_IS(ANDROID)
 
 #if defined(DAWN_USE_X11)
     // KHR_xlib_surface
diff --git a/src/dawn/tests/DawnTest.cpp b/src/dawn/tests/DawnTest.cpp
index b9ca8db..c88ccf9 100644
--- a/src/dawn/tests/DawnTest.cpp
+++ b/src/dawn/tests/DawnTest.cpp
@@ -452,7 +452,7 @@
         if (!mANGLEBackend.empty()) {
             platform = mANGLEBackend.c_str();
         } else {
-#if defined(DAWN_PLATFORM_WINDOWS)
+#if DAWN_PLATFORM_IS(WINDOWS)
             platform = "d3d11";
 #else
             platform = "swiftshader";
@@ -851,7 +851,7 @@
 }
 
 bool DawnTestBase::IsWindows() const {
-#ifdef DAWN_PLATFORM_WINDOWS
+#if DAWN_PLATFORM_IS(WINDOWS)
     return true;
 #else
     return false;
@@ -859,7 +859,7 @@
 }
 
 bool DawnTestBase::IsLinux() const {
-#ifdef DAWN_PLATFORM_LINUX
+#if DAWN_PLATFORM_IS(LINUX)
     return true;
 #else
     return false;
@@ -867,7 +867,7 @@
 }
 
 bool DawnTestBase::IsMacOS(int32_t majorVersion, int32_t minorVersion) const {
-#ifdef DAWN_PLATFORM_MACOS
+#if DAWN_PLATFORM_IS(MACOS)
     if (majorVersion == -1 && minorVersion == -1) {
         return true;
     }
diff --git a/src/dawn/tests/end2end/ComputeDispatchTests.cpp b/src/dawn/tests/end2end/ComputeDispatchTests.cpp
index dc77e68..1cdf759 100644
--- a/src/dawn/tests/end2end/ComputeDispatchTests.cpp
+++ b/src/dawn/tests/end2end/ComputeDispatchTests.cpp
@@ -214,7 +214,7 @@
 
 // Test basic indirect
 TEST_P(ComputeDispatchTests, IndirectBasic) {
-#ifdef DAWN_PLATFORM_32_BIT
+#if DAWN_PLATFORM_IS(32_BIT)
     // TODO(crbug.com/dawn/1196): Fails on Chromium's Quadro P400 bots
     DAWN_SUPPRESS_TEST_IF(IsD3D12() && IsNvidia());
 #endif
@@ -246,7 +246,7 @@
 
 // Test indirect with buffer offset
 TEST_P(ComputeDispatchTests, IndirectOffset) {
-#ifdef DAWN_PLATFORM_32_BIT
+#if DAWN_PLATFORM_IS(32_BIT)
     // TODO(crbug.com/dawn/1196): Fails on Chromium's Quadro P400 bots
     DAWN_SUPPRESS_TEST_IF(IsD3D12() && IsNvidia());
 #endif
@@ -263,7 +263,7 @@
 
 // Test indirect dispatches at max limit.
 TEST_P(ComputeDispatchTests, MaxWorkgroups) {
-#ifdef DAWN_PLATFORM_32_BIT
+#if DAWN_PLATFORM_IS(32_BIT)
     // TODO(crbug.com/dawn/1196): Fails on Chromium's Quadro P400 bots
     DAWN_SUPPRESS_TEST_IF(IsD3D12() && IsNvidia());
 #endif
diff --git a/src/dawn/tests/end2end/MaxLimitTests.cpp b/src/dawn/tests/end2end/MaxLimitTests.cpp
index ceec790..fa17ab3 100644
--- a/src/dawn/tests/end2end/MaxLimitTests.cpp
+++ b/src/dawn/tests/end2end/MaxLimitTests.cpp
@@ -122,7 +122,7 @@
                 maxBufferBindingSize =
                     std::min(maxBufferBindingSize, uint64_t(2) * 1024 * 1024 * 1024);
                 // With WARP or on 32-bit platforms, such large buffer allocations often fail.
-#ifdef DAWN_PLATFORM_32_BIT
+#if DAWN_PLATFORM_IS(32_BIT)
                 if (IsWindows()) {
                     continue;
                 }
diff --git a/src/dawn/tests/end2end/WindowSurfaceTests.cpp b/src/dawn/tests/end2end/WindowSurfaceTests.cpp
index c16c7fe..b168089 100644
--- a/src/dawn/tests/end2end/WindowSurfaceTests.cpp
+++ b/src/dawn/tests/end2end/WindowSurfaceTests.cpp
@@ -24,9 +24,9 @@
 #include "gtest/gtest.h"
 
 // Include windows.h before GLFW so GLFW's APIENTRY macro doesn't conflict with windows.h's.
-#if defined(DAWN_PLATFORM_WINDOWS)
+#if DAWN_PLATFORM_IS(WINDOWS)
 #include "dawn/common/windows_with_undefs.h"
-#endif  // defined(DAWN_PLATFORM_WINDOWS)
+#endif  // DAWN_PLATFORM_IS(WINDOWS)
 
 #include "GLFW/glfw3.h"
 
@@ -139,7 +139,7 @@
     AssertSurfaceCreation(&descriptor, false);
 }
 
-#if defined(DAWN_PLATFORM_WINDOWS)
+#if DAWN_PLATFORM_IS(WINDOWS)
 
 // Tests that GLFWUtils returns a descriptor of HWND type
 TEST_F(WindowSurfaceInstanceTests, CorrectSTypeHWND) {
@@ -160,7 +160,7 @@
     AssertSurfaceCreation(&descriptor, false);
 }
 
-#else  // defined(DAWN_PLATFORM_WINDOWS)
+#else  // DAWN_PLATFORM_IS(WINDOWS)
 
 // Test using HWND when it is not supported
 TEST_F(WindowSurfaceInstanceTests, HWNDSurfacesAreInvalid) {
@@ -173,7 +173,7 @@
     AssertSurfaceCreation(&descriptor, false);
 }
 
-#endif  // defined(DAWN_PLATFORM_WINDOWS)
+#endif  // DAWN_PLATFORM_IS(WINDOWS)
 
 #if defined(DAWN_USE_X11)
 
diff --git a/src/dawn/tests/unittests/StackContainerTests.cpp b/src/dawn/tests/unittests/StackContainerTests.cpp
index 50cfb90..a5635b9 100644
--- a/src/dawn/tests/unittests/StackContainerTests.cpp
+++ b/src/dawn/tests/unittests/StackContainerTests.cpp
@@ -123,7 +123,7 @@
     aligned16->push_back(AlignedData<16>());
     EXPECT_ALIGNED(&aligned16[0], 16);
 
-#if !defined(DAWN_COMPILER_GCC) || defined(__x86_64__) || defined(__i386__)
+#if !DAWN_COMPILER_IS(GCC) || defined(__x86_64__) || defined(__i386__)
     // It seems that non-X86 gcc doesn't respect greater than 16 byte alignment.
     // See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33721 for details.
     // TODO(sbc): Re-enable this if GCC starts respecting higher alignments.
diff --git a/src/dawn/tests/white_box/EGLImageWrappingTests.cpp b/src/dawn/tests/white_box/EGLImageWrappingTests.cpp
index 595a851..ee16eb3 100644
--- a/src/dawn/tests/white_box/EGLImageWrappingTests.cpp
+++ b/src/dawn/tests/white_box/EGLImageWrappingTests.cpp
@@ -29,9 +29,9 @@
 class EGLFunctions {
   public:
     EGLFunctions() {
-#if defined(DAWN_PLATFORM_WINDOWS)
+#if DAWN_PLATFORM_IS(WINDOWS)
         const char* eglLib = "libEGL.dll";
-#elif defined(DAWN_PLATFORM_MACOS)
+#elif DAWN_PLATFORM_IS(MACOS)
         const char* eglLib = "libEGL.dylib";
 #else
         const char* eglLib = "libEGL.so";
diff --git a/src/dawn/utils/GLFWUtils.cpp b/src/dawn/utils/GLFWUtils.cpp
index b5c4a16..74e8c73 100644
--- a/src/dawn/utils/GLFWUtils.cpp
+++ b/src/dawn/utils/GLFWUtils.cpp
@@ -19,7 +19,7 @@
 #include "dawn/common/Platform.h"
 #include "dawn/utils/GLFWUtils.h"
 
-#if defined(DAWN_PLATFORM_WINDOWS)
+#if DAWN_PLATFORM_IS(WINDOWS)
 #define GLFW_EXPOSE_NATIVE_WIN32
 #endif
 #if defined(DAWN_USE_X11)
@@ -68,7 +68,7 @@
 
 std::unique_ptr<wgpu::ChainedStruct> SetupWindowAndGetSurfaceDescriptor(GLFWwindow* window) {
     switch (glfwGetPlatform()) {
-#if defined(DAWN_PLATFORM_WINDOWS)
+#if DAWN_PLATFORM_IS(WINDOWS)
         case GLFW_PLATFORM_WIN32: {
             std::unique_ptr<wgpu::SurfaceDescriptorFromWindowsHWND> desc =
                 std::make_unique<wgpu::SurfaceDescriptorFromWindowsHWND>();
diff --git a/src/dawn/utils/SystemUtils.cpp b/src/dawn/utils/SystemUtils.cpp
index a286b22..693a6ce 100644
--- a/src/dawn/utils/SystemUtils.cpp
+++ b/src/dawn/utils/SystemUtils.cpp
@@ -16,9 +16,9 @@
 
 #include "dawn/common/Platform.h"
 
-#if defined(DAWN_PLATFORM_WINDOWS)
+#if DAWN_PLATFORM_IS(WINDOWS)
 #include <Windows.h>
-#elif defined(DAWN_PLATFORM_POSIX)
+#elif DAWN_PLATFORM_IS(POSIX)
 #include <unistd.h>
 #else
 #error "Unsupported platform."
@@ -26,11 +26,11 @@
 
 namespace utils {
 
-#if defined(DAWN_PLATFORM_WINDOWS)
+#if DAWN_PLATFORM_IS(WINDOWS)
 void USleep(unsigned int usecs) {
     Sleep(static_cast<DWORD>(usecs / 1000));
 }
-#elif defined(DAWN_PLATFORM_POSIX)
+#elif DAWN_PLATFORM_IS(POSIX)
 void USleep(unsigned int usecs) {
     usleep(usecs);
 }