r261424 - [MSVC Compat] Add support for /GX, /GX-
David Majnemer via cfe-commits
cfe-commits at lists.llvm.org
Sat Feb 20 01:23:45 PST 2016
Author: majnemer
Date: Sat Feb 20 03:23:44 2016
New Revision: 261424
URL: http://llvm.org/viewvc/llvm-project?rev=261424&view=rev
Log:
[MSVC Compat] Add support for /GX, /GX-
These are legacy flags which map to /EHsc and /EHs-c- respectively.
Modified:
cfe/trunk/include/clang/Driver/CLCompatOptions.td
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/cl-options.c
Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=261424&r1=261423&r2=261424&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original)
+++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Sat Feb 20 03:23:44 2016
@@ -205,6 +205,10 @@ def _SLASH_Fi : CLCompileJoined<"Fi">,
def _SLASH_Fo : CLCompileJoined<"Fo">,
HelpText<"Set output object file, or directory (ends in / or \\) (with /c)">,
MetaVarName<"<file or directory>">;
+def _SLASH_GX : CLFlag<"GX">,
+ HelpText<"Enable exception handling">;
+def _SLASH_GX_ : CLFlag<"GX-">,
+ HelpText<"Enable exception handling">;
def _SLASH_LD : CLFlag<"LD">, HelpText<"Create DLL">;
def _SLASH_LDd : CLFlag<"LDd">, HelpText<"Create debug DLL">;
def _SLASH_link : CLRemainingArgs<"link">,
@@ -308,7 +312,6 @@ def _SLASH_Gr : CLFlag<"Gr">;
def _SLASH_GS : CLFlag<"GS">;
def _SLASH_GT : CLFlag<"GT">;
def _SLASH_Guard : CLJoined<"guard:">;
-def _SLASH_GX : CLFlag<"GX">;
def _SLASH_Gv : CLFlag<"Gv">;
def _SLASH_Gz : CLFlag<"Gz">;
def _SLASH_GZ : CLFlag<"GZ">;
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=261424&r1=261423&r2=261424&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Sat Feb 20 03:23:44 2016
@@ -5775,10 +5775,9 @@ static bool maybeConsumeDash(const std::
namespace {
struct EHFlags {
- EHFlags() : Synch(false), Asynch(false), NoExceptC(false) {}
- bool Synch;
- bool Asynch;
- bool NoExceptC;
+ bool Synch = false;
+ bool Asynch = false;
+ bool NoUnwindC = false;
};
} // end anonymous namespace
@@ -5802,7 +5801,7 @@ static EHFlags parseClangCLEHFlags(const
EH.Asynch = maybeConsumeDash(EHVal, I);
continue;
case 'c':
- EH.NoExceptC = maybeConsumeDash(EHVal, I);
+ EH.NoUnwindC = maybeConsumeDash(EHVal, I);
continue;
case 's':
EH.Synch = maybeConsumeDash(EHVal, I);
@@ -5814,6 +5813,12 @@ static EHFlags parseClangCLEHFlags(const
break;
}
}
+ // The /GX, /GX- flags are only processed if there are not /EH flags.
+ if (EHArgs.empty() &&
+ Args.hasFlag(options::OPT__SLASH_GX, options::OPT__SLASH_GX_)) {
+ EH.Synch = true;
+ EH.NoUnwindC = true;
+ }
return EH;
}
@@ -9704,6 +9709,8 @@ std::unique_ptr<Command> visualstudio::C
// Flags that can simply be passed through.
Args.AddAllArgs(CmdArgs, options::OPT__SLASH_LD);
Args.AddAllArgs(CmdArgs, options::OPT__SLASH_LDd);
+ Args.AddAllArgs(CmdArgs, options::OPT__SLASH_GX);
+ Args.AddAllArgs(CmdArgs, options::OPT__SLASH_GX_);
Args.AddAllArgs(CmdArgs, options::OPT__SLASH_EH);
Args.AddAllArgs(CmdArgs, options::OPT__SLASH_Zl);
Modified: cfe/trunk/test/Driver/cl-options.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=261424&r1=261423&r2=261424&view=diff
==============================================================================
--- cfe/trunk/test/Driver/cl-options.c (original)
+++ cfe/trunk/test/Driver/cl-options.c Sat Feb 20 03:23:44 2016
@@ -211,6 +211,12 @@
// RUN: %clang_cl /FI asdf.h -### -- %s 2>&1 | FileCheck -check-prefix=FI_ %s
// FI_: "-include" "asdf.h"
+// RUN: %clang_cl /c /GX -### -- %s 2>&1 | FileCheck -check-prefix=GX %s
+// GX: "-fcxx-exceptions" "-fexceptions"
+
+// RUN: %clang_cl /c /GX /GX- -### -- %s 2>&1 | FileCheck -check-prefix=GX_ %s
+// GX_-NOT: "-fcxx-exceptions" "-fexceptions"
+
// We forward any unrecognized -W diagnostic options to cc1.
// RUN: %clang_cl -Wunused-pragmas -### -- %s 2>&1 | FileCheck -check-prefix=WJoined %s
// WJoined: "-cc1"
More information about the cfe-commits
mailing list