[PATCH] D27680: [CodeGen] Move lifetime.start of a variable when goto jumps back past its declaration

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 11 07:39:06 PST 2017

rjmccall added a comment.

Interesting.  That's a pretty heavyweight solution, and you're still missing switches, which have exactly the same "can jump into an arbitrary variable's scope" behavior.

I think maybe an easier solution would be to just remove the begin-lifetime marker completely when there's a label or case statement in its scope.  If we want to improve on that, there's already a jump analysis in Sema that could pretty easily be made to mark variables that have jumps into their lifetimes; we would just need to guarantee that that analysis is done.

Comment at: lib/CodeGen/LifetimeExtend.cpp:11
+class AnalyzeAST : public RecursiveASTVisitor<AnalyzeAST> {
A RecursiveASTVisitor is a rather large thing to instantiate, and we don't need most of its functionality.  Stmt already has a children() accessor that returns the range of child statements, which should be sufficient.


More information about the cfe-commits mailing list