Exemplo n.º 1
0
            private bool _HasConflictingArrayAccesses(TLoopStatementSyntax loopStatement, string loopIndex, Code code, VariableAccesses variableAccesses)
            {
                var optimized = OptimizationRunner.Optimize(code);

                code             = optimized.Code;
                variableAccesses = optimized.Changed ? VariableAccesses.Collect(code) : variableAccesses;

                var cfg           = ControlFlowGraphFactory.Create(code, true);
                var callGraph     = CallGraphFactory.Create(cfg, _methods);
                var calledMethods = callGraph.Methods.Select(methodName => _methods[methodName]).ToImmutableList();
                var aliasAnalysis = AliasAnalysis.Analyze(cfg, callGraph, _methods.Values, _GetAliasesAtLoopEntry(loopStatement, variableAccesses));

                return(ArrayAccessVerifier.HasConflictingAccesses(loopIndex, cfg, aliasAnalysis, callGraph, calledMethods));
            }
Exemplo n.º 2
0
        private static (string Name, ControlFlowGraph Cfg) _GetCodeOfMethod(MethodDeclarationSyntax method, SemanticModel semanticModel)
        {
            var methodName = method.Identifier.Text;

            try {
                var code      = ThreeAddressCodeFactory.Create(CodeFactory.CreateMethod(method, semanticModel));
                var optimized = OptimizationRunner.Optimize(code);

                Debug.WriteLine($"got optimized code for {methodName}");
                return(methodName, ControlFlowGraphFactory.Create(optimized.Code, methodName, true));
            } catch (UnsupportedSyntaxException e) {
                Debug.WriteLine($"method '{methodName}' cannot be utilized in interprocedural anaylsis: {e.Message}");
            }

            return(null, null);
        }