if __name__ == "__main__":

    args = parse()
    try:
        cpath = UF.get_juliet_testpath(args.cwe, args.test)
        UF.check_analysis_results(cpath)
    except UF.CHError as e:
        print(str(e.wrap()))
        exit(1)

    sempath = os.path.join(cpath, "semantics")

    try:
        cfapp = CApplication(sempath, args.cfile)
        cfile = cfapp.get_cfile()
    except UF.CHCFileNotFoundError as e:
        print(str(e.wrap()))
        exit(1)

    dc = ["deadcode"]

    if args.showcode:
        if args.open:
            print(
                RP.file_code_open_tostring(cfile,
                                           showinvs=args.showinvariants))
        else:
            print(RP.file_code_tostring(cfile, showinvs=args.showinvariants))

    print(RP.file_proofobligation_stats_tostring(cfile, extradsmethods=dc))
Exemple #2
0
    sempath = os.path.join(args.path, "semantics")

    cfapp = CApplication(sempath, args.cfile)
    cfile = cfapp.get_cfile()

    if args.showcode:
        if args.open and args.violations:

            def pofilter(po):
                return not po.is_closed() or po.is_violated()

        elif args.open:

            def pofilter(po):
                return not po.is_closed()

        elif args.violations:

            def pofilter(po):
                return po.is_violated()

        else:

            def pofilter(po):
                return True

        print(RP.file_code_tostring(cfile, pofilter=pofilter, showinvs=True))

    print(RP.file_proofobligation_stats_tostring(cfile))