[clang] 2d9d270 - Revert 3e782bf809 "[Sema][MSVC] warn at dynamic_cast when /GR- is given"
Hans Wennborg via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 8 07:16:39 PDT 2020
Author: Hans Wennborg
Date: 2020-09-08T16:10:18+02:00
New Revision: 2d9d270e77918dfc19ad9b3150ee7d40eeb8ca79
URL: https://github.com/llvm/llvm-project/commit/2d9d270e77918dfc19ad9b3150ee7d40eeb8ca79
DIFF: https://github.com/llvm/llvm-project/commit/2d9d270e77918dfc19ad9b3150ee7d40eeb8ca79.diff
LOG: Revert 3e782bf809 "[Sema][MSVC] warn at dynamic_cast when /GR- is given"
This caused more warnings than expected, see https://crbug.com/1126019
Also reverts the follow-up 7907e5516.
> Differential Revision: https://reviews.llvm.org/D86369
Added:
Modified:
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaCast.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/test/SemaCXX/no-rtti.cpp
Removed:
clang/test/SemaCXX/ms_no_dynamic_cast.cpp
clang/test/SemaCXX/no_dynamic_cast.cpp
################################################################################
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td
index a9bd52b8afcd..6b4dcc850612 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1235,5 +1235,3 @@ in addition with the pragmas or -fmax-tokens flag to get any warnings.
}
def WebAssemblyExceptionSpec : DiagGroup<"wasm-exception-spec">;
-
-def RTTI : DiagGroup<"rtti">;
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index ec0c0fd9fa8c..46f7ffc97ce7 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7441,12 +7441,6 @@ def err_no_typeid_with_fno_rtti : Error<
"use of typeid requires -frtti">;
def err_no_dynamic_cast_with_fno_rtti : Error<
"use of dynamic_cast requires -frtti">;
-def warn_no_dynamic_cast_with_rtti_disabled: Warning<
- "dynamic_cast will not work since RTTI data is disabled by "
- "%select{-fno-rtti-data|/GR-}0">, InGroup<RTTI>;
-def warn_no_typeid_with_rtti_disabled: Warning<
- "typeid will not work since RTTI data is disabled by "
- "%select{-fno-rtti-data|/GR-}0">, InGroup<RTTI>;
def err_cannot_form_pointer_to_member_of_reference_type : Error<
"cannot form a pointer-to-member to member %0 of reference type %1">;
diff --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp
index b213fb756a65..726900c59f20 100644
--- a/clang/lib/Sema/SemaCast.cpp
+++ b/clang/lib/Sema/SemaCast.cpp
@@ -890,18 +890,6 @@ void CastOperation::CheckDynamicCast() {
return;
}
- // Warns when dynamic_cast is used with RTTI data disabled.
- if (!Self.getLangOpts().RTTIData) {
- bool MicrosoftABI =
- Self.getASTContext().getTargetInfo().getCXXABI().isMicrosoft();
- bool isClangCL = Self.getDiagnostics().getDiagnosticOptions().getFormat() ==
- DiagnosticOptions::MSVC;
- if (MicrosoftABI || !DestPointee->isVoidType())
- Self.Diag(OpRange.getBegin(),
- diag::warn_no_dynamic_cast_with_rtti_disabled)
- << isClangCL;
- }
-
// Done. Everything else is run-time checks.
Kind = CK_Dynamic;
}
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 8f8847e63804..d1fcdf354527 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -646,12 +646,6 @@ Sema::ActOnCXXTypeid(SourceLocation OpLoc, SourceLocation LParenLoc,
return ExprError(Diag(OpLoc, diag::err_no_typeid_with_fno_rtti));
}
- // Warns when typeid is used with RTTI data disabled.
- if (!getLangOpts().RTTIData)
- Diag(OpLoc, diag::warn_no_typeid_with_rtti_disabled)
- << (getDiagnostics().getDiagnosticOptions().getFormat() ==
- DiagnosticOptions::MSVC);
-
QualType TypeInfoType = Context.getTypeDeclType(CXXTypeInfoDecl);
if (isType) {
diff --git a/clang/test/SemaCXX/ms_no_dynamic_cast.cpp b/clang/test/SemaCXX/ms_no_dynamic_cast.cpp
deleted file mode 100644
index d2c007fd8c29..000000000000
--- a/clang/test/SemaCXX/ms_no_dynamic_cast.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-// RUN: %clang_cc1 %s -triple x86_64-windows -fdiagnostics-format msvc -fno-rtti-data -fsyntax-only -verify
-
-namespace std {
-struct type_info {};
-} // namespace std
-class B {
-public:
- virtual ~B() = default;
-};
-
-class D1 : public B {
-public:
- ~D1() = default;
-};
-
-void f() {
- B* b = new D1();
- auto d = dynamic_cast<D1 *>(b); // expected-warning{{dynamic_cast will not work since RTTI data is disabled by /GR-}}
- void* v = dynamic_cast<void *>(b); // expected-warning{{dynamic_cast will not work since RTTI data is disabled by /GR-}}
- (void)typeid(int); // expected-warning{{typeid will not work since RTTI data is disabled by /GR-}}
-}
diff --git a/clang/test/SemaCXX/no-rtti.cpp b/clang/test/SemaCXX/no-rtti.cpp
index f8487a0902dd..e0b57153c24c 100644
--- a/clang/test/SemaCXX/no-rtti.cpp
+++ b/clang/test/SemaCXX/no-rtti.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -verify -fno-rtti %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fno-rtti %s
namespace std {
class type_info;
diff --git a/clang/test/SemaCXX/no_dynamic_cast.cpp b/clang/test/SemaCXX/no_dynamic_cast.cpp
deleted file mode 100644
index 074b02f4668b..000000000000
--- a/clang/test/SemaCXX/no_dynamic_cast.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-// RUN: %clang_cc1 %s -triple x86_64-pc-linux-gnu -fno-rtti-data -fsyntax-only -verify
-
-namespace std {
-struct type_info {};
-} // namespace std
-class B {
-public:
- virtual ~B() = default;
-};
-
-class D1 : public B {
-public:
- ~D1() = default;
-};
-
-void f() {
- B* b = new D1();
- auto d = dynamic_cast<D1 *>(b); // expected-warning{{dynamic_cast will not work since RTTI data is disabled by -fno-rtti-data}}
- void* v = dynamic_cast<void *>(b);
- (void)typeid(int); // expected-warning{{typeid will not work since RTTI data is disabled by -fno-rtti-data}}
-}
More information about the cfe-commits
mailing list