Пример #1
0
        public void ReportOutcomeMethodSummary(string methodName, IToken tok, VC.ConditionGeneration.Outcome outcome, string addInfo, double startTime, IEnumerable <string> proverWarnings)
        {
            if (outcome != VC.ConditionGeneration.Outcome.Correct)
            {
                VccCommandLineHost.IncreaseErrorCount();
            }
            Logger.Instance.LogMethodSummary(methodName, tok.ToLocation(), (Outcome)(int)outcome, addInfo, GetTime() - startTime);

            if (!commandLineOptions.RunTestSuite)
            {
                foreach (var proverWarning in proverWarnings)
                {
                    Logger.Instance.Warning("Prover warning: {0}", proverWarning);
                }
            }
        }
Пример #2
0
        public void HandleErrors(object sender, Microsoft.Cci.ErrorEventArgs args)
        {
            foreach (IErrorMessage error in args.Errors)
            {
                ISourceLocation /*?*/ sourceLocation = error.Location as ISourceLocation;
                if (sourceLocation == null)
                {
                    continue;
                }
                if (this.DebugOnWarningOrError)
                {
                    System.Diagnostics.Debugger.Launch();
                }
                bool isError = !error.IsWarning || WarningsAsErrors;
                if (!isError && GetWarningLevel(error.Code) > WarningLevel)
                {
                    continue;
                }
                if (isError)
                {
                    VccCommandLineHost.IncreaseErrorCount();
                }
                CompositeSourceDocument /*?*/ compositeDocument = sourceLocation.SourceDocument as CompositeSourceDocument;
                if (compositeDocument != null)
                {
                    foreach (ISourceLocation sl in compositeDocument.GetFragmentLocationsFor(sourceLocation))
                    {
                        sourceLocation = sl;
                        break;
                    }
                }
                IPrimarySourceLocation /*?*/ primarySourceLocation = sourceLocation as IPrimarySourceLocation;
                if (primarySourceLocation == null)
                {
                    Logger.Instance.Error(error.Message);
                    continue;
                }
                string docName     = primarySourceLocation.SourceDocument.Location ?? primarySourceLocation.SourceDocument.Name.Value;
                int    startLine   = primarySourceLocation.StartLine;
                int    startColumn = primarySourceLocation.StartColumn;
                IncludedSourceLocation /*?*/ includedSourceLocation = primarySourceLocation as IncludedSourceLocation;
                if (includedSourceLocation != null)
                {
                    docName = includedSourceLocation.OriginalSourceDocumentName;
                    if (docName != null)
                    {
                        docName = docName.Replace("\\\\", "\\");
                    }
                    startLine = includedSourceLocation.OriginalStartLine;
                }
                long id = error.IsWarning ? ErrorToId(error.Code) : error.Code;
                if (WarningIsDisabled(id))
                {
                    return;
                }

                Logger.Instance.LogWithLocation(String.Format("VC{0:0000}", id), error.Message, new Location(docName, startLine, startColumn), isError ? LogKind.Error : LogKind.Warning, false);

                string firstErrFile = docName;
                int    firstErrLine = startLine;

                foreach (ILocation relatedLocation in error.RelatedLocations)
                {
                    ISourceLocation /*?*/ sloc = relatedLocation as ISourceLocation;
                    if (sloc != null)
                    {
                        compositeDocument = sloc.SourceDocument as CompositeSourceDocument;
                        if (compositeDocument != null)
                        {
                            foreach (ISourceLocation sl in compositeDocument.GetFragmentLocationsFor(sloc))
                            {
                                sloc = sl;
                                break;
                            }
                        }
                        primarySourceLocation = sloc as IPrimarySourceLocation;
                        if (primarySourceLocation == null)
                        {
                            continue;
                        }
                        docName                = primarySourceLocation.SourceDocument.Location ?? primarySourceLocation.SourceDocument.Name.Value;
                        startLine              = primarySourceLocation.StartLine;
                        startColumn            = primarySourceLocation.StartColumn;
                        includedSourceLocation = primarySourceLocation as IncludedSourceLocation;
                        if (includedSourceLocation != null)
                        {
                            docName = includedSourceLocation.OriginalSourceDocumentName;
                            if (docName != null)
                            {
                                docName = docName.Replace("\\\\", "\\");
                            }
                            startLine = includedSourceLocation.OriginalStartLine;
                        }
                        if (docName != firstErrFile || firstErrLine != startLine)
                        {
                            Logger.Instance.LogWithLocation(
                                null,
                                String.Format("(Location of symbol related to previous {0}.)", isError ? "error" : "warning"),
                                new Location(docName, startLine, startColumn),
                                isError ? LogKind.Error : LogKind.Warning,
                                true);
                        }
                    }
                    //TODO: deal with non source locations
                }
            }
        }
Пример #3
0
        private Program PrepareBoogie(Microsoft.FSharp.Collections.FSharpList <BoogieAST.Decl> boogieDecls)
        {
            var boogieProgram = parent.GetBoogieProgram(boogieDecls);

            CloseVcGen();
            CommandLineOptions.Clo.Parse(standardBoogieOptions);
            IErrorSink errorSink = new BoogieErrorSink(parent.options.NoPreprocessor);

            int numErrors;

            try {
                parent.swBoogieResolve.Start();
                numErrors = boogieProgram.Resolve(errorSink);
            } finally {
                parent.swBoogieResolve.Stop();
            }
            if (numErrors == 0)
            {
                try {
                    parent.swBoogieTypecheck.Start();
                    numErrors = boogieProgram.Typecheck(errorSink);
                } finally {
                    parent.swBoogieTypecheck.Stop();
                }
            }
            if (numErrors == 0)
            {
                try {
                    parent.swBoogieAI.Start();
                    AbstractInterpretation.RunAbstractInterpretation(boogieProgram);
                } finally {
                    parent.swBoogieAI.Stop();
                }
            }

            if (Boogie.CommandLineOptions.Clo.ExpandLambdas && numErrors == 0)
            {
                Boogie.LambdaHelper.ExpandLambdas(boogieProgram);
            }

            if (numErrors != 0)
            {
                VccCommandLineHost.IncreaseErrorCount();
                if (!parent.options.RunTestSuite)
                {
                    Logger.Instance.Error("attempting to dump BPL to buggy.bpl");
                    var filename = "buggy.bpl";
                    if (parent.options.OutputDir != null)
                    {
                        filename = Path.Combine(parent.options.OutputDir, filename);
                    }

                    CommandLineOptions.Install(new CommandLineOptions());
                    using (TokenTextWriter writer = new TokenTextWriter(filename))
                        boogieProgram.Emit(writer);
                }
                errorMode = true;
            }

            return(boogieProgram);
        }