Reapply r158700 and fixup patches, minus one hunk that slipped through and
caused a crash in an obscure case. On the plus side, it caused me to catch
another bug by inspection.

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