Skip to content

Commit 37a86ad

Browse files
committed
terminate parsing when encountering an error
1 parent 7018bd3 commit 37a86ad

File tree

6 files changed

+32
-14
lines changed

6 files changed

+32
-14
lines changed

chc/app/CGlobalDeclarations.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,13 +322,19 @@ def cleanup(self, checkpoint: int, ckey: int, gckey: int) -> None:
322322
self.incompatibles[ckey] = set([])
323323
self.incompatibles[ckey].add(gckey)
324324
self.reset_conjectures()
325+
keystoberemoved: List[int] = []
325326
for k in self.compinfo_names.keys():
326327
if k >= checkpoint:
327-
self.compinfo_names.pop(k)
328+
keystoberemoved.append(k)
329+
for k in keystoberemoved:
330+
self.compinfo_names.pop(k)
331+
fskeystoberemoved: List[Tuple[str, int]] = []
328332
for fs in self.fieldstrings.keys():
329333
for gckey in self.fieldstrings[fs]:
330334
if gckey >= checkpoint:
331-
self.fieldstrings[fs].remove(gckey)
335+
fskeystoberemoved.append((fs, gckey))
336+
for (fs, gckey) in fskeystoberemoved:
337+
self.fieldstrings[fs].remove(gckey)
332338

333339
def get_state(self) -> str:
334340
lines = []

chc/cmdline/AnalysisManager.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ def create_file_primary_proofobligations(
212212
chklogger.logger.info(
213213
"Ocaml analyzer is called with %s", str(cmd))
214214
if self.verbose:
215+
print(str(cmd))
215216
result = subprocess.call(
216217
cmd, cwd=self.targetpath, stderr=subprocess.STDOUT)
217218
print("\nResult: " + str(result))

chc/cmdline/ParseManager.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,10 +453,16 @@ def parse_with_ccommands(
453453
print("\nRun the parser: " + str(command) + "\n")
454454
sys.stdout.flush()
455455
if self.verbose:
456-
subprocess.call(command)
456+
returncode = subprocess.call(command)
457457
print("\n" + ("-" * 80) + "\n\n")
458458
else:
459-
subprocess.call(command, stdout=open(os.devnull, "w"))
459+
returncopde = (
460+
subprocess.call(command, stdout=open(os.devnull, "w")))
461+
if returncode == 1:
462+
print("\n" + ("*" * 80))
463+
print("Parsing error in " + cfilename)
464+
print("*" * 80)
465+
break
460466

461467
if self.verbose:
462468
print("\n\nCollect c files")

chc/cmdline/c_file/cfileutil.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ def cfile_run_file(args: argparse.Namespace) -> NoReturn:
486486

487487
def pofilter(po: "CFunctionPO") -> bool:
488488
if copen:
489-
return not po.is_closed
489+
return (po.is_violated or (not po.is_closed))
490490
else:
491491
return True
492492

chc/reporting/ProofObligations.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,14 @@ def function_code_tostring(
468468
ppos = fn.get_ppos()
469469
# ppos = [x for x in ppos if pofilter(x)]
470470
spos = fn.get_spos()
471-
fnstartlinenr = fn.get_line_number()
472-
if fnstartlinenr is None:
471+
if fn.has_line_number():
472+
fnstartlinenr = fn.get_line_number()
473+
fnstartline = fn.cfile.get_source_line(fnstartlinenr)
474+
lines.append("\nFunction " + fn.name)
475+
lines.append("-" * 80)
476+
lines.append(fnstartline.strip())
477+
fd = FunctionDisplay(fn, True)
478+
else:
473479
lines.append(
474480
"\nFunction "
475481
+ fn.name
@@ -478,12 +484,7 @@ def function_code_tostring(
478484
+ ")"
479485
)
480486
fd = FunctionDisplay(fn, False)
481-
else:
482-
fnstartline = fn.cfile.get_source_line(fnstartlinenr)
483-
lines.append("\nFunction " + fn.name)
484-
lines.append("-" * 80)
485-
lines.append(fnstartline.strip())
486-
fd = FunctionDisplay(fn, True)
487+
487488
if showpreamble:
488489
lines.append("-" * 80)
489490
lines.append(str(fn.api))
@@ -499,6 +500,7 @@ def function_code_tostring(
499500
lines.append(
500501
fd.pos_on_code_tostring(spos, pofilter=pofilter, showinvs=showinvs)
501502
)
503+
lines.append("-" * 80)
502504
return "\n".join(lines)
503505

504506

chc/util/IndexedTable.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,12 @@ def reset_to_checkpoint(self) -> int:
241241
if i in self.reserved:
242242
continue
243243
self.indextable.pop(i)
244+
toberemoved: List[int] = []
244245
for k in self.keytable.keys():
245246
if self.keytable[k] >= cp:
246-
self.keytable.pop(k)
247+
toberemoved.append(k)
248+
for k in toberemoved:
249+
self.keytable.pop(k)
247250
self.checkpoint = None
248251
self.reserved = []
249252
self.next = cp

0 commit comments

Comments
 (0)