Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/etc/errorck.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@
errcode_map = {}
error_re = re.compile("(E\d\d\d\d)")

# In the register_long_diagnostics! macro, entries look like this:
#
# EXXXX: r##"
# <Long diagnostic message>
# "##,
#
# These two variables are for detecting the beginning and end of diagnostic
# messages so that duplicate error codes are not reported when a code occurs
# inside a diagnostic message
long_diag_begin = "r##\""
long_diag_end = "\"##"

for (dirpath, dirnames, filenames) in os.walk(src_dir):
if "src/test" in dirpath or "src/llvm" in dirpath:
# Short circuit for fast
Expand All @@ -35,7 +47,14 @@
path = os.path.join(dirpath, filename)

with open(path, 'r') as f:
inside_long_diag = False
for line_num, line in enumerate(f, start=1):
if inside_long_diag:
# Skip duplicate error code checking for this line
if long_diag_end in line:
inside_long_diag = False
continue

match = error_re.search(line)
if match:
errcode = match.group(1)
Expand All @@ -47,6 +66,9 @@
else:
errcode_map[errcode] = new_record

if long_diag_begin in line:
inside_long_diag = True

errors = False
all_errors = []

Expand Down