Skip to content

Commit f955d84

Browse files
authored
Merge pull request #59 from brk/push-ktzkqmwvptqo
Invoke C preprocessor via `cc` instead of `gcc`
2 parents 9030703 + 88471ff commit f955d84

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Interaction with the analyzer is primarily through the command-line interpreter
5757
> chkc c-file analyze <filename>
5858
> chkc c-file report-file <filename>
5959
```
60-
The first command preprocesses the file with gcc; the preprocessed file (.i file)
60+
The first command preprocesses the file with `cc`; the preprocessed file (.i file)
6161
is then parsed with **parseFile** (a wrapper for goblint-cil,
6262
https://opam.ocaml.org/packages/goblint-cil/).
6363
The second command analyzes the parsed artifacts, and the third command (and

chc/cmdline/ParseManager.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -221,32 +221,32 @@ def save_semantics(self) -> None:
221221
)
222222
os.chdir(cwd)
223223

224-
def preprocess_file_with_gcc(
224+
def preprocess_file_with_cc(
225225
self,
226226
cfilename: str,
227227
copyfiles: bool = True,
228228
moreoptions: List[str] = []) -> str:
229-
"""Invoke gcc preprocessor on c source file.
229+
"""Invoke C preprocessor on c source file.
230230
231231
Args:
232232
cfilename: c source code filename relative to cpath
233233
moreoptions: list of additional options to be given to the
234234
preprocessor
235235
236236
Effects:
237-
invokes the gcc preprocessor on the c source file and optionally
237+
invokes the C preprocessor on the c source file and optionally
238238
copies the original source file and the generated .i file to the
239-
tgtpath/sourcefiles directory
239+
tgtpath/sourcefiles directory.
240240
"""
241241

242-
chklogger.logger.info("Preprocess file with gcc: %s", cfilename)
242+
chklogger.logger.info("Preprocess file with cc: %s", cfilename)
243243
cwd = os.getcwd()
244244
mac = self.config.platform == "mac"
245245
ifilename = cfilename[:-1] + "i"
246246
macoptions = [
247247
"-U___BLOCKS___", "-D_DARWIN_C_SOURCE", "-D_FORTIFY_SOURCE=0"]
248248
cmd = [
249-
"gcc",
249+
"cc",
250250
"-fno-inline",
251251
"-fno-builtin",
252252
"-E",
@@ -498,7 +498,7 @@ def parse_ifiles(self, copyfiles: bool = True) -> None:
498498
targetfiles.save_xml_file(self.analysisresultspath)
499499

500500
def parse_cfiles(self, copyfiles: bool = True) -> None:
501-
"""Preprocess (with gcc) and run the CodeHawk C parser on all .c
501+
"""Preprocess and run the CodeHawk C parser on all .c
502502
files in the directory."""
503503

504504
os.chdir(self.projectpath)
@@ -509,7 +509,7 @@ def parse_cfiles(self, copyfiles: bool = True) -> None:
509509
fname = self.normalize_filename(os.path.join(d, fname))
510510
if fname.startswith("semantics"):
511511
continue
512-
ifilename = self.preprocess_file_with_gcc(fname, copyfiles)
512+
ifilename = self.preprocess_file_with_cc(fname, copyfiles)
513513
self.parse_ifile(ifilename)
514514
targetfiles.add_file(self.normalize_filename(fname))
515515
targetfiles.save_xml_file(self.analysisresultspath)
@@ -585,7 +585,7 @@ def save_xml_file(self, tgtpath: str) -> None:
585585

586586
if __name__ == "__main__":
587587

588-
# preprocess and parse single files with gcc
588+
# preprocess and parse single files with cc
589589
thisdir = os.path.dirname(os.path.abspath(__file__))
590590
topdir = os.path.dirname(os.path.dirname(thisdir))
591591
testsdir = os.path.join(topdir, "tests")
@@ -594,5 +594,5 @@ def save_xml_file(self, tgtpath: str) -> None:
594594
pm = ParseManager(id115dir, "kendra115", id115dir)
595595
pm.initialize_paths()
596596
for f in ["id115.c", "id116.c", "id117.c", "id118.c"]:
597-
ifilename = pm.preprocess_file_with_gcc(f)
597+
ifilename = pm.preprocess_file_with_cc(f)
598598
pm.parse_ifile(ifilename)

chc/cmdline/c_file/cfileutil.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def set_logging(
103103
def cfile_parse_file(args: argparse.Namespace) -> NoReturn:
104104
"""Parses a single file and saves the results in the .cch directory.
105105
106-
This command runs the gcc preprocessor on the single c-file presented and
106+
This command runs the `cc` preprocessor on the single c-file presented and
107107
then calls the ocaml C analyzer to parse (using the goblint cil parser)
108108
the resulting .i file into ocaml data structures. These data structures
109109
are saved in the <projectname>.cch/a directory. The original c-file and
@@ -159,7 +159,7 @@ def cfile_parse_file(args: argparse.Namespace) -> NoReturn:
159159
parsemanager.initialize_paths()
160160

161161
try:
162-
cfilename_i = parsemanager.preprocess_file_with_gcc(cfilename_c)
162+
cfilename_i = parsemanager.preprocess_file_with_cc(cfilename_c)
163163
result = parsemanager.parse_ifile(cfilename_i)
164164
if result != 0:
165165
print("*" * 80)
@@ -627,7 +627,7 @@ def cfile_run_file(args: argparse.Namespace) -> NoReturn:
627627
parsemanager.initialize_paths()
628628

629629
try:
630-
cfilename_i = parsemanager.preprocess_file_with_gcc(cfilename_c)
630+
cfilename_i = parsemanager.preprocess_file_with_cc(cfilename_c)
631631
result = parsemanager.parse_ifile(cfilename_i)
632632
if result != 0:
633633
print("*" * 80)
@@ -855,7 +855,7 @@ def cfile_testlibc_summary(args: argparse.Namespace) -> NoReturn:
855855
parsemanager.initialize_paths()
856856

857857
try:
858-
cfilename_i = parsemanager.preprocess_file_with_gcc(cfilename_c)
858+
cfilename_i = parsemanager.preprocess_file_with_cc(cfilename_c)
859859
result = parsemanager.parse_ifile(cfilename_i)
860860
if result != 0:
861861
print("*" * 80)

chc/cmdline/chkc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ The regular sequence of commands is:
9191
9292
> chkc c-file parse <cfilename>.c
9393
94-
This command will call gcc to preprocess the file and produce an .i file.
94+
This command will call `cc` to preprocess the file and produce an .i file.
9595
Then the CodeHawk/CIL parser is called to convert the preprocessed file into
9696
OCaml data structures for further analysis. The data structures are stored
9797
in xml_format in (by default) the directory <cfilename>.cch .

chc/cmdline/kendra/TestManager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def test_parser(self, savesemantics: bool = False) -> bool:
219219
self.parsemanager.initialize_paths()
220220
for cfile in self.cref_files:
221221
cfilename_c = cfile.name
222-
ifilename = self.parsemanager.preprocess_file_with_gcc(
222+
ifilename = self.parsemanager.preprocess_file_with_cc(
223223
cfilename_c, copyfiles=True
224224
)
225225
parseresult = self.parsemanager.parse_ifile(ifilename)

chc/util/fileutil.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
1. A new analysis directory is created: tp/pn.cch with two subdirectories:
5959
tp/pn.cch/a and tp/pn.cch/s
6060
61-
2. x.c is preprocessed with the gcc preprocessor, producing the file
61+
2. x.c is preprocessed with the C preprocessor, producing the file
6262
pp/fp/x.i. Both pp/fp/x.c and pp/fp/x.i are copied to tp/pn.cch/s/fp.
6363
6464
3. x.c is parsed by the CodeHawk/CIL parser, producing the following files

0 commit comments

Comments
 (0)