[cfe-commits] r60561 - in /cfe/trunk: Driver/clang.cpp include/clang/Basic/TargetInfo.h lib/Basic/Targets.cpp
Chris Lattner
sabre at nondot.org
Thu Dec 4 14:54:33 PST 2008
Author: lattner
Date: Thu Dec 4 16:54:33 2008
New Revision: 60561
URL: http://llvm.org/viewvc/llvm-project?rev=60561&view=rev
Log:
replace useNeXTRuntimeAsDefault with a generic hook that allows targets
to specify their default language options.
Modified:
cfe/trunk/Driver/clang.cpp
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/Basic/Targets.cpp
Modified: cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=60561&r1=60560&r2=60561&view=diff
==============================================================================
--- cfe/trunk/Driver/clang.cpp (original)
+++ cfe/trunk/Driver/clang.cpp Thu Dec 4 16:54:33 2008
@@ -497,6 +497,8 @@
// -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 @@
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 @@
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);
Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=60561&r1=60560&r2=60561&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Thu Dec 4 16:54:33 2008
@@ -24,6 +24,7 @@
class Diagnostic;
class SourceManager;
+class LangOptions;
namespace Builtin { struct Info; }
@@ -228,7 +229,10 @@
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 {
Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=60561&r1=60560&r2=60561&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Dec 4 16:54:33 2008
@@ -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 @@
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 @@
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 @@
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 @@
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.
More information about the cfe-commits
mailing list