[clang] 91d5a53 - [clang] Drop explicit -Woverloaded-virtual build option (#225359)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 25 01:59:14 PDT 2026
Author: Bruno De Fraine
Date: 2026-09-25T10:59:05+02:00
New Revision: 91d5a537b6b2b62eb1d3dbc5c9c358d2d699ff26
URL: https://github.com/llvm/llvm-project/commit/91d5a537b6b2b62eb1d3dbc5c9c358d2d699ff26
DIFF: https://github.com/llvm/llvm-project/commit/91d5a537b6b2b62eb1d3dbc5c9c358d2d699ff26.diff
LOG: [clang] Drop explicit -Woverloaded-virtual build option (#225359)
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.
Added:
Modified:
clang/CMakeLists.txt
clang/lib/CIR/CMakeLists.txt
clang/tools/cir-opt/CMakeLists.txt
Removed:
################################################################################
diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index a1bdd56599e86c..bc415539fceb13 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -412,7 +412,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 f215c927565def..eebb1131f914c9 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
diff erent 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 b4ae75cfbb118f..9257bb80f978ef 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
diff erent 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()
More information about the cfe-commits
mailing list