From: Chandler Carruth Date: Thu, 10 Aug 2017 03:05:21 +0000 (+0000) Subject: [LCG] Fix an assert in a on-scope-exit lambda that checked the contents X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0302f3db41184435af0ba451755b515815c16306;p=llvm [LCG] Fix an assert in a on-scope-exit lambda that checked the contents 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310547 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/LazyCallGraph.cpp b/lib/Analysis/LazyCallGraph.cpp index b658fed40c4..5aeea9ef1f7 100644 --- a/lib/Analysis/LazyCallGraph.cpp +++ b/lib/Analysis/LazyCallGraph.cpp @@ -1105,14 +1105,10 @@ LazyCallGraph::RefSCC::removeInternalRefEdge(Node &SourceN, // 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 @@ -1325,6 +1321,12 @@ LazyCallGraph::RefSCC::removeInternalRefEdge(Node &SourceN, 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; }