[cleanup] Factor out some checks. NFC.

The core logic in main() is actually pretty simple, but there's lots of
stuff that has been added over time which obscures the flow of the code.
In upcoming patches, I'll be pulling more stuff out of the main
codepath.

I'm open to naming suggestions for these helper functions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215751 91177308-0d34-0410-b5e6-96231b3b80d8