No longer warn on this false positive for -Winvalid-noreturn
__attribute__((noreturn)) void fail(); struct A { ~A() __attribute__((noreturn)) { fail(); } }; struct B : A { B() {} }; __attribute__((noreturn)) void test_1() { A a; } // no warning __attribute__((noreturn)) void test_2() { B b; } // false positive warning here
A new method CXXDesctructorDecl:isAnyDestructorNoReturn that checks if any destructor invoked from the destructor is marked no return. This includes base classes, virtual base classes, and members. Then, replace use of FunctionDecl::isNoReturn with this new method when constructing the CFG.
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)?