compilerplugins/clang/dynexcspec.cxx |   19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

New commits:
commit 07bcdbaed1427549e29af00107b99878b9a66a72
Author: Stephan Bergmann <sberg...@redhat.com>
Date:   Fri Feb 10 17:52:15 2017 +0100

    loplugin:dynexcspec: Deallocation functions are implicitly non-throwing
    
    ...so a dynamic exception specification should be replaced with 
noexcept(false).
    Doesn't look like this omission made any difference when running the 
rewriter
    across the LO code base earlier, though.
    
    Change-Id: Ib0e2b412b65cae7c1a68e875bbddf93f3656cebb

diff --git a/compilerplugins/clang/dynexcspec.cxx 
b/compilerplugins/clang/dynexcspec.cxx
index ee74646..c3b8e79 100644
--- a/compilerplugins/clang/dynexcspec.cxx
+++ b/compilerplugins/clang/dynexcspec.cxx
@@ -29,6 +29,19 @@ bool isOverriding(FunctionDecl const * decl) {
         && m->begin_overridden_methods() != m->end_overridden_methods();
 }
 
+bool isDtorOrDealloc(FunctionDecl const * decl) {
+    if (isa<CXXDestructorDecl>(decl)) {
+        return true;
+    }
+    switch (decl->getOverloadedOperator()) {
+    case OO_Delete:
+    case OO_Array_Delete:
+        return true;
+    default:
+        return false;
+    }
+}
+
 class DynExcSpec:
     public RecursiveASTVisitor<DynExcSpec>, public loplugin::RewritePlugin
 {
@@ -75,13 +88,13 @@ public:
                 }
             }
         }
-        bool dtor = isa<CXXDestructorDecl>(decl);
+        bool dtorOrDealloc = isDtorOrDealloc(decl);
         SourceRange source;
 #if CLANG_VERSION >= 40000
         source = decl->getExceptionSpecSourceRange();
 #endif
         if (rewriter != nullptr && source.isValid()) {
-            if (dtor) {
+            if (dtorOrDealloc) {
                 if (replaceText(source, "noexcept(false)")) {
                     return true;
                 }
@@ -125,7 +138,7 @@ public:
         }
         report(
             DiagnosticsEngine::Warning,
-            (dtor
+            (dtorOrDealloc
              ? "replace dynamic exception specification with 'noexcept(false)'"
              : "remove dynamic exception specification"),
             source.isValid() ? source.getBegin() : decl->getLocation())
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to