From e16dc18d96e3fe2a873ab12b607fc80b395cef83 Mon Sep 17 00:00:00 2001 From: Eric Snow Date: Wed, 15 Mar 2023 18:26:32 -0600 Subject: [PATCH 1/2] Un-ignore ceval.c. --- Tools/c-analyzer/cpython/_parser.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Tools/c-analyzer/cpython/_parser.py b/Tools/c-analyzer/cpython/_parser.py index a2911e030ffee1..acf30e2c4020b3 100644 --- a/Tools/c-analyzer/cpython/_parser.py +++ b/Tools/c-analyzer/cpython/_parser.py @@ -96,10 +96,6 @@ def clean_lines(text): # has gone wrong where # we handle "maybe inline actual" # in Tools/c-analyzer/c_parser/parser/_global.py. Modules/expat/xmlparse.c - -# The parser doesn't like the #line directives -# that originate from generated_cases.c.h -Python/ceval.c ''') INCL_DIRS = clean_lines(''' From 575089afee34931206028956df0dce453a26546d Mon Sep 17 00:00:00 2001 From: Eric Snow Date: Wed, 15 Mar 2023 18:39:30 -0600 Subject: [PATCH 2/2] Allow user-added #LINE directives. --- Tools/c-analyzer/c_parser/preprocessor/gcc.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Tools/c-analyzer/c_parser/preprocessor/gcc.py b/Tools/c-analyzer/c_parser/preprocessor/gcc.py index 24c1b0e9b9d48c..c680f351f22416 100644 --- a/Tools/c-analyzer/c_parser/preprocessor/gcc.py +++ b/Tools/c-analyzer/c_parser/preprocessor/gcc.py @@ -153,9 +153,13 @@ def _iter_top_include_lines(lines, topfile, cwd, # XXX How can a file return to line 1? #assert lno > 1, (line, lno) else: - # It's the next line from the file. - assert included == files[-1], (line, files) - assert lno > 1, (line, lno) + if included == files[-1]: + # It's the next line from the file. + assert lno > 1, (line, lno) + else: + # We ran into a user-added #LINE directive, + # which we promptly ignore. + pass elif not files: raise NotImplementedError((line,)) elif filter_reqfile(files[-1]):