diff options
author | Martin Storsjo <martin@martin.st> | 2017-07-31 18:17:38 +0000 |
---|---|---|
committer | Martin Storsjo <martin@martin.st> | 2017-07-31 18:17:38 +0000 |
commit | e2a247ccb0e08de8fcd5999e453bac5feb66b2a7 (patch) | |
tree | 4221ef25e44e06539356072f806e8cfa9102577d /clang/lib/Basic/Targets.cpp | |
parent | fea731a4aa6aabf270fbb9ba6401ca8826c55a9b (diff) | |
download | bcm5719-llvm-e2a247ccb0e08de8fcd5999e453bac5feb66b2a7.tar.gz bcm5719-llvm-e2a247ccb0e08de8fcd5999e453bac5feb66b2a7.zip |
[Targets] Move addCygMingDefines into the arch-independent Targets.cpp (NFC)
This fixes a dependency inconsistency, where addMinGWDefines in Targets.cpp
(used from other architectures than X86) called the addCygMingDefines function
in X86.h.
This was inconsistently split in SVN r308791 (D35701).
Differential Revision: https://reviews.llvm.org/D36072
llvm-svn: 309598
Diffstat (limited to 'clang/lib/Basic/Targets.cpp')
-rw-r--r-- | clang/lib/Basic/Targets.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp index e67ffdbf119..9946f82405e 100644 --- a/clang/lib/Basic/Targets.cpp +++ b/clang/lib/Basic/Targets.cpp @@ -73,6 +73,30 @@ void defineCPUMacros(MacroBuilder &Builder, StringRef CPUName, bool Tuning) { Builder.defineMacro("__tune_" + CPUName + "__"); } +void addCygMingDefines(const LangOptions &Opts, MacroBuilder &Builder) { + // Mingw and cygwin define __declspec(a) to __attribute__((a)). Clang + // supports __declspec natively under -fms-extensions, but we define a no-op + // __declspec macro anyway for pre-processor compatibility. + if (Opts.MicrosoftExt) + Builder.defineMacro("__declspec", "__declspec"); + else + Builder.defineMacro("__declspec(a)", "__attribute__((a))"); + + if (!Opts.MicrosoftExt) { + // Provide macros for all the calling convention keywords. Provide both + // single and double underscore prefixed variants. These are available on + // x64 as well as x86, even though they have no effect. + const char *CCs[] = {"cdecl", "stdcall", "fastcall", "thiscall", "pascal"}; + for (const char *CC : CCs) { + std::string GCCSpelling = "__attribute__((__"; + GCCSpelling += CC; + GCCSpelling += "__))"; + Builder.defineMacro(Twine("_") + CC, GCCSpelling); + Builder.defineMacro(Twine("__") + CC, GCCSpelling); + } + } +} + void addMinGWDefines(const LangOptions &Opts, MacroBuilder &Builder) { Builder.defineMacro("__MSVCRT__"); Builder.defineMacro("__MINGW32__"); |