[clang] [clang] Drop explicit -Woverloaded-virtual build option (PR #225359)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 22 03:31:47 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Bruno De Fraine (brunodf-gf)
<details>
<summary>Changes</summary>
Nowadays, Clang and GCC have reasonable (and aligned) default `-Woverloaded-virtual` warnings when using `-Wall`. Fall back to this default and omit the more aggressive `-Woverloaded-virtual` warnings only present in GCC's level 2 mode of the warning.
The motivation for this change is discussed in the following RFC:
https://discourse.llvm.org/t/rfc-drop-explicit-woverloaded-virtual-clang-build-option/91857
Removing the explicit `-Woverloaded-virtual` build option also allows removing the workaround from e1bd39c.
---
Full diff: https://github.com/llvm/llvm-project/pull/225359.diff
3 Files Affected:
- (modified) clang/CMakeLists.txt (+1-1)
- (modified) clang/lib/CIR/CMakeLists.txt (-11)
- (modified) clang/tools/cir-opt/CMakeLists.txt (-11)
``````````diff
diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 67bc01754fa28..7dc801dbcd5fe 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -402,7 +402,7 @@ configure_file(
# Add appropriate flags for GCC
if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-common -Woverloaded-virtual")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-common")
# Enable -pedantic for Clang even if it's not enabled for LLVM.
if (NOT LLVM_ENABLE_PEDANTIC)
diff --git a/clang/lib/CIR/CMakeLists.txt b/clang/lib/CIR/CMakeLists.txt
index f215c927565de..eebb1131f914c 100644
--- a/clang/lib/CIR/CMakeLists.txt
+++ b/clang/lib/CIR/CMakeLists.txt
@@ -1,17 +1,6 @@
include_directories(${LLVM_MAIN_SRC_DIR}/../mlir/include)
include_directories(${CMAKE_BINARY_DIR}/tools/mlir/include)
-# GCC, unlike clang, issues a warning when one virtual function is overridden
-# in a derived class but one or more other virtual functions with the same
-# name and different signature from a base class are not overridden. This
-# leads to many warnings in the MLIR and ClangIR code when using the
-# OpenConversionPattern<>::matchAndRewrite() function in the ordinary way.
-# The "hiding" behavior is what we want, so we're just disabling the warning
-# here.
-if (LLVM_COMPILER_IS_GCC_COMPATIBLE AND (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang"))
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-overloaded-virtual")
-endif()
-
add_subdirectory(Dialect)
add_subdirectory(CodeGen)
add_subdirectory(FrontendAction)
diff --git a/clang/tools/cir-opt/CMakeLists.txt b/clang/tools/cir-opt/CMakeLists.txt
index b4ae75cfbb118..9257bb80f978e 100644
--- a/clang/tools/cir-opt/CMakeLists.txt
+++ b/clang/tools/cir-opt/CMakeLists.txt
@@ -1,17 +1,6 @@
include_directories(${LLVM_MAIN_SRC_DIR}/../mlir/include)
include_directories(${CMAKE_BINARY_DIR}/tools/mlir/include)
-# GCC, unlike clang, issues a warning when one virtual function is overridden
-# in a derived class but one or more other virtual functions with the same
-# name and different signature from a base class are not overridden. This
-# leads to many warnings in the MLIR and ClangIR code when using the
-# OpenConversionPattern<>::matchAndRewrite() function in the ordinary way.
-# The "hiding" behavior is what we want, so we're just disabling the warning
-# here.
-if (LLVM_COMPILER_IS_GCC_COMPATIBLE AND (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang"))
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-overloaded-virtual")
-endif()
-
if(CLANG_INCLUDE_TESTS)
set(cir_opt_test_libs CIRTestAnalysis)
endif()
``````````
</details>
https://github.com/llvm/llvm-project/pull/225359
More information about the cfe-commits
mailing list