[PATCH] D53142: [VPlan] Script to extract VPlan digraphs from log

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 11 10:03:01 PDT 2018


fhahn added inline comments.


================
Comment at: utils/extract_vplan.py:24
+CurVPlan = ''
+for line in sys.stdin:
+    if not CurVPlan and re.match("digraph VPlan {", line):
----------------
fhahn wrote:
> My python regex knowledge is a bit rusty, but I think it might be possible to simplify this a bit by having a multi line regex, something like `pattern = re.compile(r"(digraph VPlan {.*})",re.DOTALL)`
> 
> I am curious now and will give that a try.
> 
> 
```pattern = re.compile(r"(digraph VPlan {.*?\n})",re.DOTALL)

matches = re.findall(pattern, sys.stdin.read())
```

-> matches should be a list containing one string per `digraph VPlan {}`. I guess the regex could also be tweaked to extract the name, but that might make it a bit more complicated.


https://reviews.llvm.org/D53142





More information about the llvm-commits mailing list