mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-17 06:56:44 +00:00

- For a better understand of what the unsupported cases are, we add more information to the debug note---a string of ancestor AST nodes of the unclaimed DRE. For example, an unclaimed DRE p in an expression `*(p++)` will result in a string starting with `DRE ==> UnaryOperator(++) ==> Paren ==> UnaryOperator(*)`. - To find out the most common patterns of those unsupported use cases, we add a simple script to build a prefix tree over those strings and count each prefix. The script reads input line by line, assumes a line is a list of words separated by `==>`s, and builds a prefix tree over those lists. Reviewed by: t-rasmud (Rashmi Mudduluru), NoQ (Artem Dergachev) Differential revision: https://reviews.llvm.org/D158561
40 lines
959 B
Python
40 lines
959 B
Python
import sys
|
|
from collections import OrderedDict
|
|
|
|
class Trie:
|
|
def __init__(self, name):
|
|
self.name = name
|
|
self.children = OrderedDict()
|
|
self.count = 1
|
|
|
|
def add(self, name):
|
|
if name in self.children:
|
|
self.children[name].count += 1
|
|
else:
|
|
self.children[name] = Trie(name)
|
|
return self.children[name]
|
|
|
|
def print(self, depth):
|
|
if depth > 0:
|
|
print('|', end="")
|
|
for i in range(depth):
|
|
print('-', end="")
|
|
if depth > 0:
|
|
print(end=" ")
|
|
print(self.name, '#', self.count)
|
|
for key, child in self.children.items():
|
|
child.print(depth + 1)
|
|
|
|
|
|
Root = Trie("Root")
|
|
|
|
if __name__ == "__main__":
|
|
for line in sys.stdin:
|
|
words = line.split('==>')
|
|
words = [word.strip() for word in words]
|
|
MyTrie = Root;
|
|
for word in words:
|
|
MyTrie = MyTrie.add(word)
|
|
|
|
Root.print(0)
|