Replace function with high cyclomatic complexity with clang API call.

Replace function with high cyclomatic complexity with clang API call.