ap.add_argument('basedir', help='where to look for source file')
return ap.parse_args()
+# Special collector functions for tags that may not occur in source files. This
+# can be useful when we print information with a dynamically generated tag.
+special_collectors = [
+ {
+ 'patterns' : ['assertions::pre-{}', 'assertions::post-{}'],
+ 'collector' : lambda basedir:
+ re.findall('registerPassInfo\("([a-z-]+)"',
+ open(os.path.join(basedir, 'preprocessing', 'preprocessing_pass_registry.cpp')).read()
+ )
+ }
+]
def collect_tags(basedir):
- """Collect all tags used in filed within the given base directory.
+ """Collect all tags used in files within the given base directory and then
+ adds all tags generated by the special collectors specified above.
Return them sorted lexicographically."""
tags = set()
for ext in ['.cc', '.cpp', '.g', '.h']:
content = open(filename, 'rb').read().decode()
for tag in RE_PAT.finditer(content):
tags.add(tag.group(1))
+ for sc in special_collectors:
+ for tag in sc['collector'](basedir):
+ for pat in sc['patterns']:
+ tags.add(pat.format(tag))
return sorted(tags)