Skip to content

Commit 8b2c882

Browse files
committed
[CIR] Disable -Woverloaded-virtual when compiling with gcc
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.
1 parent 2ab0704 commit 8b2c882

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

clang/lib/CIR/CMakeLists.txt

+11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
include_directories(${LLVM_MAIN_SRC_DIR}/../mlir/include)
22
include_directories(${CMAKE_BINARY_DIR}/tools/mlir/include)
33

4+
# GCC, unlike clang, issues a warning when one virtual function is overridden
5+
# in a derived class but one or more other virtual functions with the same
6+
# name and different signature from a base class are not overridden. This
7+
# leads to many warnings in the MLIR and ClangIR code when using the
8+
# OpenConversionPattern<>::matchAndRewrite() function in the ordinary way.
9+
# The "hiding" behavior is what we want, so we're just disabling the warning
10+
# here.
11+
if (LLVM_COMPILER_IS_GCC_COMPATIBLE AND (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang"))
12+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-overloaded-virtual")
13+
endif()
14+
415
# Report use of deprecated APIs as errors.
516
# TODO: Consider adding `/we4996` for MSVC when upstream MLIR resolves
617
# https://github.com/llvm/llvm-project/issues/65255.

clang/tools/cir-opt/CMakeLists.txt

+11
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ get_property(conversion_libs GLOBAL PROPERTY MLIR_CONVERSION_LIBS)
44
include_directories(${LLVM_MAIN_SRC_DIR}/../mlir/include)
55
include_directories(${CMAKE_BINARY_DIR}/tools/mlir/include)
66

7+
# GCC, unlike clang, issues a warning when one virtual function is overridden
8+
# in a derived class but one or more other virtual functions with the same
9+
# name and different signature from a base class are not overridden. This
10+
# leads to many warnings in the MLIR and ClangIR code when using the
11+
# OpenConversionPattern<>::matchAndRewrite() function in the ordinary way.
12+
# The "hiding" behavior is what we want, so we're just disabling the warning
13+
# here.
14+
if (LLVM_COMPILER_IS_GCC_COMPATIBLE AND (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang"))
15+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-overloaded-virtual")
16+
endif()
17+
718
add_clang_tool(cir-opt
819
cir-opt.cpp
920
)

0 commit comments

Comments
 (0)