Short-circuit a couple of queries (and avoid corrupting
the linkage cache) when type-checking static local
variables.

There's a very deep problem here where the linkage of
a declaration can suddenly massively change as soon as
it's given a typedef name; these fixes, while optimizations
in their own right, are really just targeted workarounds.

rdar://15928125

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200380 91177308-0d34-0410-b5e6-96231b3b80d8
Fix crash on unmatched #endif's.

The following snippet would crash:
  #endif
  #if A

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