diff --git a/src/etc/errorck.py b/src/etc/errorck.py index 4b1b78da9fde4..48736542f20c7 100644 --- a/src/etc/errorck.py +++ b/src/etc/errorck.py @@ -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##" +# +# "##, +# +# 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 @@ -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) @@ -47,6 +66,9 @@ else: errcode_map[errcode] = new_record + if long_diag_begin in line: + inside_long_diag = True + errors = False all_errors = []