Skip to content

Commit 0b1fb21

Browse files
committed
CMD: delegate to analysis digests
1 parent 5ccf5a8 commit 0b1fb21

File tree

5 files changed

+59
-37
lines changed

5 files changed

+59
-37
lines changed

chc/cmdline/AnalysisManager.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ def __init__(
5656
thirdpartysummaries: List[str] = [],
5757
keep_system_includes: bool = False,
5858
verbose: bool = False,
59+
disable_timing: bool = False,
5960
collectdiagnostics: bool = False
6061
) -> None:
6162
"""Initialize the analyzer location and target file location.
@@ -79,6 +80,7 @@ def __init__(
7980
self.thirdpartysummaries = thirdpartysummaries
8081
self.unreachability = unreachability
8182
self.verbose = verbose
83+
self.disable_timing = disable_timing
8284
self._collectdiagnostics = collectdiagnostics
8385

8486
@property
@@ -309,6 +311,8 @@ def _generate_and_check_file_cmd_partial(
309311
cmd.append("-unreachability")
310312
if self.verbose:
311313
cmd.append("-verbose")
314+
if self.disable_timing:
315+
cmd.append("-disable_timing")
312316
if self.collect_diagnostics:
313317
cmd.append("-diagnostics")
314318
cmd.append(self.targetpath)

chc/cmdline/c_file/cfileutil.py

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@
6666
from chc.app.CApplication import CApplication
6767
from chc.app.CPrettyPrinter import CPrettyPrinter
6868

69-
from chc.proof.OutputParameterChecker import OutputParameterChecker
70-
7169
import chc.reporting.ProofObligations as RP
7270

7371
from chc.util.Config import Config
@@ -76,6 +74,7 @@
7674

7775
if TYPE_CHECKING:
7876
from chc.app.CAttributes import CAttributes
77+
from chc.app.CInstr import CCallInstr
7978
from chc.app.CTyp import (
8079
CTypComp, CTypFloat, CTypFun, CTypInt, CTypPtr)
8180
from chc.proof.CFunctionPO import CFunctionPO
@@ -652,18 +651,18 @@ def pofilter(po: "CFunctionPO") -> bool:
652651

653652
print(RP.file_proofobligation_stats_tostring(cfile))
654653

654+
def callsite_str(instr: "CCallInstr") -> str:
655+
return (
656+
instr.parent.cfile.name + ".c:"
657+
+ instr.parent.cfun.name + ":"
658+
+ str(instr.location.line)
659+
)
660+
655661
if canalysis == "outputparameters":
656-
print("\n\nOutput parameter analysis results:\n")
657662
for cfun in cfile.functions.values():
658-
op_checker = OutputParameterChecker(cfun)
659-
results = op_checker.results()
660-
if len(results) > 0:
661-
print("\nFunction: " + cfun.name + ": ")
662-
for result in results:
663-
if result.is_success():
664-
print(result.success_str())
665-
else:
666-
print(result.failure_str())
663+
print("\nFunction: " + cfun.name)
664+
print(str(cfun.analysis_digests))
665+
667666
exit(0)
668667

669668
for fnname in cfunctions:
@@ -848,12 +847,8 @@ def pofilter(po: "CFunctionPO") -> bool:
848847

849848
if analysis == "outputparameters":
850849
for cfun in cfile.functions.values():
851-
try:
852-
op_checker = OutputParameterChecker(cfun)
853-
print(str(op_checker))
854-
except UF.CHCError as e:
855-
print("Skipping function " + cfun.name + ": " + str(e))
856-
continue
850+
print("\nFunction: " + cfun.name)
851+
print(str(cfun.analysis_digests))
857852

858853
exit(0)
859854

chc/cmdline/c_project/cprojectutil.py

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@
4949

5050
from chc.linker.CLinker import CLinker
5151

52-
from chc.proof.OutputParameterChecker import OutputParameterChecker
53-
5452
import chc.reporting.ProofObligations as RP
5553

5654
from chc.util.Config import Config
@@ -61,7 +59,7 @@
6159
from chc.app.CAttributes import CAttributes
6260
from chc.app.CFile import CFile
6361
from chc.app.CFunction import CFunction
64-
from chc.app.CInstr import CInstr
62+
from chc.app.CInstr import CInstr, CCallInstr
6563
from chc.app.CStmt import CInstrsStmt, CStmt
6664
from chc.app.CTyp import (
6765
CTypComp, CTypFloat, CTypFun, CTypInt, CTypPtr)
@@ -533,14 +531,17 @@ def cproject_report(args: argparse.Namespace) -> NoReturn:
533531
# arguments
534532
tgtpath: str = args.tgtpath
535533
projectname: str = args.projectname
534+
canalysis: str = args.analysis
535+
verbose: bool = args.verbose
536536

537537
targetpath = os.path.abspath(tgtpath)
538538
projectpath = targetpath
539539

540-
result = UF.read_project_summary_results(targetpath, projectname)
541-
if result is not None:
542-
print(RP.project_proofobligation_stats_dict_to_string(result))
543-
exit(0)
540+
statsresult = UF.read_project_summary_results(targetpath, projectname)
541+
if statsresult is not None:
542+
print(RP.project_proofobligation_stats_dict_to_string(statsresult))
543+
if canalysis == "undefinedbehavior":
544+
exit(0)
544545

545546
if not UF.has_analysisresults_path(targetpath, projectname):
546547
print_error(
@@ -558,13 +559,21 @@ def cproject_report(args: argparse.Namespace) -> NoReturn:
558559
UF.save_project_summary_results(targetpath, projectname, fresult)
559560
UF.save_project_summary_results_as_xml(targetpath, projectname, fresult)
560561

561-
result = UF.read_project_summary_results(targetpath, projectname)
562-
if result is not None:
563-
print(RP.project_proofobligation_stats_dict_to_string(result))
562+
statsresult = UF.read_project_summary_results(targetpath, projectname)
563+
if statsresult is not None:
564+
print(RP.project_proofobligation_stats_dict_to_string(statsresult))
564565
else:
565566
print_error("Results were not readable")
566567
exit(1)
567568

569+
if canalysis == "outputparameters":
570+
571+
for cfile in capp.files.values():
572+
print("\nFile: " + cfile.name)
573+
for cfun in cfile.functions.values():
574+
print("\nFunction: " + cfun.name)
575+
print(str(cfun.analysis_digests))
576+
568577
exit(0)
569578

570579

@@ -613,14 +622,17 @@ def pofilter(po: "CFunctionPO") -> bool:
613622

614623
print(RP.file_proofobligation_stats_tostring(cfile))
615624

625+
def callsite_str(instr: "CCallInstr") -> str:
626+
return (
627+
instr.parent.cfile.name + ".c:"
628+
+ instr.parent.cfun.name + ":"
629+
+ str(instr.location.line)
630+
)
631+
616632
if canalysis == "outputparameters":
617633
for cfun in cfile.functions.values():
618-
try:
619-
op_checker = OutputParameterChecker(cfun)
620-
print(str(op_checker))
621-
except UF.CHCError as e:
622-
print("Skipping function " + cfun.name)
623-
continue
634+
print("\nFunction: " + cfun.name)
635+
print(str(cfun.analysis_digests))
624636

625637
exit(0)
626638

chc/cmdline/chkc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,6 +1584,14 @@ def parse() -> argparse.Namespace:
15841584
"tgtpath", help="directory that contains the analysis results")
15851585
cprojectreport.add_argument(
15861586
"projectname", help="name of the project")
1587+
cprojectreport.add_argument(
1588+
"--analysis",
1589+
default="undefined-behavior",
1590+
choices=["undefined-behavior", "outputparameters"],
1591+
help="choose analysis for reporting results")
1592+
cprojectreport.add_argument(
1593+
"--verbose", "-v",
1594+
action="store_true")
15871595
cprojectreport.set_defaults(func=P.cproject_report)
15881596

15891597
# --- report-file

chc/cmdline/kendra/TestManager.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,8 @@ def test_ppos(self) -> None:
345345
)
346346
cfilename = creffilename_c[:-2]
347347
capp.initialize_single_file(cfilename)
348-
am = AnalysisManager(capp, verbose=self.verbose)
348+
am = AnalysisManager(
349+
capp, verbose=self.verbose, disable_timing=True)
349350
am.create_file_primary_proofobligations(cfilename)
350351
cfile = capp.get_cfile()
351352
capp.collect_post_assumes()
@@ -588,7 +589,8 @@ def test_ppo_proofs(self, delaytest: bool = False) -> None:
588589
# only generate invariants if required
589590
if creffile.has_domains():
590591
for d in creffile.domains:
591-
am = AnalysisManager(capp, verbose=self.verbose)
592+
am = AnalysisManager(
593+
capp, verbose=self.verbose, disable_timing=True)
592594
am.generate_and_check_file(cfilename, None, d)
593595
cfile.reinitialize_tables()
594596
ppos = cfile.get_ppos()
@@ -668,7 +670,8 @@ def test_spo_proofs(self, delaytest: bool = False) -> None:
668670
cappfile = capp.get_cfile()
669671
if creffile.has_domains():
670672
for d in creffile.domains:
671-
am = AnalysisManager(capp, verbose=self.verbose)
673+
am = AnalysisManager(
674+
capp, verbose=self.verbose, disable_timing=True)
672675
am.generate_and_check_file(cfilename, None, d)
673676
cappfile.reinitialize_tables()
674677
spos = cappfile.get_spos()

0 commit comments

Comments
 (0)