[clang] 230558e - [Clang][M68k] Use `DefineStd` for target-specific macros
Min-Yih Hsu via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 1 23:26:31 PDT 2023
Author: Min-Yih Hsu
Date: 2023-09-01T23:25:08-07:00
New Revision: 230558e444c2e1af8f34f99e59433a3fb87ed758
URL: https://github.com/llvm/llvm-project/commit/230558e444c2e1af8f34f99e59433a3fb87ed758
DIFF: https://github.com/llvm/llvm-project/commit/230558e444c2e1af8f34f99e59433a3fb87ed758.diff
LOG: [Clang][M68k] Use `DefineStd` for target-specific macros
Use `DefineStd` for target-specific macros such that GNU-style definitions
can be correctly toggled.
Differential Revision: https://reviews.llvm.org/D158698
Added:
Modified:
clang/lib/Basic/Targets/M68k.cpp
clang/test/Driver/m68k-macros.cpp
Removed:
################################################################################
diff --git a/clang/lib/Basic/Targets/M68k.cpp b/clang/lib/Basic/Targets/M68k.cpp
index 1b0cc4d0b13ffcc..3c6274f89dab162 100644
--- a/clang/lib/Basic/Targets/M68k.cpp
+++ b/clang/lib/Basic/Targets/M68k.cpp
@@ -80,36 +80,24 @@ void M68kTargetInfo::getTargetDefines(const LangOptions &Opts,
Builder.defineMacro("__m68k__");
- Builder.defineMacro("mc68000");
- Builder.defineMacro("__mc68000");
- Builder.defineMacro("__mc68000__");
+ DefineStd(Builder, "mc68000", Opts);
// For sub-architecture
switch (CPU) {
case CK_68010:
- Builder.defineMacro("mc68010");
- Builder.defineMacro("__mc68010");
- Builder.defineMacro("__mc68010__");
+ DefineStd(Builder, "mc68010", Opts);
break;
case CK_68020:
- Builder.defineMacro("mc68020");
- Builder.defineMacro("__mc68020");
- Builder.defineMacro("__mc68020__");
+ DefineStd(Builder, "mc68020", Opts);
break;
case CK_68030:
- Builder.defineMacro("mc68030");
- Builder.defineMacro("__mc68030");
- Builder.defineMacro("__mc68030__");
+ DefineStd(Builder, "mc68030", Opts);
break;
case CK_68040:
- Builder.defineMacro("mc68040");
- Builder.defineMacro("__mc68040");
- Builder.defineMacro("__mc68040__");
+ DefineStd(Builder, "mc68040", Opts);
break;
case CK_68060:
- Builder.defineMacro("mc68060");
- Builder.defineMacro("__mc68060");
- Builder.defineMacro("__mc68060__");
+ DefineStd(Builder, "mc68060", Opts);
break;
default:
break;
diff --git a/clang/test/Driver/m68k-macros.cpp b/clang/test/Driver/m68k-macros.cpp
index 19954f5a0c81b35..c61248ee0232a48 100644
--- a/clang/test/Driver/m68k-macros.cpp
+++ b/clang/test/Driver/m68k-macros.cpp
@@ -4,55 +4,61 @@
// CHECK-MX881: #define __HAVE_68881__ 1
// CHECK-NOMX881-NOT: #define __HAVE_68881__ 1
-// RUN: %clang -target m68k-unknown-linux -m68000 -dM -E %s | FileCheck --check-prefixes=CHECK-MX,CHECK-NOMX881 %s
+// RUN: %clang -target m68k-unknown-linux -m68000 -std=c++11 -dM -E %s | FileCheck --check-prefixes=CHECK-MX,CHECK-NOMX881 %s
+// RUN: %clang -target m68k-unknown-linux -m68000 -std=gnu++11 -dM -E %s | FileCheck --check-prefixes=CHECK-MX,CHECK-MX-GNU,CHECK-NOMX881 %s
// RUN: %clang -target m68k-unknown-linux -m68000 -mhard-float -dM -E %s | FileCheck --check-prefix=CHECK-MX881 %s
// RUN: %clang -target m68k-unknown-linux -m68000 -m68881 -dM -E %s | FileCheck --check-prefix=CHECK-MX881 %s
// CHECK-MX: #define __mc68000 1
// CHECK-MX: #define __mc68000__ 1
-// CHECK-MX: #define mc68000 1
+// CHECK-MX-GNU: #define mc68000 1
-// RUN: %clang -target m68k-unknown-linux -m68010 -dM -E %s | FileCheck --check-prefixes=CHECK-MX10,CHECK-NOMX881 %s
+// RUN: %clang -target m68k-unknown-linux -m68010 -std=c++11 -dM -E %s | FileCheck --check-prefixes=CHECK-MX10,CHECK-NOMX881 %s
+// RUN: %clang -target m68k-unknown-linux -m68010 -std=gnu++11 -dM -E %s | FileCheck --check-prefixes=CHECK-MX10,CHECK-MX10-GNU,CHECK-NOMX881 %s
// RUN: %clang -target m68k-unknown-linux -m68010 -mhard-float -dM -E %s | FileCheck --check-prefix=CHECK-MX881 %s
// RUN: %clang -target m68k-unknown-linux -m68010 -m68881 -dM -E %s | FileCheck --check-prefix=CHECK-MX881 %s
// CHECK-MX10: #define __mc68000 1
// CHECK-MX10: #define __mc68000__ 1
// CHECK-MX10: #define __mc68010 1
// CHECK-MX10: #define __mc68010__ 1
-// CHECK-MX10: #define mc68000 1
-// CHECK-MX10: #define mc68010 1
+// CHECK-MX10-GNU: #define mc68000 1
+// CHECK-MX10-GNU: #define mc68010 1
-// RUN: %clang -target m68k-unknown-linux -m68020 -dM -E %s | FileCheck --check-prefixes=CHECK-MX20,CHECK-MX881 %s
+// RUN: %clang -target m68k-unknown-linux -m68020 -std=c++11 -dM -E %s | FileCheck --check-prefixes=CHECK-MX20,CHECK-MX881 %s
+// RUN: %clang -target m68k-unknown-linux -m68020 -std=gnu++11 -dM -E %s | FileCheck --check-prefixes=CHECK-MX20,CHECK-MX20-GNU,CHECK-MX881 %s
// RUN: %clang -target m68k-unknown-linux -m68020 -msoft-float -dM -E %s | FileCheck --check-prefix=CHECK-NOMX881 %s
// CHECK-MX20: #define __mc68000 1
// CHECK-MX20: #define __mc68000__ 1
// CHECK-MX20: #define __mc68020 1
// CHECK-MX20: #define __mc68020__ 1
-// CHECK-MX20: #define mc68000 1
-// CHECK-MX20: #define mc68020 1
+// CHECK-MX20-GNU: #define mc68000 1
+// CHECK-MX20-GNU: #define mc68020 1
-// RUN: %clang -target m68k-unknown-linux -m68030 -dM -E %s | FileCheck --check-prefixes=CHECK-MX30,CHECK-MX881 %s
+// RUN: %clang -target m68k-unknown-linux -m68030 -std=c++11 -dM -E %s | FileCheck --check-prefixes=CHECK-MX30,CHECK-MX881 %s
+// RUN: %clang -target m68k-unknown-linux -m68030 -std=gnu++11 -dM -E %s | FileCheck --check-prefixes=CHECK-MX30,CHECK-MX30-GNU,CHECK-MX881 %s
// RUN: %clang -target m68k-unknown-linux -m68030 -msoft-float -dM -E %s | FileCheck --check-prefix=CHECK-NOMX881 %s
// CHECK-MX30: #define __mc68000 1
// CHECK-MX30: #define __mc68000__ 1
// CHECK-MX30: #define __mc68030 1
// CHECK-MX30: #define __mc68030__ 1
-// CHECK-MX30: #define mc68000 1
-// CHECK-MX30: #define mc68030 1
+// CHECK-MX30-GNU: #define mc68000 1
+// CHECK-MX30-GNU: #define mc68030 1
-// RUN: %clang -target m68k-unknown-linux -m68040 -dM -E %s | FileCheck --check-prefixes=CHECK-MX40,CHECK-MX881 %s
+// RUN: %clang -target m68k-unknown-linux -m68040 -std=c++11 -dM -E %s | FileCheck --check-prefixes=CHECK-MX40,CHECK-MX881 %s
+// RUN: %clang -target m68k-unknown-linux -m68040 -std=gnu++11 -dM -E %s | FileCheck --check-prefixes=CHECK-MX40,CHECK-MX40-GNU,CHECK-MX881 %s
// RUN: %clang -target m68k-unknown-linux -m68040 -msoft-float -dM -E %s | FileCheck --check-prefix=CHECK-NOMX881 %s
// CHECK-MX40: #define __mc68000 1
// CHECK-MX40: #define __mc68000__ 1
// CHECK-MX40: #define __mc68040 1
// CHECK-MX40: #define __mc68040__ 1
-// CHECK-MX40: #define mc68000 1
-// CHECK-MX40: #define mc68040 1
+// CHECK-MX40-GNU: #define mc68000 1
+// CHECK-MX40-GNU: #define mc68040 1
-// RUN: %clang -target m68k-unknown-linux -m68060 -dM -E %s | FileCheck --check-prefixes=CHECK-MX60,CHECK-MX881 %s
+// RUN: %clang -target m68k-unknown-linux -m68060 -std=c++11 -dM -E %s | FileCheck --check-prefixes=CHECK-MX60,CHECK-MX881 %s
+// RUN: %clang -target m68k-unknown-linux -m68060 -std=gnu++11 -dM -E %s | FileCheck --check-prefixes=CHECK-MX60,CHECK-MX60-GNU,CHECK-MX881 %s
// RUN: %clang -target m68k-unknown-linux -m68060 -msoft-float -dM -E %s | FileCheck --check-prefix=CHECK-NOMX881 %s
// CHECK-MX60: #define __mc68000 1
// CHECK-MX60: #define __mc68000__ 1
// CHECK-MX60: #define __mc68060 1
// CHECK-MX60: #define __mc68060__ 1
-// CHECK-MX60: #define mc68000 1
-// CHECK-MX60: #define mc68060 1
+// CHECK-MX60-GNU: #define mc68000 1
+// CHECK-MX60-GNU: #define mc68060 1
More information about the cfe-commits
mailing list