aboutsummaryrefslogtreecommitdiff
path: root/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
diff options
context:
space:
mode:
authorHaojian Wu <hokein.wu@gmail.com>2023-07-04 13:16:05 +0200
committerHaojian Wu <hokein.wu@gmail.com>2023-07-04 14:32:27 +0200
commit2444fb96435ecae73211f3ced3d06e48719afe97 (patch)
tree4aae6de4215b8085e7028bbf74e4ca379dafb774 /clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
parent7e48c2d85e6d7a306dedef900e74f861c5a66312 (diff)
downloadllvm-2444fb96435ecae73211f3ced3d06e48719afe97.zip
llvm-2444fb96435ecae73211f3ced3d06e48719afe97.tar.gz
llvm-2444fb96435ecae73211f3ced3d06e48719afe97.tar.bz2
[clang-tidy] Don't emit the whole spelling include header in include-cleaner diagnostic message
To keep the message short and consistent with clangd, and the diagnostics are attached to the #include line, users have enough context to understand the whole #include. Differential Revision: https://reviews.llvm.org/D154434
Diffstat (limited to 'clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp')
-rw-r--r--clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp b/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
index b9f44c9..064eccd 100644
--- a/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
@@ -34,6 +34,7 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/Path.h"
#include "llvm/Support/Regex.h"
#include <optional>
#include <string>
@@ -171,7 +172,8 @@ void IncludeCleanerCheck::check(const MatchFinder::MatchResult &Result) {
for (const auto *Inc : Unused) {
diag(Inc->HashLocation, "included header %0 is not used directly")
- << Inc->quote()
+ << llvm::sys::path::filename(Inc->Spelled,
+ llvm::sys::path::Style::posix)
<< FixItHint::CreateRemoval(CharSourceRange::getCharRange(
SM->translateLineCol(SM->getMainFileID(), Inc->Line, 1),
SM->translateLineCol(SM->getMainFileID(), Inc->Line + 1, 1)));