[clang-tidy] Fix crash when diagnostic is emit with invalid location
authorPiotr Zegar <me@piotrzegar.pl>
Fri, 11 Aug 2023 15:25:43 +0000 (15:25 +0000)
committerTobias Hieta <tobias@hieta.se>
Tue, 15 Aug 2023 09:08:15 +0000 (11:08 +0200)
commit53671fcffc9cb76e21b1396bd115f9a3e420eb47
treebf6005185ab6708f42af1f5eae2ea1a1e1563778
parent38908de2fb35a51afc5a15eb58cf38df56bf667a
[clang-tidy] Fix crash when diagnostic is emit with invalid location

Fix crash when diagnostic is emit with invalid location,
but with attached valid ranges. Diagnostic can contain
invalid location, but SourceManager attached to it still
can be valid, use it in such case or fallback to known
SourceManager.

Fixes: #64602

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D157649

(cherry picked from commit efd44f80a5a8194b9fe26ff3244ce702cd8dab73)
clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
clang-tools-extra/test/clang-tidy/infrastructure/diagnostic.cpp