[llvm] 4bb5f44 - [CMake] Remove unneeded -Wnon-virtual-dtor availability check
Martin Storsjö via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 31 23:58:09 PDT 2021
This causes lots new build warnings when building with GCC (noted with GCC 7 and 9), like these:
../include/llvm/Analysis/ScalarEvolution.h:200:7: warning: ‘class llvm::SCEVPredicate’ has virtual functions and accessible non-virtual destructor [-Wnon-virtual-dtor]
class SCEVPredicate : public FoldingSetNode {
^~~~~~~~~~~~~
../include/llvm/Analysis/ScalarEvolution.h:267:7: warning: base class ‘class llvm::SCEVPredicate’ has accessible non-virtual destructor [-Wnon-virtual-dtor]
class SCEVEqualPredicate final : public SCEVPredicate {
^~~~~~~~~~~~~~~~~~
../include/llvm/Analysis/ScalarEvolution.h:304:7: warning: base class ‘class llvm::SCEVPredicate’ has accessible non-virtual destructor [-Wnon-virtual-dtor]
class SCEVWrapPredicate final : public SCEVPredicate {
^~~~~~~~~~~~~~~~~
../include/llvm/Analysis/ScalarEvolution.h:399:7: warning: base class ‘class llvm::SCEVPredicate’ has accessible non-virtual destructor [-Wnon-virtual-dtor]
class SCEVUnionPredicate final : public SCEVPredicate {
^~~~~~~~~~~~~~~~~~
I haven’t dug in to see whether this is the exact issue that the removed comment referred to or if it’s something else (or if the code should be fixed?).
// Martin
> On Aug 31, 2021, at 21:00, Fangrui Song via llvm-commits <llvm-commits at lists.llvm.org> wrote:
>
>
> Author: Fangrui Song
> Date: 2021-08-31T11:00:16-07:00
> New Revision: 4bb5f44c701402462cb93ef00d46d52382f39f11
>
> URL: https://github.com/llvm/llvm-project/commit/4bb5f44c701402462cb93ef00d46d52382f39f11
> DIFF: https://github.com/llvm/llvm-project/commit/4bb5f44c701402462cb93ef00d46d52382f39f11.diff
>
> LOG: [CMake] Remove unneeded -Wnon-virtual-dtor availability check
>
> For Clang, 3.5 is the minimum requirement which has fixed the bug.
> GCC 5 is good as well.
>
> Added:
>
>
> Modified:
> llvm/cmake/modules/HandleLLVMOptions.cmake
>
> Removed:
>
>
>
> ################################################################################
> diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
> index b139344ce2a7d..c12440d502b74 100644
> --- a/llvm/cmake/modules/HandleLLVMOptions.cmake
> +++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
> @@ -736,25 +736,7 @@ if (LLVM_ENABLE_WARNINGS AND (LLVM_COMPILER_IS_GCC_COMPATIBLE OR CLANG_CL))
> check_cxx_compiler_flag("-Wnoexcept-type" CXX_SUPPORTS_NOEXCEPT_TYPE_FLAG)
> append_if(CXX_SUPPORTS_NOEXCEPT_TYPE_FLAG "-Wno-noexcept-type" CMAKE_CXX_FLAGS)
>
> - # Check if -Wnon-virtual-dtor warns even though the class is marked final.
> - # If it does, don't add it. So it won't be added on clang 3.4 and older.
> - # This also catches cases when -Wnon-virtual-dtor isn't supported by
> - # the compiler at all. This flag is not activated for gcc since it will
> - # incorrectly identify a protected non-virtual base when there is a friend
> - # declaration. Don't activate this in general on Windows as this warning has
> - # too many false positives on COM-style classes, which are destroyed with
> - # Release() (PR32286).
> - if (NOT CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32)
> - set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
> - set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++11 -Werror=non-virtual-dtor")
> - CHECK_CXX_SOURCE_COMPILES("class base {public: virtual void anchor();protected: ~base();};
> - class derived final : public base { public: ~derived();};
> - int main() { return 0; }"
> - CXX_WONT_WARN_ON_FINAL_NONVIRTUALDTOR)
> - set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
> - append_if(CXX_WONT_WARN_ON_FINAL_NONVIRTUALDTOR
> - "-Wnon-virtual-dtor" CMAKE_CXX_FLAGS)
> - endif()
> + append("-Wnon-virtual-dtor" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
>
> # Enable -Wdelete-non-virtual-dtor if available.
> add_flag_if_supported("-Wdelete-non-virtual-dtor" DELETE_NON_VIRTUAL_DTOR_FLAG)
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list