https://github.com/brunodf-gf created https://github.com/llvm/llvm-project/pull/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. >From 81fd70a889dc991e3757f6ebd7d4cb47e49a73c8 Mon Sep 17 00:00:00 2001 From: Bruno De Fraine <[email protected]> Date: Tue, 15 Sep 2026 16:22:43 +0200 Subject: [PATCH] [clang] Drop explicit -Woverloaded-virtual build option Nowadays, Clang and GCC have reasonable default "overloaded-virtual" warnings when using `-Wall`. Fall back to this default. --- clang/CMakeLists.txt | 2 +- clang/lib/CIR/CMakeLists.txt | 11 ----------- clang/tools/cir-opt/CMakeLists.txt | 11 ----------- 3 files changed, 1 insertion(+), 23 deletions(-) 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() _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
