[clang] [clang][X86] Fix -Wundef warning in cpuid.h (PR #89842)

via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 23 15:42:35 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Dan Klishch (DanShaders)

<details>
<summary>Changes</summary>

Caught by compiling a project (SerenityOS) that uses compiler-rt and not silencing warnings from system headers.

---
Full diff: https://github.com/llvm/llvm-project/pull/89842.diff


1 Files Affected:

- (modified) clang/lib/Headers/cpuid.h (+3-3) 


``````````diff
diff --git a/clang/lib/Headers/cpuid.h b/clang/lib/Headers/cpuid.h
index 0bb9912b465ffe..bb7692efb78ffe 100644
--- a/clang/lib/Headers/cpuid.h
+++ b/clang/lib/Headers/cpuid.h
@@ -10,7 +10,7 @@
 #ifndef __CPUID_H
 #define __CPUID_H
 
-#if !(__x86_64__ || __i386__)
+#if !defined(__x86_64__) && !defined(__i386__)
 #error this header is for x86 only
 #endif
 
@@ -256,7 +256,7 @@
 #define bit_AVX10_256   0x00020000
 #define bit_AVX10_512   0x00040000
 
-#if __i386__
+#ifdef __i386__
 #define __cpuid(__leaf, __eax, __ebx, __ecx, __edx) \
     __asm("cpuid" : "=a"(__eax), "=b" (__ebx), "=c"(__ecx), "=d"(__edx) \
                   : "0"(__leaf))
@@ -285,7 +285,7 @@ static __inline unsigned int __get_cpuid_max (unsigned int __leaf,
                                               unsigned int *__sig)
 {
     unsigned int __eax, __ebx, __ecx, __edx;
-#if __i386__
+#ifdef __i386__
     int __cpuid_supported;
 
     __asm("  pushfl\n"

``````````

</details>


https://github.com/llvm/llvm-project/pull/89842


More information about the cfe-commits mailing list