Driver: Handle /GR- in a compatible way with MSVC
There are slight differences between /GR- and -fno-rtti which made
mapping one to the other inappropriate.
-fno-rtti disables dynamic_cast, typeid, and does not emit RTTI related
information for the v-table.
/GR- does not generate complete object locators and thus will not
reference them in vftables. However, constructs like dynamic_cast and
typeid are permitted.
This should bring our implementation of RTTI up to semantic parity with
MSVC modulo bugs.
llvm-svn: 212138
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp
index 8238167..35affab 100644
--- a/clang/lib/Driver/Tools.cpp
+++ b/clang/lib/Driver/Tools.cpp
@@ -4193,15 +4193,7 @@
(InputType == types::TY_C || InputType == types::TY_CXX)) {
Command *CLCommand = getCLFallback()->GetCommand(C, JA, Output, Inputs,
Args, LinkingOutput);
- // RTTI support in clang-cl is a work in progress. Fall back to MSVC early
- // if we are using 'clang-cl /fallback /GR'.
- // FIXME: Remove this when RTTI is finished.
- if (Args.hasFlag(options::OPT_frtti, options::OPT_fno_rtti, false)) {
- D.Diag(diag::warn_drv_rtti_fallback) << CLCommand->getExecutable();
- C.addCommand(CLCommand);
- } else {
- C.addCommand(new FallbackCommand(JA, *this, Exec, CmdArgs, CLCommand));
- }
+ C.addCommand(new FallbackCommand(JA, *this, Exec, CmdArgs, CLCommand));
} else {
C.addCommand(new Command(JA, *this, Exec, CmdArgs));
}
@@ -4446,9 +4438,10 @@
if (Arg *A = Args.getLastArg(options::OPT_show_includes))
A->render(Args, CmdArgs);
- // RTTI is currently not supported, so disable it by default.
- if (!Args.hasArg(options::OPT_frtti, options::OPT_fno_rtti))
- CmdArgs.push_back("-fno-rtti");
+ // This controls whether or not we emit RTTI data for polymorphic types.
+ if (Args.hasFlag(options::OPT__SLASH_GR_, options::OPT__SLASH_GR,
+ /*default=*/false))
+ CmdArgs.push_back("-fno-rtti-data");
const Driver &D = getToolChain().getDriver();
EHFlags EH = parseClangCLEHFlags(D, Args);
@@ -7709,9 +7702,9 @@
// Flags for which clang-cl have an alias.
// FIXME: How can we ensure this stays in sync with relevant clang-cl options?
- if (Arg *A = Args.getLastArg(options::OPT_frtti, options::OPT_fno_rtti))
- CmdArgs.push_back(A->getOption().getID() == options::OPT_frtti ? "/GR"
- : "/GR-");
+ if (Args.hasFlag(options::OPT__SLASH_GR_, options::OPT__SLASH_GR,
+ /*default=*/false))
+ CmdArgs.push_back("/GR-");
if (Arg *A = Args.getLastArg(options::OPT_ffunction_sections,
options::OPT_fno_function_sections))
CmdArgs.push_back(A->getOption().getID() == options::OPT_ffunction_sections