diff --git a/README.md b/README.md index 9bf8222..84c4e93 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ Interaction with the analyzer is primarily through the command-line interpreter > chkc c-file analyze > chkc c-file report-file ``` - The first command preprocesses the file with gcc; the preprocessed file (.i file) + The first command preprocesses the file with `cc`; the preprocessed file (.i file) is then parsed with **parseFile** (a wrapper for goblint-cil, https://opam.ocaml.org/packages/goblint-cil/). The second command analyzes the parsed artifacts, and the third command (and diff --git a/chc/cmdline/ParseManager.py b/chc/cmdline/ParseManager.py index ff1d095..f41df19 100644 --- a/chc/cmdline/ParseManager.py +++ b/chc/cmdline/ParseManager.py @@ -221,12 +221,12 @@ def save_semantics(self) -> None: ) os.chdir(cwd) - def preprocess_file_with_gcc( + def preprocess_file_with_cc( self, cfilename: str, copyfiles: bool = True, moreoptions: List[str] = []) -> str: - """Invoke gcc preprocessor on c source file. + """Invoke C preprocessor on c source file. Args: cfilename: c source code filename relative to cpath @@ -234,19 +234,19 @@ def preprocess_file_with_gcc( preprocessor Effects: - invokes the gcc preprocessor on the c source file and optionally + invokes the C preprocessor on the c source file and optionally copies the original source file and the generated .i file to the - tgtpath/sourcefiles directory + tgtpath/sourcefiles directory. """ - chklogger.logger.info("Preprocess file with gcc: %s", cfilename) + chklogger.logger.info("Preprocess file with cc: %s", cfilename) cwd = os.getcwd() mac = self.config.platform == "mac" ifilename = cfilename[:-1] + "i" macoptions = [ "-U___BLOCKS___", "-D_DARWIN_C_SOURCE", "-D_FORTIFY_SOURCE=0"] cmd = [ - "gcc", + "cc", "-fno-inline", "-fno-builtin", "-E", @@ -498,7 +498,7 @@ def parse_ifiles(self, copyfiles: bool = True) -> None: targetfiles.save_xml_file(self.analysisresultspath) def parse_cfiles(self, copyfiles: bool = True) -> None: - """Preprocess (with gcc) and run the CodeHawk C parser on all .c + """Preprocess and run the CodeHawk C parser on all .c files in the directory.""" os.chdir(self.projectpath) @@ -509,7 +509,7 @@ def parse_cfiles(self, copyfiles: bool = True) -> None: fname = self.normalize_filename(os.path.join(d, fname)) if fname.startswith("semantics"): continue - ifilename = self.preprocess_file_with_gcc(fname, copyfiles) + ifilename = self.preprocess_file_with_cc(fname, copyfiles) self.parse_ifile(ifilename) targetfiles.add_file(self.normalize_filename(fname)) targetfiles.save_xml_file(self.analysisresultspath) @@ -585,7 +585,7 @@ def save_xml_file(self, tgtpath: str) -> None: if __name__ == "__main__": - # preprocess and parse single files with gcc + # preprocess and parse single files with cc thisdir = os.path.dirname(os.path.abspath(__file__)) topdir = os.path.dirname(os.path.dirname(thisdir)) testsdir = os.path.join(topdir, "tests") @@ -594,5 +594,5 @@ def save_xml_file(self, tgtpath: str) -> None: pm = ParseManager(id115dir, "kendra115", id115dir) pm.initialize_paths() for f in ["id115.c", "id116.c", "id117.c", "id118.c"]: - ifilename = pm.preprocess_file_with_gcc(f) + ifilename = pm.preprocess_file_with_cc(f) pm.parse_ifile(ifilename) diff --git a/chc/cmdline/c_file/cfileutil.py b/chc/cmdline/c_file/cfileutil.py index abdc97c..9b7622f 100644 --- a/chc/cmdline/c_file/cfileutil.py +++ b/chc/cmdline/c_file/cfileutil.py @@ -98,7 +98,7 @@ def set_logging( def cfile_parse_file(args: argparse.Namespace) -> NoReturn: """Parses a single file and saves the results in the .cch directory. - This command runs the gcc preprocessor on the single c-file presented and + This command runs the `cc` preprocessor on the single c-file presented and then calls the ocaml C analyzer to parse (using the goblint cil parser) the resulting .i file into ocaml data structures. These data structures are saved in the .cch/a directory. The original c-file and @@ -154,7 +154,7 @@ def cfile_parse_file(args: argparse.Namespace) -> NoReturn: parsemanager.initialize_paths() try: - cfilename_i = parsemanager.preprocess_file_with_gcc(cfilename_c) + cfilename_i = parsemanager.preprocess_file_with_cc(cfilename_c) result = parsemanager.parse_ifile(cfilename_i) if result != 0: print("*" * 80) @@ -479,7 +479,7 @@ def cfile_run_file(args: argparse.Namespace) -> NoReturn: parsemanager.initialize_paths() try: - cfilename_i = parsemanager.preprocess_file_with_gcc(cfilename_c) + cfilename_i = parsemanager.preprocess_file_with_cc(cfilename_c) result = parsemanager.parse_ifile(cfilename_i) if result != 0: print("*" * 80) @@ -707,7 +707,7 @@ def cfile_testlibc_summary(args: argparse.Namespace) -> NoReturn: parsemanager.initialize_paths() try: - cfilename_i = parsemanager.preprocess_file_with_gcc(cfilename_c) + cfilename_i = parsemanager.preprocess_file_with_cc(cfilename_c) result = parsemanager.parse_ifile(cfilename_i) if result != 0: print("*" * 80) diff --git a/chc/cmdline/chkc b/chc/cmdline/chkc index fa14016..92f2f85 100755 --- a/chc/cmdline/chkc +++ b/chc/cmdline/chkc @@ -91,7 +91,7 @@ The regular sequence of commands is: > chkc c-file parse .c -This command will call gcc to preprocess the file and produce an .i file. +This command will call `cc` to preprocess the file and produce an .i file. Then the CodeHawk/CIL parser is called to convert the preprocessed file into OCaml data structures for further analysis. The data structures are stored in xml_format in (by default) the directory .cch . diff --git a/chc/cmdline/kendra/TestManager.py b/chc/cmdline/kendra/TestManager.py index 9841c63..d42ef3e 100644 --- a/chc/cmdline/kendra/TestManager.py +++ b/chc/cmdline/kendra/TestManager.py @@ -219,7 +219,7 @@ def test_parser(self, savesemantics: bool = False) -> bool: self.parsemanager.initialize_paths() for cfile in self.cref_files: cfilename_c = cfile.name - ifilename = self.parsemanager.preprocess_file_with_gcc( + ifilename = self.parsemanager.preprocess_file_with_cc( cfilename_c, copyfiles=True ) parseresult = self.parsemanager.parse_ifile(ifilename) diff --git a/chc/util/fileutil.py b/chc/util/fileutil.py index 7882f45..38f18a2 100644 --- a/chc/util/fileutil.py +++ b/chc/util/fileutil.py @@ -58,7 +58,7 @@ 1. A new analysis directory is created: tp/pn.cch with two subdirectories: tp/pn.cch/a and tp/pn.cch/s -2. x.c is preprocessed with the gcc preprocessor, producing the file +2. x.c is preprocessed with the C preprocessor, producing the file pp/fp/x.i. Both pp/fp/x.c and pp/fp/x.i are copied to tp/pn.cch/s/fp. 3. x.c is parsed by the CodeHawk/CIL parser, producing the following files