[PATCH] D52933: Fix incorrect Twine usage in CFGPrinter

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 7 03:50:28 PDT 2018


lebedev.ri added a comment.

This talks about UB, but i fail to find any ASAN/UBSan output.
Is there ASAN/UBSan output for this? Can you post it?

Nontheless, if the code is identical, then the produced assembly should be mostly the same, too, right?
https://godbolt.org/z/vyEKNo <- i wouldn't say the produced string is the same.
E.g., where does the `.asciz  "label=\"W:"` go?



================
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();
   }
----------------
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.


Repository:
  rL LLVM

https://reviews.llvm.org/D52933





More information about the llvm-commits mailing list