Rationalize some of how the locations of prior diagnostics are tracked
across emissions.

1) The include stack printing is conditioned on non-note diagnostics,
   not just on warning diagnostics.
2) Those should be full source locations as they're tied to a source
   manager.
3) We should pass in the prior state to the TextDiagnostic constructor,
   allow it to mutate as diagnostics are emitted, and then cache the
   final state before tearing it down.

Some of this remains incomplete, specifically #3 isn't finished for the
non-note location. That'll come when the include stack printing sinks
down a level.

This also highlights how *completely* bug-ridden this code is. For
example, we currently do all these comparisons of a FullSourceLoc and
a SourceLocation... which silently does a SourceLocation to
SourceLocation comparison, completely disregarding the source manager
from whence one of the arguments came. Oops! Good thing in practice this
wasn't important, but it could in theory be suppressing caret
diagnostics in a second TU on a single clang invocation. I'm hoping to
hammer these bugs out as the refactorings occur, although for so many of
them it's really unlikely I can dream up a test case that would show the
potentially buggy behavior.

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