]> granicus.if.org Git - clang/commitdiff
More clang support for darwin tls. Add a __has_feature macro and
authorEric Christopher <echristo@apple.com>
Thu, 24 Jun 2010 02:02:00 +0000 (02:02 +0000)
committerEric Christopher <echristo@apple.com>
Thu, 24 Jun 2010 02:02:00 +0000 (02:02 +0000)
target specific preprocessor define as well.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106715 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Basic/Targets.cpp
lib/Frontend/InitPreprocessor.cpp
lib/Lex/PPMacroExpansion.cpp

index 3717b12b15d620cba0d15c45a1d618727c168b81..12758f8a92fd2cb2eb60eaa22f6d7c45c8e12228 100644 (file)
@@ -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 {
index c9c76e5f1f3b08d24fc21f6805fce8c0b0dda4fc..ab0e7067a8e4d320e2ec1b63fbc011d66e13a395 100644 (file)
@@ -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);
 }
index 71bb4fcf684a2e8fab5029dcd93d739f0ae88b8d..ebf606e9406f7ed08aa900b14263866e37afe6bd 100644 (file)
@@ -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);
 }