[clang] 271f964 - [Preprocessor][X86] Fix __code_model_*__ predefine macros

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 21 23:30:39 PST 2020


Author: Roland McGrath
Date: 2020-02-21T23:30:07-08:00
New Revision: 271f96477328f42cbf31a2b42433cdef8ed91914

URL: https://github.com/llvm/llvm-project/commit/271f96477328f42cbf31a2b42433cdef8ed91914
DIFF: https://github.com/llvm/llvm-project/commit/271f96477328f42cbf31a2b42433cdef8ed91914.diff

LOG: [Preprocessor][X86] Fix __code_model_*__ predefine macros

GCC defines __code_model_*__ (two trailing underscores), not
__code_model_*_ (one trailing underscore).

Reviewed By: MaskRay

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

Added: 
    

Modified: 
    clang/lib/Basic/Targets/X86.cpp
    clang/test/Preprocessor/init.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index d099d3742f0b..7b575f52bb22 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -911,7 +911,7 @@ void X86TargetInfo::getTargetDefines(const LangOptions &Opts,
   std::string CodeModel = getTargetOpts().CodeModel;
   if (CodeModel == "default")
     CodeModel = "small";
-  Builder.defineMacro("__code_model_" + CodeModel + "_");
+  Builder.defineMacro("__code_model_" + CodeModel + "__");
 
   // Target identification.
   if (getTriple().getArch() == llvm::Triple::x86_64) {

diff  --git a/clang/test/Preprocessor/init.c b/clang/test/Preprocessor/init.c
index 0e29ac3ff698..f38f87ddef8e 100644
--- a/clang/test/Preprocessor/init.c
+++ b/clang/test/Preprocessor/init.c
@@ -6198,7 +6198,7 @@
 // X86_64:#define __WINT_WIDTH__ 32
 // X86_64:#define __amd64 1
 // X86_64:#define __amd64__ 1
-// X86_64:#define __code_model_small_ 1
+// X86_64:#define __code_model_small__ 1
 // X86_64:#define __x86_64 1
 // X86_64:#define __x86_64__ 1
 //
@@ -6210,7 +6210,7 @@
 // X86_64H:#define __x86_64h__ 1
 //
 // RUN: %clang -xc - -E -dM -mcmodel=medium --target=i386-unknown-linux < /dev/null | FileCheck -match-full-lines -check-prefix X86_MEDIUM %s
-// X86_MEDIUM:#define __code_model_medium_ 1
+// X86_MEDIUM:#define __code_model_medium__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=x86_64-none-none-gnux32 < /dev/null | FileCheck -match-full-lines -check-prefix X32 %s
 // RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=x86_64-none-none-gnux32 < /dev/null | FileCheck -match-full-lines -check-prefix X32 -check-prefix X32-CXX %s


        


More information about the cfe-commits mailing list