[PATCH] D52933: Fix incorrect Twine usage in CFGPrinter
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 7 04:09:53 PDT 2018
lebedev.ri added inline comments.
================
Comment at: include/llvm/Analysis/CFGPrinter.h:176
+ // Evaluate in a single statement to avoid dangling pointers in a Twine.
+ return ("label=\"W:" + Twine(Weight->getZExtValue()) + "\"").str();
}
----------------
JonasToth wrote:
> lebedev.ri wrote:
> > Reading the http://llvm.org/docs/ProgrammersManual.html#dss-twine, i *do* think the fix is correct.
> > The old code would call `str()` on a `Twine` stored on a stack,
> > which is clearly stated as broken in the manual.
> The pattern for Twine would be `Twine("label=\"W:") + Weight->getZExtValue() + "\"").str()`, why use `Twine` for the second value instead of the first one?
> The fix itself should still be correct.
That doesn't compile https://godbolt.org/z/7UhuUJ
Repository:
rL LLVM
https://reviews.llvm.org/D52933
More information about the llvm-commits
mailing list