[PATCH] Improve -Winvalid-noreturn

Richard Smith richard at metafoo.co.uk
Fri May 1 19:25:36 PDT 2015


================
Comment at: lib/AST/DeclCXX.cpp:1916-1922
@@ +1915,9 @@
+
+  // Check virtual base classes destructor for noreturn
+  for (const auto &VBase : Record->vbases())
+    if (VBase.getType()
+            ->getAsCXXRecordDecl()
+            ->getDestructor()
+            ->isAnyDestructorNoReturn())
+      return true;
+
----------------
This seems redundant -- the previous loop already checked all direct bases -- and will be expensive because you'll check every virtual base once for each direct base that inherits from it directly or indirectly.

Maybe delete this loop and only check direct bases (recursively)?

================
Comment at: lib/AST/DeclCXX.cpp:1926
@@ +1925,3 @@
+  for (const auto *Field : Record->fields())
+    if (const CXXRecordDecl* RD = Field->getType()->getAsCXXRecordDecl())
+      if (RD->getDestructor()->isAnyDestructorNoReturn())
----------------
You should insert a `getBaseElementTypeUnsafe()` call here before grabbing the `CXXRecordDecl`, in case it's an array of class type.

http://reviews.llvm.org/D9454

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list