Index: clang/lib/Driver/ToolChains/MSVC.h =================================================================== --- clang/lib/Driver/ToolChains/MSVC.h +++ clang/lib/Driver/ToolChains/MSVC.h @@ -122,6 +122,11 @@ bool FoundMSVCInstall() const { return !VCToolChainPath.empty(); } + void + addClangTargetOptions(const llvm::opt::ArgList &DriverArgs, + llvm::opt::ArgStringList &CC1Args, + Action::OffloadKind DeviceOffloadKind) const override; + protected: void AddSystemIncludeWithSubfolder(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, Index: clang/lib/Driver/ToolChains/MSVC.cpp =================================================================== --- clang/lib/Driver/ToolChains/MSVC.cpp +++ clang/lib/Driver/ToolChains/MSVC.cpp @@ -1555,3 +1555,11 @@ return DAL; } + +void MSVCToolChain::addClangTargetOptions( + const ArgList &DriverArgs, ArgStringList &CC1Args, + Action::OffloadKind DeviceOffloadKind) const { + if (DriverArgs.hasArg(options::OPT_fno_rtti, options::OPT_frtti, + /*Default=*/false)) + CC1Args.push_back("-D_HAS_STATIC_RTTI=0"); +} Index: clang/test/Driver/msvc-static-rtti.cpp =================================================================== --- /dev/null +++ clang/test/Driver/msvc-static-rtti.cpp @@ -0,0 +1,5 @@ +// RUN: %clang -target x86_64-pc-windows-msvc -fno-rtti -### %s 2>&1 | FileCheck %s -check-prefix STATIC-RTTI-DEF +// RUN: %clang -target x86_64-pc-windows-msvc -frtti -### %s 2>&1 | FileCheck %s -check-prefix STATIC-RTTI-DEF-NOT + +// STATIC-RTTI-DEF: -D_HAS_STATIC_RTTI=0 +// STATIC-RTTI-DEF-NOT: -D_HAS_STATIC_RTTI=0