From 4bc8369a267912e0bf6684a46ceef51c6c373713 Mon Sep 17 00:00:00 2001 From: Nick Hamann Date: Sun, 12 Jul 2015 02:23:33 -0500 Subject: [PATCH 1/2] Skip diagnostic codes occurring inside a long diagnostic in errorck. --- src/etc/errorck.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/etc/errorck.py b/src/etc/errorck.py index 4b1b78da9fde4..4f529f5632c39 100644 --- a/src/etc/errorck.py +++ b/src/etc/errorck.py @@ -23,6 +23,9 @@ errcode_map = {} error_re = re.compile("(E\d\d\d\d)") +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 +38,13 @@ 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: + if long_diag_end in line: + inside_long_diag = False + continue + match = error_re.search(line) if match: errcode = match.group(1) @@ -47,6 +56,9 @@ else: errcode_map[errcode] = new_record + if long_diag_begin in line: + inside_long_diag = True + errors = False all_errors = [] From 4630fc75a7a9f61d53153452e5f3c13a8d7e3233 Mon Sep 17 00:00:00 2001 From: Nick Hamann Date: Sun, 12 Jul 2015 21:19:19 -0500 Subject: [PATCH 2/2] Add comments. --- src/etc/errorck.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/etc/errorck.py b/src/etc/errorck.py index 4f529f5632c39..48736542f20c7 100644 --- a/src/etc/errorck.py +++ b/src/etc/errorck.py @@ -23,6 +23,15 @@ 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 = "\"##" @@ -41,6 +50,7 @@ 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