private static int CallClousotInternally(string[] args, TextWriter textWriter) { var cciilProvider = CciILCodeProvider.CreateCodeProvider(); var metadataDecoder = cciilProvider.MetaDataDecoder; var contractDecoder = cciilProvider.ContractDecoder; var assemblyCache = new System.Collections.Hashtable(); var outputFactory = new FullTextWriterOutputFactory <MethodReferenceAdaptor, IAssemblyReference>(textWriter, "ServiceOutput"); try { // We now call Clousot int returnCode = Clousot.ClousotMain(args, metadataDecoder, contractDecoder, assemblyCache, outputFactory: outputFactory, cacheAccessorFactories: null ); return(returnCode); } finally { cciilProvider.Dispose(); // make sure all open files are closed } }
public static Environment For(GeneralOptions options, Dictionary <string, IMethodAnalysis> methodAnalyzers, Dictionary <string, IClassAnalysis> classAnalyzers, HostEnvironment host) { var codeProvider = CciILCodeProvider.CreateCodeProvider(host); var codeWriter = CCI2Slicer.CreateSlicer(host); var metadataDecoder = codeProvider.MetaDataDecoder; var contractDecoder = codeProvider.ContractDecoder; return(new Environment(options, codeWriter, metadataDecoder, contractDecoder, methodAnalyzers, classAnalyzers)); }
private void Initialize() { this.host = new ClousotGlueHost(); this.cciProvider = Microsoft.Cci.Analysis.CciILCodeProvider.CreateCodeProvider(host); var metadataDecoder = this.cciProvider.MetaDataDecoder; var contractDecoder = this.cciProvider.ContractDecoder; var args = new string[] { "-nonnull", "-bounds", "-arithmetic", "-sortwarns:-" }; var output = new RoslynOutput(this.analysisResults); this.methodAnalyzer = Clousot.GetIndividualMethodAnalyzer(metadataDecoder, contractDecoder, args, output, null); }
public static int Main(string[] args, IOutputFullResultsFactory <MethodReferenceAdaptor, IAssemblyReference> outputFactory, IEnumerable <Caching.IClousotCacheFactory> cacheAccessorFactories) { Contract.Requires(args != null); if (args.Length > 0 && args[0] == "-cloudot") { try { return(ClousotViaService.Main(args)); } catch (Exception) { Console.WriteLine("Process terminated with an exception".PrefixWithCurrentTime()); return(-1); } } else { var cciilProvider = CciILCodeProvider.CreateCodeProvider(); var metadataDecoder = cciilProvider.MetaDataDecoder; var contractDecoder = cciilProvider.ContractDecoder; var assemblyCache = new System.Collections.Hashtable(); try { int returnCode = Clousot.ClousotMain(args, metadataDecoder, contractDecoder, assemblyCache, outputFactory: outputFactory, cacheAccessorFactories: cacheAccessorFactories ); return(returnCode); // important for regressions } catch (ExitRequestedException e) { return(e.ExitCode); } finally { cciilProvider.Dispose(); } } }
static int CallClousot2(string[] args) { var cciilProvider = CciILCodeProvider.CreateCodeProvider(); var metadataDecoder = cciilProvider.MetaDataDecoder; var contractDecoder = cciilProvider.ContractDecoder; var assemblyCache = new System.Collections.Hashtable(); var textWriter = Console.Out; var outputFactory = new FullTextWriterOutputFactory <MethodReferenceAdaptor, IAssemblyReference>(textWriter, "ServiceOutput"); try { // We now call Clousot int returnCode = Clousot.ClousotMain(args, metadataDecoder, contractDecoder, assemblyCache, outputFactory: outputFactory, cacheAccessorFactories: null ); return(returnCode); } catch (ExitRequestedException e) { return(e.ExitCode); } catch (Exception e) { // We need to catch all exception, otherwise the service is turned into an faulted state and remains unusable textWriter.WriteLine("[{0}]: Many Clousot: caught exception: {1}", DateTime.Now, e); if (e.InnerException != null) { textWriter.WriteLine("Inner exception: {0}", e.InnerException); } return(-4444); } finally { Console.WriteLine("Analysis done".PrefixWithCurrentTime()); textWriter.Close(); // make sure all pending output are flushed cciilProvider.Dispose(); // make sure all open files are closed } }