sammccall created this revision.
sammccall added reviewers: kadircet, uabelho, bjope.
Herald added subscribers: cfe-commits, mgorny.
Herald added a project: clang.
Currently this warning is on for both clang and GCC, when building clang.
It's off for the rest of LLVM, so my sense is it isn't that vital.
Clang's version seems to be OK: it warns if you're declaring a method that's
virtual in the base, but not overriding.
GCC's version warns whenever there's name hiding, even if you are overriding
something. It fires on this legitimate pattern:
class Base {
virtual void foo(); // to be overridden
void foo(int); // implemented in terms of foo()
};
foo(int) is hidden in derived classes, but foo(int) is used polymorphically
through Base* and works fine there.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=20423
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D82617
Files:
clang/CMakeLists.txt
Index: clang/CMakeLists.txt
===================================================================
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -393,8 +393,11 @@
# Add appropriate flags for GCC
if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-common -Woverloaded-virtual")
- if (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-common")
+ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+ # Clang's version of -Woverloaded-virtual is OK, GCC's is too noisy.
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Woverloaded-virtual")
+ else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing")
endif ()
Index: clang/CMakeLists.txt
===================================================================
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -393,8 +393,11 @@
# Add appropriate flags for GCC
if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-common -Woverloaded-virtual")
- if (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-common")
+ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+ # Clang's version of -Woverloaded-virtual is OK, GCC's is too noisy.
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Woverloaded-virtual")
+ else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing")
endif ()
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits