[llvm] r255905 - Revert r254592 (virtual dtor in SCEVPredicate).

Andy Gibbs via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 17 08:43:54 PST 2015


Author: andyg
Date: Thu Dec 17 10:43:53 2015
New Revision: 255905

URL: http://llvm.org/viewvc/llvm-project?rev=255905&view=rev
Log:
Revert r254592 (virtual dtor in SCEVPredicate).

Clang has better diagnostics in this case.  It is not necessary therefore
to change the destructor to avoid what is effectively an invalid warning
in gcc.  Instead, better handle the warning flags given to the compiler.

Modified:
    llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
    llvm/trunk/include/llvm/Analysis/ScalarEvolution.h
    llvm/trunk/lib/Analysis/ScalarEvolution.cpp

Modified: llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/HandleLLVMOptions.cmake?rev=255905&r1=255904&r2=255905&view=diff
==============================================================================
--- llvm/trunk/cmake/modules/HandleLLVMOptions.cmake (original)
+++ llvm/trunk/cmake/modules/HandleLLVMOptions.cmake Thu Dec 17 10:43:53 2015
@@ -391,16 +391,23 @@ elseif( LLVM_COMPILER_IS_GCC_COMPATIBLE
     # 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.
-    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)
+    # 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.
+    if (NOT CMAKE_COMPILER_IS_GNUCXX)
+      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()
+
+    # Enable -Wdelete-non-virtual-dtor if available.
+    add_flag_if_supported("-Wdelete-non-virtual-dtor" DELETE_NON_VIRTUAL_DTOR_FLAG)
 
     # Check if -Wcomment is OK with an // comment ending with '\' if the next
     # line is also a // comment.

Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolution.h?rev=255905&r1=255904&r2=255905&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/ScalarEvolution.h (original)
+++ llvm/trunk/include/llvm/Analysis/ScalarEvolution.h Thu Dec 17 10:43:53 2015
@@ -183,7 +183,7 @@ namespace llvm {
 
   protected:
     SCEVPredicateKind Kind;
-    virtual ~SCEVPredicate();
+    ~SCEVPredicate() = default;
     SCEVPredicate(const SCEVPredicate&) = default;
     SCEVPredicate &operator=(const SCEVPredicate&) = default;
 

Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=255905&r1=255904&r2=255905&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Thu Dec 17 10:43:53 2015
@@ -9628,8 +9628,6 @@ SCEVPredicate::SCEVPredicate(const Foldi
                              SCEVPredicateKind Kind)
     : FastID(ID), Kind(Kind) {}
 
-SCEVPredicate::~SCEVPredicate() {}
-
 SCEVEqualPredicate::SCEVEqualPredicate(const FoldingSetNodeIDRef ID,
                                        const SCEVUnknown *LHS,
                                        const SCEVConstant *RHS)




More information about the llvm-commits mailing list