MaskRay created this revision.
MaskRay added reviewers: q66, thesamesam.
Herald added subscribers: StephenFan, shchenz, kbarton, nemanjai.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

GCC only defines `__ppc64__` for darwin while the darwin support has been
removed from llvm-project. The existence of `__ppc64__` lures users to make typo
mistakes: if they write code to check `__ppc64__`, the code will not work with
GCC.

It is straightforward if a distro wants to keep the macro: add
`-D__PPC64__=1` to a Clang configuration file.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137511

Files:
  clang/lib/Basic/Targets/PPC.cpp
  clang/test/Preprocessor/init-ppc64.c


Index: clang/test/Preprocessor/init-ppc64.c
===================================================================
--- clang/test/Preprocessor/init-ppc64.c
+++ clang/test/Preprocessor/init-ppc64.c
@@ -198,7 +198,6 @@
 // PPC64:#define __WCHAR_WIDTH__ 32
 // PPC64:#define __WINT_TYPE__ int
 // PPC64:#define __WINT_WIDTH__ 32
-// PPC64:#define __ppc64__ 1
 // PPC64:#define __ppc__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64le-none-none 
-target-cpu pwr7 -fno-signed-char < /dev/null | FileCheck -match-full-lines 
-check-prefix PPC64LE %s
@@ -403,7 +402,6 @@
 // PPC64LE:#define __WCHAR_WIDTH__ 32
 // PPC64LE:#define __WINT_TYPE__ int
 // PPC64LE:#define __WINT_WIDTH__ 32
-// PPC64LE:#define __ppc64__ 1
 // PPC64LE:#define __ppc__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none 
-target-cpu 630 -fno-signed-char < /dev/null | FileCheck -match-full-lines 
-check-prefix PPC630 %s
@@ -865,7 +863,6 @@
 // PPC64-AIX:#define __WINT_WIDTH__ 32
 // PPC64-AIX:#define __powerpc64__ 1
 // PPC64-AIX:#define __powerpc__ 1
-// PPC64-AIX:#define __ppc64__ 1
 // PPC64-AIX:#define __ppc__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-unknown-linux-gnu 
-fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix 
PPC64-LINUX %s
@@ -1064,7 +1061,6 @@
 // PPC64-LINUX:#define __WINT_WIDTH__ 32
 // PPC64-LINUX:#define __powerpc64__ 1
 // PPC64-LINUX:#define __powerpc__ 1
-// PPC64-LINUX:#define __ppc64__ 1
 // PPC64-LINUX:#define __ppc__ 1
 
 // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=powerpc64-unknown-linux-gnu < /dev/null | FileCheck -match-full-lines 
-check-prefix PPC64-ELFv1 %s
Index: clang/lib/Basic/Targets/PPC.cpp
===================================================================
--- clang/lib/Basic/Targets/PPC.cpp
+++ clang/lib/Basic/Targets/PPC.cpp
@@ -281,7 +281,6 @@
   if (PointerWidth == 64) {
     Builder.defineMacro("_ARCH_PPC64");
     Builder.defineMacro("__powerpc64__");
-    Builder.defineMacro("__ppc64__");
     Builder.defineMacro("__PPC64__");
   } else if (getTriple().isOSAIX()) {
     // The XL compilers on AIX define _ARCH_PPC64 for both 32 and 64-bit modes.


Index: clang/test/Preprocessor/init-ppc64.c
===================================================================
--- clang/test/Preprocessor/init-ppc64.c
+++ clang/test/Preprocessor/init-ppc64.c
@@ -198,7 +198,6 @@
 // PPC64:#define __WCHAR_WIDTH__ 32
 // PPC64:#define __WINT_TYPE__ int
 // PPC64:#define __WINT_WIDTH__ 32
-// PPC64:#define __ppc64__ 1
 // PPC64:#define __ppc__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64le-none-none -target-cpu pwr7 -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPC64LE %s
@@ -403,7 +402,6 @@
 // PPC64LE:#define __WCHAR_WIDTH__ 32
 // PPC64LE:#define __WINT_TYPE__ int
 // PPC64LE:#define __WINT_WIDTH__ 32
-// PPC64LE:#define __ppc64__ 1
 // PPC64LE:#define __ppc__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu 630 -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPC630 %s
@@ -865,7 +863,6 @@
 // PPC64-AIX:#define __WINT_WIDTH__ 32
 // PPC64-AIX:#define __powerpc64__ 1
 // PPC64-AIX:#define __powerpc__ 1
-// PPC64-AIX:#define __ppc64__ 1
 // PPC64-AIX:#define __ppc__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-unknown-linux-gnu -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPC64-LINUX %s
@@ -1064,7 +1061,6 @@
 // PPC64-LINUX:#define __WINT_WIDTH__ 32
 // PPC64-LINUX:#define __powerpc64__ 1
 // PPC64-LINUX:#define __powerpc__ 1
-// PPC64-LINUX:#define __ppc64__ 1
 // PPC64-LINUX:#define __ppc__ 1
 
 // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=powerpc64-unknown-linux-gnu < /dev/null | FileCheck -match-full-lines -check-prefix PPC64-ELFv1 %s
Index: clang/lib/Basic/Targets/PPC.cpp
===================================================================
--- clang/lib/Basic/Targets/PPC.cpp
+++ clang/lib/Basic/Targets/PPC.cpp
@@ -281,7 +281,6 @@
   if (PointerWidth == 64) {
     Builder.defineMacro("_ARCH_PPC64");
     Builder.defineMacro("__powerpc64__");
-    Builder.defineMacro("__ppc64__");
     Builder.defineMacro("__PPC64__");
   } else if (getTriple().isOSAIX()) {
     // The XL compilers on AIX define _ARCH_PPC64 for both 32 and 64-bit modes.
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to