r309598 - [Targets] Move addCygMingDefines into the arch-independent Targets.cpp (NFC)
Martin Storsjo via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 31 11:17:38 PDT 2017
Author: mstorsjo
Date: Mon Jul 31 11:17:38 2017
New Revision: 309598
URL: http://llvm.org/viewvc/llvm-project?rev=309598&view=rev
Log:
[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
Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Basic/Targets.h
cfe/trunk/lib/Basic/Targets/X86.h
Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=309598&r1=309597&r2=309598&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Mon Jul 31 11:17:38 2017
@@ -73,6 +73,30 @@ void defineCPUMacros(MacroBuilder &Build
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__");
Modified: cfe/trunk/lib/Basic/Targets.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.h?rev=309598&r1=309597&r2=309598&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.h (original)
+++ cfe/trunk/lib/Basic/Targets.h Mon Jul 31 11:17:38 2017
@@ -42,6 +42,10 @@ void defineCPUMacros(clang::MacroBuilder
LLVM_LIBRARY_VISIBILITY
void addMinGWDefines(const clang::LangOptions &Opts,
clang::MacroBuilder &Builder);
+
+LLVM_LIBRARY_VISIBILITY
+void addCygMingDefines(const clang::LangOptions &Opts,
+ clang::MacroBuilder &Builder);
} // namespace targets
} // namespace clang
#endif // LLVM_CLANG_LIB_BASIC_TARGETS_H
Modified: cfe/trunk/lib/Basic/Targets/X86.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.h?rev=309598&r1=309597&r2=309598&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets/X86.h (original)
+++ cfe/trunk/lib/Basic/Targets/X86.h Mon Jul 31 11:17:38 2017
@@ -691,30 +691,6 @@ public:
}
};
-static 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);
- }
- }
-}
-
// x86-32 MinGW target
class LLVM_LIBRARY_VISIBILITY MinGWX86_32TargetInfo
: public WindowsX86_32TargetInfo {
More information about the cfe-commits
mailing list