]> granicus.if.org Git - clang/commitdiff
Work around an obnoxious GCC warning by changing semantics in a hopefully-
authorJohn McCall <rjmccall@apple.com>
Tue, 13 Jul 2010 23:19:49 +0000 (23:19 +0000)
committerJohn McCall <rjmccall@apple.com>
Tue, 13 Jul 2010 23:19:49 +0000 (23:19 +0000)
harmless way.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108295 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGException.cpp
lib/CodeGen/CodeGenFunction.h

index bfe00ea158ac4c66410b481e42388186a1b5c2b5..4980aad1b383c464032517d4b4addc86625cd148 100644 (file)
@@ -1541,4 +1541,6 @@ CodeGenFunction::CleanupBlock::~CleanupBlock() {
   CGF.Builder.restoreIP(SavedIP);
 }
 
-void EHScopeStack::LazyCleanup::_anchor() {}
+EHScopeStack::LazyCleanup::~LazyCleanup() {
+  llvm_unreachable("LazyCleanup is indestructable");
+}
index 90a5421c69558a32007b6afa79b0407b6b6b4e1b..5ee3db08eea0b2097e9982cfef37faa7d882e793 100644 (file)
@@ -125,18 +125,23 @@ public:
     }
   };
 
-  /// A lazy cleanup.  These will be allocated on the cleanup stack
-  /// and so must be trivially copyable.  We "enforce" this by
-  /// providing no virtual destructor so that subclasses will be
-  /// encouraged to contain no non-POD types.
+  /// A lazy cleanup.  Subclasses must be POD-like:  cleanups will
+  /// not be destructed, and they will be allocated on the cleanup
+  /// stack and freely copied and moved around.
   ///
   /// LazyCleanup implementations should generally be declared in an
   /// anonymous namespace.
   class LazyCleanup {
-    // Anchor the construction vtable.
-    virtual void _anchor();
-
   public:
+    // Anchor the construction vtable.  We use the destructor because
+    // gcc gives an obnoxious warning if there are virtual methods
+    // with an accessible non-virtual destructor.  Unfortunately,
+    // declaring this destructor makes it non-trivial, but there
+    // doesn't seem to be any other way around this warning.
+    //
+    // This destructor will never be called.
+    virtual ~LazyCleanup();
+
     /// Emit the cleanup.  For normal cleanups, this is run in the
     /// same EH context as when the cleanup was pushed, i.e. the
     /// immediately-enclosing context of the cleanup scope.  For