Skip to content

Commit 271f964

Browse files
frobtechMaskRay
authored andcommitted
[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
1 parent d2e949e commit 271f964

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

clang/lib/Basic/Targets/X86.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ void X86TargetInfo::getTargetDefines(const LangOptions &Opts,
911911
std::string CodeModel = getTargetOpts().CodeModel;
912912
if (CodeModel == "default")
913913
CodeModel = "small";
914-
Builder.defineMacro("__code_model_" + CodeModel + "_");
914+
Builder.defineMacro("__code_model_" + CodeModel + "__");
915915

916916
// Target identification.
917917
if (getTriple().getArch() == llvm::Triple::x86_64) {

clang/test/Preprocessor/init.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6198,7 +6198,7 @@
61986198
// X86_64:#define __WINT_WIDTH__ 32
61996199
// X86_64:#define __amd64 1
62006200
// X86_64:#define __amd64__ 1
6201-
// X86_64:#define __code_model_small_ 1
6201+
// X86_64:#define __code_model_small__ 1
62026202
// X86_64:#define __x86_64 1
62036203
// X86_64:#define __x86_64__ 1
62046204
//
@@ -6210,7 +6210,7 @@
62106210
// X86_64H:#define __x86_64h__ 1
62116211
//
62126212
// RUN: %clang -xc - -E -dM -mcmodel=medium --target=i386-unknown-linux < /dev/null | FileCheck -match-full-lines -check-prefix X86_MEDIUM %s
6213-
// X86_MEDIUM:#define __code_model_medium_ 1
6213+
// X86_MEDIUM:#define __code_model_medium__ 1
62146214
//
62156215
// 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
62166216
// 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

0 commit comments

Comments
 (0)