private static string GenerateClArgs(string fileName, VccOptions commandLineOptions) { StringBuilder args = new StringBuilder(); args.Append("/nologo /TC /u /E /DVERIFY /D_WIN32"); // VCC doesn't like /D_PREFAST_ with VS2010 args.Append(" /D_USE_DECLSPECS_FOR_SAL /DSAL_NO_ATTRIBUTE_DECLARATIONS"); // TODO revisit these if (commandLineOptions.PointerSize == 64) { args.Append(" /D_WIN64"); } foreach (string ppOption in commandLineOptions.PreprocessorOptions) { args.Append(' '); args.Append(ppOption); } string /*?*/ vccHeaders = PathHelper.GetVccHeaderDir(true); if (vccHeaders != null) { args.Append(" /I"); args.Append(vccHeaders); } args.Append(" \"").Append(fileName).Append('\"'); return(args.ToString()); }
public static IEnumerable <StreamReader> Preprocess(VccOptions commandLineOptions, out bool hasErrors) { hasErrors = false; if (commandLineOptions.NoPreprocessor) { return(commandLineOptions.FileNames.Select(s => new StreamReader(s))); } string savedCurentDir = Directory.GetCurrentDirectory(); var preprocessedFiles = new List <StreamReader>(); try { foreach (string fileName in commandLineOptions.FileNames) { Directory.SetCurrentDirectory(Path.GetDirectoryName(fileName)); var ppStream = RunPreprocessor(fileName, commandLineOptions); if (ppStream == null) { hasErrors = true; break; } else { preprocessedFiles.Add(ppStream); } } } catch (Exception e) { Logger.Instance.Error("Error while running preprocessor: " + e.Message); hasErrors = true; } finally { Directory.SetCurrentDirectory(savedCurentDir); } return(preprocessedFiles); }
public ErrorReporter(VccOptions opts, string name, IToken tok, double startTime, VerificationErrorHandler errorHandler) { this.name = name; this.startTime = startTime; this.prevTime = VccCommandLineHost.GetTime(); this.commandLineOptions = opts; this.proverWarnings = new List <string>(); this.errorHandler = errorHandler; this.tok = tok; }
private static void DumpTimes(VccOptions commandLineOptions) { if (commandLineOptions.DetailedTimes) { foreach (var s in currentPlugin.Stopwatches) { Logger.Instance.Log(s.Display()); } } }
public PluginManager(VccOptions options) { List <string> dirs; if (options.PluginOptions.TryGetValue("dir", out dirs)) { foreach (var d in dirs) { AddPluginDirectory(d); } } }
private static StreamReader RunPreprocessor(string fileName, VccOptions commandLineOptions) { string args = GenerateClArgs(fileName, commandLineOptions); string outExtension = ".i"; string outFileName = Path.ChangeExtension(fileName, outExtension); if (commandLineOptions.OutputDir != null) { outFileName = Path.Combine(commandLineOptions.OutputDir, Path.GetFileName(outFileName)); } return(StartClProcessAndReturnOutput(fileName, args, outFileName, commandLineOptions)); }
/// <summary> /// Determine the install location of cl.exe via the environment variables VS100COMNTOOLS or /// VS90COMNTOOLS and setup the start info to invoke the found instance of cl, unless an explicit /// location has been given as command line option. /// </summary> private static ProcessStartInfo ConfigureStartInfoForClVersion11Or10Or9(VccOptions commandLineOptions) { var envPath = Environment.GetEnvironmentVariable("PATH"); var envInclude = Environment.GetEnvironmentVariable("INCLUDE"); if (envPath != "") { envPath = envPath + ";"; } if (envInclude != "") { envInclude = envInclude + ";"; } if (!String.IsNullOrEmpty(commandLineOptions.ClPath)) { ProcessStartInfo result = new ProcessStartInfo("\"" + commandLineOptions.ClPath + "\""); try { FileInfo clPath = new FileInfo(commandLineOptions.ClPath); result.EnvironmentVariables["path"] = envPath + Path.Combine(clPath.Directory.Parent.Parent.FullName, @"Common7\IDE") + ";" + Path.Combine(clPath.Directory.Parent.Parent.Parent.FullName, @"Common7\IDE"); result.EnvironmentVariables["include"] = envInclude + Path.Combine(clPath.Directory.Parent.Parent.FullName, @"VC\INCLUDE") + ";" + Path.Combine(clPath.Directory.Parent.Parent.Parent.FullName, @"VC\INCLUDE"); } catch (Exception) { } // we only do a best effort to set the path return(result); } else { string VSCOMNTOOLS = Environment.GetEnvironmentVariable("VS110COMNTOOLS"); if (VSCOMNTOOLS == null) { VSCOMNTOOLS = Environment.GetEnvironmentVariable("VS100COMNTOOLS"); } if (VSCOMNTOOLS == null) { VSCOMNTOOLS = Environment.GetEnvironmentVariable("VS90COMNTOOLS"); } if (VSCOMNTOOLS == null) { throw new FileNotFoundException(); } string vsDir = new DirectoryInfo(VSCOMNTOOLS).Parent.Parent.FullName; ProcessStartInfo info = new ProcessStartInfo(Path.Combine(vsDir, @"vc\bin\cl.exe")); info.EnvironmentVariables["path"] = envPath + Path.Combine(vsDir, @"Common7\IDE"); info.EnvironmentVariables["include"] = envInclude + Path.Combine(vsDir, @"VC\INCLUDE"); return(info); } }
private void Init(TransHelper.TransEnv env, string filename) { RegisterStopwatches(); foreach (var s in env.Stopwatches) { this.RegisterStopwatch(s); } Transformers.init(env); Transformers.processPipeOptions(env); options = ((VccOptionWrapper)env.Options).VccOptions; this.BvdModelFileName = options.SaveModelForBvd ? AddOutputDirIfRequested(Path.ChangeExtension(filename, "model")) : null; }
internal static Program StandardPrelude(VccOptions options) { // For now Boogie does not support reusing the prelude. //if (standardPrelude == null) // standardPrelude = GetStandardPrelude(); //return standardPrelude; try { swPrelude.Start(); return(GetStandardPrelude(options)); } finally { swPrelude.Stop(); } }
private static void RunPlugin(string fileName, StreamReader instream, VccOptions commandLineOptions) { HostEnvironment hostEnvironment = new HostEnvironment(commandLineOptions.PointerSize); hostEnvironment.Errors += new CciErrorHandler(commandLineOptions).HandleErrors; IName assemName = hostEnvironment.NameTable.GetNameFor(Path.GetFileNameWithoutExtension(fileName)); IName docName = hostEnvironment.NameTable.GetNameFor(Path.GetFileName(fileName)); List <IAssemblyReference> assemblyReferences = new List <IAssemblyReference>(); List <IModuleReference> moduleReferences = new List <IModuleReference>(); assemblyReferences.Add(hostEnvironment.LoadAssembly(hostEnvironment.CoreAssemblySymbolicIdentity)); assemblyReferences.Add(hostEnvironment.LoadAssembly(hostEnvironment.VccRuntimeAssemblyIdentity)); List <VccSourceDocument> programSources = new List <VccSourceDocument>(1); VccAssembly assem = new VccAssembly(assemName, Path.GetFullPath(fileName), hostEnvironment, commandLineOptions, assemblyReferences, moduleReferences, programSources); VccCompilationHelper helper = new VccCompilationHelper(assem.Compilation); programSources.Add(new VccSourceDocument(helper, docName, Path.GetFullPath(fileName), instream)); if (0 != Felt2Cast2Plugin(fileName, commandLineOptions, hostEnvironment, assem)) { fileErrorCount++; } }
static void RunPlugin(VccOptions commandLineOptions) { bool errorsInPreprocessor; var processedFiles = CCompilerHelper.Preprocess(commandLineOptions, out errorsInPreprocessor); if (errorsInPreprocessor) { errorCount++; return; } using (var fnEnum = commandLineOptions.FileNames.GetEnumerator()) using (var ppEnum = processedFiles.GetEnumerator()) while (fnEnum.MoveNext() && ppEnum.MoveNext()) { RunPlugin(fnEnum.Current, ppEnum.Current, commandLineOptions); } if (fileErrorCount > 0) { errorCount++; } }
private static Program GetStandardPrelude(VccOptions options) { string _preludePath = string.IsNullOrEmpty(options.PreludePath) ? PathHelper.PreludePath(StandardPreludePath) : options.PreludePath; if (standardPreludeLines == null) { var lines = File.ReadAllLines(_preludePath, Encoding.UTF8); standardPreludeLines = new List <string>(lines); } Program prelude; int _errorCount = Boogie.Parser.Parse(_preludePath, new List <string>(), out prelude); if (prelude == null || _errorCount > 0) { Logger.Instance.Error("There were errors parsing Vcc3Prelude.bpl."); return(new Program()); } else { return(prelude); } }
private static Plugin InitializePlugin(VccOptions commandLineOptions) { try { string pluginName = null; Plugin selectedPlugin = null; VCGenPlugin vcgenPlugin = null; if (commandLineOptions.PluginOptions.Count != 0 || commandLineOptions.DisplayCommandLineHelp) { pluginManager = new PluginManager(commandLineOptions); string pluginDir = PathHelper.PluginDir; if (pluginDir != null) { pluginManager.AddPluginDirectory(pluginDir); } pluginManager.Discover(); foreach (var opt in commandLineOptions.PluginOptions.Keys) { if (opt == "dir") { continue; } if (pluginName == null) { pluginName = opt; } else { Logger.Instance.Error("More than one plugin requested ('{0}' and '{1}').", pluginName, opt); return(null); } } if (pluginName != null) { foreach (var plugin in pluginManager.Plugins) { if (string.Compare(pluginName, plugin.Name(), true) == 0) { if (selectedPlugin != null) { Logger.Instance.Error("More than one plugin matches '{0}'.", pluginName); return(null); } selectedPlugin = plugin; } } if (selectedPlugin == null) { foreach (var plugin in pluginManager.VCGenPlugins) { if (string.Compare(pluginName, plugin.Name, true) == 0) { if (vcgenPlugin != null) { Logger.Instance.Error("More than one VCGEN plugin matches '{0}'.", pluginName); return(null); } vcgenPlugin = plugin; } } if (vcgenPlugin == null) { Logger.Instance.Error("Plugin '{0}' not found.", pluginName); return(null); } } } } if (selectedPlugin == null) { selectedPlugin = new VccPlugin(vcgenPlugin); // the default } selectedPlugin.RegisterStopwatch(swTotal); selectedPlugin.RegisterStopwatch(swVisitor); selectedPlugin.RegisterStopwatch(swPlugin); selectedPlugin.RegisterStopwatch(swPrelude); selectedPlugin.MessageHandler.AddHandler(PrintPluginMessage); try { swPlugin.Start(); selectedPlugin.UseOptions(new VccOptionWrapper(commandLineOptions)); if (pluginName != null) { selectedPlugin.UseCommandLineOptions(commandLineOptions.PluginOptions[pluginName]); } } finally { swPlugin.Stop(); } return(selectedPlugin); } catch (System.Reflection.ReflectionTypeLoadException e) { foreach (Exception ex in e.LoaderExceptions) { Logger.Instance.Error(ex.Message); Logger.Instance.Error(ex.StackTrace); } } return(null); }
public VerificationErrorHandler(VccOptions commandLineOptions) { this.commandLineOptions = commandLineOptions; }
public CciErrorHandler(VccOptions commandLineOptions) { this.CommandLineOptions = commandLineOptions; }
public override VerificationResult Verify(string funcName) { double start = VccCommandLineHost.GetTime(); // Match replacement in Boogie names string sanitizedFuncName = funcName.Replace('\\', '#'); bool restartProver = false; bool isolateProof = HasIsolateProofAttribute(funcName); if (isolateProof) { CloseVcGen(); } if (parent.options.AggressivePruning || isolateProof) { restartProver = true; // this needs to be done before pruning; otherwise call cycles might get hidden Termination.checkCallCycles(env, currentDecls); var decls = TransUtil.pruneBy(env, funcName, currentDecls); var boogieDecls = Translator.translate(funcName, env, () => VccCommandLineHost.StandardPrelude(parent.options), decls); if (!env.ShouldContinue) { return(VerificationResult.UserError); } currentBoogie = PrepareBoogie(boogieDecls); mustRegenerateBoogie = true; } else { if (mustRegenerateBoogie || currentBoogie == null) { var boogieDecls = Translator.translate(null, env, () => VccCommandLineHost.StandardPrelude(parent.options), currentDecls); if (!env.ShouldContinue) { return(VerificationResult.UserError); } currentBoogie = PrepareBoogie(boogieDecls); mustRegenerateBoogie = false; } } Implementation impl = null; foreach (Declaration decl in currentBoogie.TopLevelDeclarations) { impl = decl as Implementation; if (impl != null && impl.Name == sanitizedFuncName) { break; } impl = null; } if (impl == null) { Logger.Instance.Error("cannot find function: {0}", funcName); return(VerificationResult.UserError); } if (this.errorMode || !env.ShouldContinue) { return(VerificationResult.UserError); } if (impl.SkipVerification) { return(VerificationResult.Skipped); } Logger.Instance.LogMethodStart(funcName); string logPath = CommandLineOptions.Clo.SimplifyLogFilePath; if (logPath != null) { logPath = logPath.Replace("@VCCFILE@", TestRunner.currentTestcaseName); } if (logPath != null && logPath.Contains("@VCCFUNC@")) { logPath = logPath.Replace("@VCCFUNC@", funcName.Replace("$", "_").Replace("^", "_")); CloseVcGen(); } string extraFunctionOptions = null; bool isBvLemmaCheck = IsBvLemmaCheck(impl); bool skipSmoke = HasSkipSmokeAttr(impl); if ((parent.options.RunInBatchMode && (extraFunctionOptions = GetExtraFunctionOptions(impl)) != null) || isBvLemmaCheck || skipSmoke) { CloseVcGen(); extraFunctionOptions = extraFunctionOptions ?? ""; // this prevents parsing errors in case of bv_lemma checks and will also cause the VcGen to be closed later VccOptions extraCommandLineOptions = OptionParser.ParseCommandLineArguments(VccCommandLineHost.dummyHostEnvironment, extraFunctionOptions.Split(' ', '\t'), false); List <string> effectiveOptions = new List <string>(extraCommandLineOptions.BoogieOptions); effectiveOptions.AddRange(extraCommandLineOptions.Z3Options.Select(z3option => "/z3opt:" + z3option)); effectiveOptions.AddRange(options); if (isBvLemmaCheck) { effectiveOptions.Add("/proverOpt:OPTIMIZE_FOR_BV=true"); effectiveOptions.RemoveAll(opt => opt == "/z3opt:CASE_SPLIT"); effectiveOptions.Add("/z3opt:CASE_SPLIT=1"); } if (skipSmoke) { effectiveOptions.RemoveAll(opt => opt == "/smoke"); } if (restartProver) { effectiveOptions.Add("/restartProver"); } if (!ReParseBoogieOptions(effectiveOptions, parent.options.RunningFromCommandLine)) { Logger.Instance.Error("Error parsing extra options '{0}' for function '{1}'", extraFunctionOptions, impl.Name); return(VerificationResult.UserError); } try { parent.swBoogie.Start(); vcgen = new VC.VCGen(currentBoogie, logPath, CommandLineOptions.Clo.SimplifyLogFileAppend); } finally { parent.swBoogie.Stop(); } } else if (vcgen == null) { // run with default options ReParseBoogieOptions(options, parent.options.RunningFromCommandLine); try { parent.swBoogie.Start(); vcgen = new VC.VCGen(currentBoogie, logPath, CommandLineOptions.Clo.SimplifyLogFileAppend); } finally { parent.swBoogie.Stop(); } } var reporter = new ErrorReporter(parent.options, impl.Proc.Name, impl.Proc.tok, start, VccCommandLineHost.ErrorHandler); try { parent.swVcOpt.Start(); } finally { parent.swVcOpt.Stop(); } VC.ConditionGeneration.Outcome outcome; string extraInfo = null; try { parent.swVerifyImpl.Start(); VCGenPlugin plugin = parent.plugin; outcome = plugin != null?plugin.VerifyImpl(env, vcgen, impl, currentBoogie, reporter) : vcgen.VerifyImplementation(impl, currentBoogie, reporter); } catch (UnexpectedProverOutputException exc) { outcome = VC.ConditionGeneration.Outcome.OutOfMemory; extraInfo = "caused an exception \"" + exc.Message + "\""; } finally { parent.swVerifyImpl.Stop(); } if (extraFunctionOptions != null) { CloseVcGen(); } reporter.PrintSummary(outcome, extraInfo); modelCount += reporter.modelCount; switch (outcome) { case VC.ConditionGeneration.Outcome.Correct: return(VerificationResult.Succeeded); case VC.ConditionGeneration.Outcome.Errors: return(VerificationResult.Failed); case VC.ConditionGeneration.Outcome.Inconclusive: return(VerificationResult.Inconclusive); case VC.ConditionGeneration.Outcome.OutOfMemory: return(VerificationResult.Crashed); case VC.ConditionGeneration.Outcome.TimedOut: return(VerificationResult.Crashed); default: return(VerificationResult.Crashed); } }
public static int RunTestSuite(VccOptions commandLineOptions) { return(commandLineOptions.FileNames.Count(fileName => !RunTestSuite(fileName, commandLineOptions))); }
internal VccAssembly(IName name, string location, ISourceEditHost hostEnvironment, VccOptions options, IEnumerable <IAssemblyReference> assemblyReferences, IEnumerable <IModuleReference> moduleReferences, IEnumerable <CompilationPart> compilationParts) : base(name, location, name, assemblyReferences, moduleReferences, new List <IResourceReference>(0).AsReadOnly(), new List <IFileReference>(0).AsReadOnly()) { this.options = options; this.hostEnvironment = hostEnvironment; this.compilationParts = compilationParts; }
public TestRunnerMT(int threadCount, VccOptions commandLineOptions) { this.threadCount = threadCount; this.commandLineOptions = commandLineOptions; }
public VccModule(IName name, string location, ISourceEditHost hostEnvironment, VccOptions options, IAssembly containingAssembly, IEnumerable <IAssemblyReference> assemblyReferences, IEnumerable <IModuleReference> moduleReferences, IEnumerable <VccSourceDocument> programSources) //TODO: pass in information about which assemblies belong to which named unit sets : base(name, location, containingAssembly, assemblyReferences, moduleReferences) { this.options = options; this.hostEnvironment = hostEnvironment; this.programSources = programSources; }
public TransEnv(ISourceEditHost hostEnv, VccOptions options) : base(new VccOptionWrapper(options)) { this.options = options; this.hostEnv = hostEnv; this.hostEnv.Errors += ErrorHandler; }
static bool RunTestSuite(string fileName, VccOptions commandLineOptions) { if (File.Exists(fileName)) { return(TestRunner.RunTestSuite(new FileInfo(fileName), commandLineOptions)); } string baseDir; string fileSpec; if (Directory.Exists(fileName)) { baseDir = fileName; fileSpec = "*"; } else { baseDir = Path.GetDirectoryName(fileName); if (string.IsNullOrEmpty(baseDir)) { baseDir = "."; } fileSpec = Path.GetFileName(fileName); if (string.IsNullOrEmpty(fileSpec)) { fileSpec = "*"; } } int errorCount = 0; int threads = NumThreads(commandLineOptions.RunTestSuiteMultiThreaded); TestRunnerMT trmt = threads > 1 ? new TestRunnerMT(threads, commandLineOptions) : null; foreach (FileInfo fi in new DirectoryInfo(baseDir).GetFiles(fileSpec, SearchOption.TopDirectoryOnly)) { if (fi.Name.StartsWith(".")) { continue; } if (fi.Name.Contains(vccSplitSuffix)) { continue; } if (fi.Extension != ".c" && fi.Extension != "") { continue; } if (trmt != null) { trmt.Queue(fi); } else { if (!TestRunner.RunTestSuite(fi, commandLineOptions)) { errorCount++; } } } if (trmt != null) { if (firstFile) { firstFile = false; if (File.Exists("testsuite.log")) { File.Delete("testsuite.log"); } } errorCount += trmt.Run(); } foreach (DirectoryInfo di in new DirectoryInfo(baseDir).GetDirectories(fileSpec, SearchOption.TopDirectoryOnly)) { if (di.Name.StartsWith(".")) { continue; } RunTestSuite(di.FullName, commandLineOptions); } if (errorCount != 0) { Logger.Instance.NewLine(); Logger.Instance.Error("*** {0} error(s) ***", errorCount); Logger.Instance.NewLine(); return(false); } return(true); }
internal static int Felt2Cast2Plugin(string fileName, VccOptions commandLineOptions, HostEnvironment hostEnvironment, VccAssembly assem) { try { TransHelper.TransEnv helperenv; FSharp.Collections.FSharpList <CAST.Top> res; try { swVisitor.Start(); helperenv = new TransEnv(hostEnvironment, commandLineOptions); var visitor = new Microsoft.Research.Vcc.Visitor(assem.Compilation.ContractProvider, helperenv); if (commandLineOptions.VerificationLocation != null) { var memberAtLoc = FindMemberNameByLocation(commandLineOptions.VerificationLocation, assem); if (memberAtLoc != null) { commandLineOptions.Functions.Add(memberAtLoc); } } try { if (commandLineOptions.AggressivePruning && (commandLineOptions.Functions.Count > 0 || commandLineOptions.FunctionsWithExactName.Count > 0)) { var pruningRoots = new List <string>(); pruningRoots.AddRange(commandLineOptions.Functions.ConvertAll(FunctionOrTypeRoot)); pruningRoots.AddRange(commandLineOptions.FunctionsWithExactName.ConvertAll(FunctionOrTypeRoot)); visitor.VisitOnly(assem, pruningRoots); } else { ((ICodeVisitor)visitor).Visit(assem); } } catch { if (helperenv.ShouldDumpStack) { throw; } return(0); } res = visitor.GetResult(); } finally { swVisitor.Stop(); } if (fileErrorCount > 0) { return(fileErrorCount); } try { swPlugin.Start(); if (currentPlugin.IsModular()) { var fv = currentPlugin.GetFunctionVerifier(fileName, helperenv, res); if (helperenv.ShouldContinue && fileErrorCount == 0) { VerifyFunctions(commandLineOptions, fileName, assem.Name.ToString(), fv); } } else { currentPlugin.Verify(fileName, helperenv, res); } } finally { errorCount += fileErrorCount; fileErrorCount = 0; swPlugin.Stop(); } return(0); } catch (ProverDiedException e) { // we might want to do something else for this one Logger.Instance.NewLine(); Logger.Instance.Error(e.Message); } catch (UnexpectedProverOutputException e) { Logger.Instance.NewLine(); Logger.Instance.Error(e.Message); } catch (Exception e) { Logger.Instance.NewLine(); Logger.Instance.Error(e.Message); } return(-2); }
private static int RunTest(CciErrorHandler errorHandler, string suiteName, string fileNameWithoutExt, string test, VccOptions commandLineOptions, List <string> compilerParameters) { VccCommandLineHost.ResetErrorCount(); string fileNameC = fileNameWithoutExt + ".c"; string fileNameI = fileNameWithoutExt + ".i"; StreamWriter tempStreamWriter = new StreamWriter(fileNameC); tempStreamWriter.Write(test); tempStreamWriter.Close(); VccOptions options = new VccOptions(); options.CopyFrom(commandLineOptions); if (compilerParameters != null) { options = OptionParser.ParseCommandLineArguments(VccCommandLineHost.dummyHostEnvironment, compilerParameters, options); } options.NoPreprocessor = false; options.CheckedArithmetic = true; options.RunTestSuite = true; options.FileNames = new List <string> { fileNameC }; HostEnvironment hostEnvironment = new HostEnvironment(options.PointerSize); hostEnvironment.Errors += errorHandler.HandleErrors; bool errorsInPreprocessor; var f = CCompilerHelper.Preprocess(options, out errorsInPreprocessor); if (errorsInPreprocessor) { return(-1); } var st = f.First(); test = st.ReadToEnd(); st.Close(); File.Delete(fileNameC); // if (!options.KeepPreprocessorFiles) File.Delete(fileNameI); IName name = hostEnvironment.NameTable.GetNameFor(suiteName); List <IAssemblyReference> assemblyReferences = new List <IAssemblyReference>(); List <IModuleReference> moduleReferences = new List <IModuleReference>(); assemblyReferences.Add(hostEnvironment.LoadAssembly(hostEnvironment.CoreAssemblySymbolicIdentity)); assemblyReferences.Add(hostEnvironment.LoadAssembly(hostEnvironment.VccRuntimeAssemblyIdentity)); VccAssembly /*?*/ assem = null; if (hostEnvironment.previousDocument == null || compilerParameters == null || !compilerParameters.Contains("/incremental")) { List <VccSourceDocument> programSources = new List <VccSourceDocument>(1); assem = new VccAssembly(name, "", hostEnvironment, options, assemblyReferences, moduleReferences, programSources); var helper = new VccCompilationHelper(assem.Compilation); programSources.Add(hostEnvironment.previousDocument = new VccSourceDocument(helper, name, name.ToString(), test)); } VccCommandLineHost.ResetStartTime(); return(VccCommandLineHost.Felt2Cast2Plugin("testcase", options, hostEnvironment, assem)); }
private static void VerifyFunctions(VccOptions commandLineOptions, string fileName, string baseName, FunctionVerifier fver) { double beforeBoogie = GetTime(); int numErrors = 0; double beforeMethods = GetTime(); bool checkSpecificFunctions = commandLineOptions.ExplicitTargetsGiven; List <string> foundFunctionSpecifiers = new List <string>(); if (commandLineOptions.DumpBoogie) { fver.DumpInternalsToFile(baseName, true); } foreach (var func in fver.FunctionsToVerify()) { if (checkSpecificFunctions) { // check if this function has been requested either specifically or by prefix bool checkThisFunction = false; if (commandLineOptions.FunctionsWithExactName.Contains(func.Item2)) { checkThisFunction = true; foundFunctionSpecifiers.Add(func.Item2); } if (!checkThisFunction) { foreach (var fn in commandLineOptions.Functions) { var normalized = fn.Replace(':', '#'); if (func.Item2.StartsWith(normalized) && (normalized.Length == func.Item2.Length || func.Item2[normalized.Length] == '#')) { checkThisFunction = true; foundFunctionSpecifiers.Add(fn); break; } } } if (!checkThisFunction) { continue; } } else if (commandLineOptions.IgnoreIncludes != null) { bool fileFound = false; if (commandLineOptions.IgnoreIncludes == "") { if (commandLineOptions.FileNames.Any(file => String.Equals(file, func.Item1, StringComparison.OrdinalIgnoreCase))) { fileFound = true; } } else if (String.Equals(Path.GetFullPath(commandLineOptions.IgnoreIncludes), func.Item1, StringComparison.OrdinalIgnoreCase)) { fileFound = true; } if (!fileFound) { continue; } } var outcome = fver.Verify(func.Item2); //verificationErrorHandler.FlushErrors(); if (commandLineOptions.DumpBoogie) { fver.DumpInternalsToFile(baseName, false); } if (outcome == VerificationResult.Succeeded || outcome == VerificationResult.Skipped) { } else { numErrors++; } } if (checkSpecificFunctions) { List <string> functionSpecifiers = new List <string>(); functionSpecifiers.AddRange(commandLineOptions.Functions); functionSpecifiers.AddRange(commandLineOptions.FunctionsWithExactName); // some functions have not been encountered; warn about those foreach (var fn in functionSpecifiers) { if (!foundFunctionSpecifiers.Contains(fn)) { Logger.Instance.Error("'{0}' did not match any function.", fn); errorCount++; } } } fver.Close(); double now = GetTime(); var timerInfo = commandLineOptions.TimeStats ? new[] { Tuple.Create("total", now - startTime), Tuple.Create("compiler", beforeBoogie - startTime), Tuple.Create("boogie", beforeMethods - beforeBoogie), Tuple.Create("verification", now - beforeMethods) } : null; Logger.Instance.LogFileSummary(fileName, numErrors, timerInfo); }
public void CopyFrom(VccOptions other) { // base class: this.CheckedArithmetic = other.CheckedArithmetic; this.CodePage = other.CodePage; this.DisplayCommandLineHelp = other.DisplayCommandLineHelp; this.DisplayVersion = other.DisplayVersion; this.OutputFileName = other.OutputFileName; this.FileNames.Clear(); this.FileNames.AddRange(other.FileNames); this.ReferencedAssemblies.Clear(); this.ReferencedAssemblies.AddRange(other.ReferencedAssemblies); // this class this.HandledOptions.Clear(); this.HandledOptions.AddRange(other.HandledOptions); this.BoogieOptions.Clear(); this.BoogieOptions.AddRange(other.BoogieOptions); this.WeightOptions.Clear(); this.WeightOptions.AddRange(other.WeightOptions); this.PreprocessorOptions.Clear(); this.PreprocessorOptions.AddRange(other.PreprocessorOptions); this.Z3Options.Clear(); this.Z3Options.AddRange(other.Z3Options); this.Functions.Clear(); this.Functions.AddRange(other.Functions); this.FunctionsWithExactName.Clear(); this.FunctionsWithExactName.AddRange(other.FunctionsWithExactName); this.PipeOperations.Clear(); this.PipeOperations.AddRange(other.PipeOperations); this.DisabledWarnings.Clear(); foreach (var kv in other.DisabledWarnings) { this.DisabledWarnings[kv.Key] = kv.Value; } this.PluginOptions.Clear(); foreach (var kv in other.PluginOptions) { this.PluginOptions[kv.Key] = new List <string>(kv.Value); } this.NoPreprocessor = other.NoPreprocessor; this.RunTestSuite = other.RunTestSuite; this.RunTestSuiteMultiThreaded = other.RunTestSuiteMultiThreaded; this.TranslateToBPL = other.TranslateToBPL; this.TimeStats = other.TimeStats; this.XmlLogFile = other.XmlLogFile; this.ClPath = other.ClPath; this.RunningFromCommandLine = other.RunningFromCommandLine; this.VerifyUpToLine = other.VerifyUpToLine; this.RunInBatchMode = other.RunInBatchMode; this.AggressivePruning = other.AggressivePruning; this.DumpBoogie = other.DumpBoogie; this.WarningsAsErrors = other.WarningsAsErrors; this.WarningLevel = other.WarningLevel; this.DebugOnWarningOrError = other.DebugOnWarningOrError; this.SaveModelForBvd = other.SaveModelForBvd; this.RunInspector = other.RunInspector; this.DetailedTimes = other.DetailedTimes; this.PrintCEVModel = other.PrintCEVModel; this.PointerSize = other.PointerSize; this.DumpTriggers = other.DumpTriggers; this.KeepPreprocessorFiles = other.KeepPreprocessorFiles; this.OpsAsFunctions = other.OpsAsFunctions; this.OutputDir = other.OutputDir; this.VerificationLocation = other.VerificationLocation; this.YarraMode = other.YarraMode; this.IgnoreIncludes = other.IgnoreIncludes; this.TerminationLevel = other.TerminationLevel; this.DefExpansionLevel = other.DefExpansionLevel; this.NoVerification = other.NoVerification; this.DeterminizeOutput = other.DeterminizeOutput; this.PreludePath = other.PreludePath; }
internal VccModule(IName name, string location, ISourceEditHost hostEnvironment, VccOptions options, IAssembly containingAssembly, IEnumerable <IAssemblyReference> assemblyReferences, IEnumerable <IModuleReference> moduleReferences, IEnumerable <CompilationPart> compilationParts) //TODO: pass in information about which assemblies belong to which named unit sets : base(name, location, containingAssembly, assemblyReferences, moduleReferences) { this.options = options; this.hostEnvironment = hostEnvironment; this.compilationParts = compilationParts; }
public override void UseOptions(Helper.Options opts) { options = ((VccOptionWrapper)opts).VccOptions; }
public VccOptionWrapper(VccOptions options) { this.options = options; }
public VccAssembly(IName name, string location, ISourceEditHost hostEnvironment, VccOptions options, IEnumerable <IAssemblyReference> assemblyReferences, IEnumerable <IModuleReference> moduleReferences, IEnumerable <VccSourceDocument> programSources) : base(name, location, name, assemblyReferences, moduleReferences, new List <IResourceReference>(0).AsReadOnly(), new List <IFileReference>(0).AsReadOnly()) { this.options = options; this.hostEnvironment = hostEnvironment; this.programSources = programSources; }