[cfe-commits] r108295 - in /cfe/trunk/lib/CodeGen: CGException.cpp CodeGenFunction.h

John McCall rjmccall at apple.com
Tue Jul 13 16:19:49 PDT 2010


Author: rjmccall
Date: Tue Jul 13 18:19:49 2010
New Revision: 108295

URL: http://llvm.org/viewvc/llvm-project?rev=108295&view=rev
Log:
Work around an obnoxious GCC warning by changing semantics in a hopefully-
harmless way.


Modified:
    cfe/trunk/lib/CodeGen/CGException.cpp
    cfe/trunk/lib/CodeGen/CodeGenFunction.h

Modified: cfe/trunk/lib/CodeGen/CGException.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=108295&r1=108294&r2=108295&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGException.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGException.cpp Tue Jul 13 18:19:49 2010
@@ -1541,4 +1541,6 @@
   CGF.Builder.restoreIP(SavedIP);
 }
 
-void EHScopeStack::LazyCleanup::_anchor() {}
+EHScopeStack::LazyCleanup::~LazyCleanup() {
+  llvm_unreachable("LazyCleanup is indestructable");
+}

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=108295&r1=108294&r2=108295&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Tue Jul 13 18:19:49 2010
@@ -125,18 +125,23 @@
     }
   };
 
-  /// 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





More information about the cfe-commits mailing list