of the returned value.
Checking the returned value from inside of a scoped exit isn't actually
valid. It happens to work when NRVO fires and the stars align, which
they reliably do with Clang but don't, for example, on MSVC builds.
llvm-svn: 310547
// or we return new RefSCCs and this RefSCC is dead.
verify();
auto VerifyOnExit = make_scope_exit([&]() {
- if (Result.empty()) {
+ // If we didn't replace our RefSCC with new ones, check that this one
+ // remains valid.
+ if (G)
verify();
- } else {
- assert(!G && "A dead RefSCC should have its graph pointer nulled.");
- assert(SCCs.empty() && "A dead RefSCC should have no SCCs in it.");
- for (RefSCC *RC : Result)
- RC->verify();
- }
});
#endif
SCCs.clear();
SCCIndices.clear();
+#ifndef NDEBUG
+ // Verify the new RefSCCs we've built.
+ for (RefSCC *RC : Result)
+ RC->verify();
+#endif
+
// Return the new list of SCCs.
return Result;
}