unsigned OpenCL : 1; // OpenCL C99 language extensions.
- unsigned StackProtector : 2; // Whether stack protectors are on:
- // 0 - None
- // 1 - On
- // 2 - All
-
private:
- unsigned GC : 2; // Objective-C Garbage Collection modes. We declare
- // this enum as unsigned because MSVC insists on making enums
- // signed. Set/Query this value using accessors.
+ unsigned GC : 2; // Objective-C Garbage Collection modes. We
+ // declare this enum as unsigned because MSVC
+ // insists on making enums signed. Set/Query
+ // this value using accessors.
unsigned SymbolVisibility : 3; // Symbol's visibility.
+ unsigned StackProtector : 2; // Whether stack protectors are on. We declare
+ // this enum as unsigned because MSVC insists
+ // on making enums signed. Set/Query this
+ // value using accessors.
/// The user provided name for the "main file", if non-null. This is
/// useful in situations where the input file name does not match
unsigned InstantiationDepth; // Maximum template instantiation depth.
enum GCMode { NonGC, GCOnly, HybridGC };
+ enum StackProtectorMode { SSPOff, SSPOn, SSPReq };
enum VisibilityMode {
Default,
Protected,
GCMode getGCMode() const { return (GCMode) GC; }
void setGCMode(GCMode m) { GC = (unsigned) m; }
+ StackProtectorMode getStackProtectorMode() const {
+ return static_cast<StackProtectorMode>(StackProtector);
+ }
+ void setStackProtectorMode(StackProtectorMode m) {
+ StackProtector = static_cast<unsigned>(m);
+ }
+
const char *getMainFileName() const { return MainFileName; }
void setMainFileName(const char *Name) { MainFileName = Name; }
// Blocks and stack protectors default to on for 10.6 (darwin10) and beyond.
if (Maj > 9) {
Opts.Blocks = 1;
- Opts.StackProtector = 1;
+ Opts.setStackProtectorMode(LangOptions::SSPOn);
}
// Non-fragile ABI (in 64-bit mode) default to on for 10.5 (darwin9) and
if (CompileOpts.NoImplicitFloat)
FuncAttrs |= llvm::Attribute::NoImplicitFloat;
- if (Features.StackProtector == 1)
+ if (Features.getStackProtectorMode() == LangOptions::SSPOn)
FuncAttrs |= llvm::Attribute::StackProtect;
- else if (Features.StackProtector == 2)
+ else if (Features.getStackProtectorMode() == LangOptions::SSPReq)
FuncAttrs |= llvm::Attribute::StackProtectReq;
QualType RetTy = FI.getReturnType();
PickFP(&TI.getLongDoubleFormat(), -1/*FIXME*/, 17, 21, 33, 36));
DefineBuiltinMacro(Buf, MacroBuf);
- if (LangOpts.StackProtector == 1)
+ if (LangOpts.getStackProtectorMode() == LangOptions::SSPOn)
DefineBuiltinMacro(Buf, "__SSP__=1");
- else if (LangOpts.StackProtector == 2)
+ else if (LangOpts.getStackProtectorMode() == LangOptions::SSPReq)
DefineBuiltinMacro(Buf, "__SSP_ALL__=2");
// Get other target #defines.
Options.Static = StaticDefine;
- assert(StackProtector <= 2 && "Invalid value for -stack-protector");
- if (StackProtector != -1)
- Options.StackProtector = StackProtector;
+ switch (StackProtector) {
+ default:
+ assert(StackProtector <= 2 && "Invalid value for -stack-protector");
+ case -1: break;
+ case 0: Options.setStackProtectorMode(LangOptions::SSPOff); break;
+ case 1: Options.setStackProtectorMode(LangOptions::SSPOn); break;
+ case 2: Options.setStackProtectorMode(LangOptions::SSPReq); break;
+ }
if (MainFileName.getPosition())
Options.setMainFileName(MainFileName.c_str());