diff options
author | Eric Christopher <echristo@apple.com> | 2010-06-24 02:02:00 +0000 |
---|---|---|
committer | Eric Christopher <echristo@apple.com> | 2010-06-24 02:02:00 +0000 |
commit | 1f84f8d970a673e487b40d341cd3e8d52ca9cc22 (patch) | |
tree | 89b3f3bba1a2fe8c5f6288dd48dbc43bc5ea0b38 | |
parent | 564360be450b319aeafc26698be9811837bfb826 (diff) |
More clang support for darwin tls. Add a __has_feature macro and
target specific preprocessor define as well.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106715 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Basic/Targets.cpp | 2 | ||||
-rw-r--r-- | lib/Frontend/InitPreprocessor.cpp | 4 | ||||
-rw-r--r-- | lib/Lex/PPMacroExpansion.cpp | 2 |
3 files changed, 7 insertions, 1 deletions
diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index 3717b12b15..12758f8a92 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -150,7 +150,7 @@ protected: public: DarwinTargetInfo(const std::string& triple) : OSTargetInfo<Target>(triple) { - this->TLSSupported = false; + this->TLSSupported = llvm::Triple(triple).getDarwinMajorNumber() > 6; } virtual std::string isValidSectionSpecifier(llvm::StringRef SR) const { diff --git a/lib/Frontend/InitPreprocessor.cpp b/lib/Frontend/InitPreprocessor.cpp index c9c76e5f1f..ab0e7067a8 100644 --- a/lib/Frontend/InitPreprocessor.cpp +++ b/lib/Frontend/InitPreprocessor.cpp @@ -460,6 +460,10 @@ static void InitializePredefinedMacros(const TargetInfo &TI, if (FEOpts.ProgramAction == frontend::RunAnalysis) Builder.defineMacro("__clang_analyzer__"); + // Define __HAS_TLS__ if the target supports it. + if (TI.isTLSSupported()) + Builder.defineMacro("__HAS_TLS__"); + // Get other target #defines. TI.getTargetDefines(LangOpts, Builder); } diff --git a/lib/Lex/PPMacroExpansion.cpp b/lib/Lex/PPMacroExpansion.cpp index 71bb4fcf68..ebf606e940 100644 --- a/lib/Lex/PPMacroExpansion.cpp +++ b/lib/Lex/PPMacroExpansion.cpp @@ -17,6 +17,7 @@ #include "clang/Lex/MacroInfo.h" #include "clang/Basic/SourceManager.h" #include "clang/Basic/FileManager.h" +#include "clang/Basic/TargetInfo.h" #include "clang/Lex/LexDiagnostic.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/Support/raw_ostream.h" @@ -510,6 +511,7 @@ static bool HasFeature(const Preprocessor &PP, const IdentifierInfo *II) { //.Case("cxx_nullptr", false) //.Case("cxx_rvalue_references", false) //.Case("cxx_variadic_templates", false) + .Case("tls", PP.getTargetInfo().isTLSSupported()) .Default(false); } |