[cfe-commits] r74414 - in /cfe/trunk: include/clang/Basic/LangOptions.h lib/Basic/Targets.cpp lib/CodeGen/CGCall.cpp lib/Frontend/InitPreprocessor.cpp tools/clang-cc/clang-cc.cpp
Bill Wendling
isanbard at gmail.com
Sun Jun 28 16:01:03 PDT 2009
Author: void
Date: Sun Jun 28 18:01:01 2009
New Revision: 74414
URL: http://llvm.org/viewvc/llvm-project?rev=74414&view=rev
Log:
Make the StackProtector bitfield use enums instead of obscure numbers.
Modified:
cfe/trunk/include/clang/Basic/LangOptions.h
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/tools/clang-cc/clang-cc.cpp
Modified: cfe/trunk/include/clang/Basic/LangOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.h?rev=74414&r1=74413&r2=74414&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/LangOptions.h (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.h Sun Jun 28 18:01:01 2009
@@ -84,16 +84,16 @@
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
@@ -104,6 +104,7 @@
unsigned InstantiationDepth; // Maximum template instantiation depth.
enum GCMode { NonGC, GCOnly, HybridGC };
+ enum StackProtectorMode { SSPOff, SSPOn, SSPReq };
enum VisibilityMode {
Default,
Protected,
@@ -156,6 +157,13 @@
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; }
Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=74414&r1=74413&r2=74414&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Sun Jun 28 18:01:01 2009
@@ -238,7 +238,7 @@
// 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
Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=74414&r1=74413&r2=74414&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Sun Jun 28 18:01:01 2009
@@ -392,9 +392,9 @@
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();
Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=74414&r1=74413&r2=74414&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Sun Jun 28 18:01:01 2009
@@ -424,9 +424,9 @@
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.
Modified: cfe/trunk/tools/clang-cc/clang-cc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/clang-cc.cpp?rev=74414&r1=74413&r2=74414&view=diff
==============================================================================
--- cfe/trunk/tools/clang-cc/clang-cc.cpp (original)
+++ cfe/trunk/tools/clang-cc/clang-cc.cpp Sun Jun 28 18:01:01 2009
@@ -819,9 +819,14 @@
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());
More information about the cfe-commits
mailing list