예제 #1
0
        /// <summary>
        /// Perform control flow analysis, reporting all necessary diagnostics.  Returns true if the end of
        /// the body might be reachable...
        /// </summary>
        public static bool Analyze(CSharpCompilation compilation, Symbol member, BoundBlock block, DiagnosticBag diagnostics)
        {
            var walker = new ControlFlowPass(compilation, member, block);

            if (diagnostics != null)
            {
                walker._convertInsufficientExecutionStackExceptionToCancelledByStackGuardException = true;
            }

            try
            {
                bool badRegion = false;
                var  result    = walker.Analyze(ref badRegion, diagnostics);
                Debug.Assert(!badRegion);
                return(result);
            }
            catch (BoundTreeVisitor.CancelledByStackGuardException ex) when(diagnostics != null)
            {
                ex.AddAnError(diagnostics);
                return(true);
            }
            finally
            {
                walker.Free();
            }
        }
예제 #2
0
        private static bool Analyze(
            CSharpCompilation compilation,
            MethodSymbol method,
            BoundBlock block,
            DiagnosticBag diagnostics)
        {
            var result = ControlFlowPass.Analyze(compilation, method, block, diagnostics);

            DefiniteAssignmentPass.Analyze(compilation, method, block, diagnostics);
            return(result);
        }