]> granicus.if.org Git - clang/commitdiff
replace useNeXTRuntimeAsDefault with a generic hook that allows targets
authorChris Lattner <sabre@nondot.org>
Thu, 4 Dec 2008 22:54:33 +0000 (22:54 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 4 Dec 2008 22:54:33 +0000 (22:54 +0000)
to specify their default language options.

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

Driver/clang.cpp
include/clang/Basic/TargetInfo.h
lib/Basic/Targets.cpp

index 2870c3dec008e9d781f43622199ab98246d2c9a4..bb838ed846f58ba422fbd5c98356933fc6c5a37a 100644 (file)
@@ -497,6 +497,8 @@ Ansi("ansi", llvm::cl::desc("Equivalent to specifying -std=c89."));
 //   -fpascal-strings
 static void InitializeLanguageStandard(LangOptions &Options, LangKind LK,
                                        TargetInfo *Target) {
+  // Allow the target to set the default the langauge options as it sees fit.
+  Target->getDefaultLangOptions(Options);
   
   if (Ansi) // "The -ansi option is equivalent to -std=c89."
     LangStd = lang_c89;
@@ -574,13 +576,11 @@ static void InitializeLanguageStandard(LangOptions &Options, LangKind LK,
   Options.LaxVectorConversions = LaxVectorConversions;
   Options.Exceptions = Exceptions;
 
-  if (NeXTRuntime) {
+  // Override the default runtime if the user requested it.
+  if (NeXTRuntime)
     Options.NeXTRuntime = 1;
-  } else if (GNURuntime) {
+  else if (GNURuntime)
     Options.NeXTRuntime = 0;
-  } else {
-    Options.NeXTRuntime = Target->useNeXTRuntimeAsDefault();
-  }
 }
 
 static llvm::cl::opt<bool>
@@ -1524,8 +1524,8 @@ int main(int argc, char **argv) {
       InitializeBaseLanguage();
       LangKind LK = GetLanguage(InFile);
       bool PCH = InitializeLangOptions(LangInfo, LK);
-      InitializeLanguageStandard(LangInfo, LK, Target.get());
       InitializeGCMode(LangInfo);
+      InitializeLanguageStandard(LangInfo, LK, Target.get());
             
       // Process the -I options and set them in the HeaderInfo.
       HeaderSearch HeaderInfo(FileMgr);
index 32c87434d97cb1de409ab51a8affda8cdd873efb..a9a71367bce11dee4bc0eb64edfc321a92771827 100644 (file)
@@ -24,6 +24,7 @@ namespace clang {
 
 class Diagnostic;
 class SourceManager;
+class LangOptions;
   
 namespace Builtin { struct Info; }
   
@@ -228,7 +229,10 @@ public:
 
   virtual bool useGlobalsForAutomaticVariables() const { return false; }
 
-  virtual bool useNeXTRuntimeAsDefault() const { return false; }
+  /// getDefaultLangOptions - Allow the target to specify default settings for
+  /// various language options.  These may be overridden by command line
+  /// options. 
+  virtual void getDefaultLangOptions(LangOptions &Opts) {}
 
 protected:
   virtual uint64_t getPointerWidthV(unsigned AddrSpace) const {
index 71321f19cc8dc376619fdf1d293e5a836b8bc69c..6f563a55c3bd0dd9d27c8713794671fd683fea80 100644 (file)
@@ -15,6 +15,7 @@
 #include "clang/AST/Builtins.h"
 #include "clang/AST/TargetBuiltins.h"
 #include "clang/Basic/TargetInfo.h"
+#include "clang/Basic/LangOptions.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/APFloat.h"
 using namespace clang;
@@ -366,7 +367,12 @@ public:
     getDarwinDefines(Defines, getTargetTriple());
   }
 
-  virtual bool useNeXTRuntimeAsDefault() const { return true; }
+  /// getDefaultLangOptions - Allow the target to specify default settings for
+  /// various language options.  These may be overridden by command line
+  /// options. 
+  virtual void getDefaultLangOptions(LangOptions &Opts) {
+    Opts.NeXTRuntime = true;
+  }
 };
 } // end anonymous namespace.
 
@@ -379,7 +385,12 @@ public:
     getDarwinDefines(Defines, getTargetTriple());
   }
 
-  virtual bool useNeXTRuntimeAsDefault() const { return true; }
+  /// getDefaultLangOptions - Allow the target to specify default settings for
+  /// various language options.  These may be overridden by command line
+  /// options. 
+  virtual void getDefaultLangOptions(LangOptions &Opts) {
+    Opts.NeXTRuntime = true;
+  }
 };
 } // end anonymous namespace.
 
@@ -526,7 +537,12 @@ public:
     X86_32TargetInfo::getTargetDefines(Defines);
     getDarwinDefines(Defines, getTargetTriple());
   }
-  virtual bool useNeXTRuntimeAsDefault() const { return true; }
+  /// getDefaultLangOptions - Allow the target to specify default settings for
+  /// various language options.  These may be overridden by command line
+  /// options. 
+  virtual void getDefaultLangOptions(LangOptions &Opts) {
+    Opts.NeXTRuntime = true;
+  }
 };
 } // end anonymous namespace
 
@@ -670,7 +686,12 @@ public:
     getDarwinDefines(Defines, getTargetTriple());
   }
 
-  virtual bool useNeXTRuntimeAsDefault() const { return true; }
+  /// getDefaultLangOptions - Allow the target to specify default settings for
+  /// various language options.  These may be overridden by command line
+  /// options. 
+  virtual void getDefaultLangOptions(LangOptions &Opts) {
+    Opts.NeXTRuntime = true;
+  }
 };
 } // end anonymous namespace.