// C++ translation unit.
Builder.defineMacro("__cplusplus", "199711L");
Builder.defineMacro("__private_extern__", "extern");
- // Ugly hack to work with GNU libstdc++.
- Builder.defineMacro("_GNU_SOURCE");
+
+ // Define _GNU_SOURCE on platforms where we expect to use glibc.
+ switch (TI.getTriple().getOS()) {
+ case llvm::Triple::Cygwin:
+ case llvm::Triple::MinGW64:
+ case llvm::Triple::MinGW32:
+ case llvm::Triple::Linux:
+ case llvm::Triple::Solaris:
+ case llvm::Triple::AuroraUX:
+ Builder.defineMacro("_GNU_SOURCE");
+ break;
+
+ case llvm::Triple::Darwin:
+ case llvm::Triple::DragonFly:
+ case llvm::Triple::FreeBSD:
+ case llvm::Triple::UnknownOS:
+ case llvm::Triple::Lv2:
+ case llvm::Triple::NetBSD:
+ case llvm::Triple::OpenBSD:
+ case llvm::Triple::Psp:
+ case llvm::Triple::Win32:
+ case llvm::Triple::Haiku:
+ break;
+ }
}
if (LangOpts.Microsoft) {
//
// RUN: %clang_cc1 -x c++ -std=c++0x -E -dM < /dev/null | FileCheck -check-prefix CXX0X %s
//
-// CXX0X:#define _GNU_SOURCE 1
// CXX0X:#define __DEPRECATED 1
// CXX0X:#define __GNUG__
// CXX0X:#define __GXX_EXPERIMENTAL_CXX0X__ 1
//
// RUN: %clang_cc1 -x c++ -std=c++98 -E -dM < /dev/null | FileCheck -check-prefix CXX98 %s
//
-// CXX98:#define _GNU_SOURCE 1
// CXX98:#define __DEPRECATED 1
// CXX98:#define __GNUG__
// CXX98:#define __GXX_WEAK__ 1
//
// RUN: %clang_cc1 -x c++ -std=gnu++98 -E -dM < /dev/null | FileCheck -check-prefix GXX98 %s
//
-// GXX98:#define _GNU_SOURCE 1
// GXX98:#define __DEPRECATED 1
// GXX98:#define __GNUG__
// GXX98:#define __GXX_WEAK__ 1
// X86_64:#define __x86_64 1
// X86_64:#define __x86_64__ 1
//
+// RUN: %clang_cc1 -x c++ -triple i686-pc-linux-gnu -E -dM < /dev/null | FileCheck -check-prefix GNUSOURCE %s
+// GNUSOURCE:#define _GNU_SOURCE 1
+//