diff options
author | Haojian Wu <hokein.wu@gmail.com> | 2023-06-15 13:48:50 +0200 |
---|---|---|
committer | Haojian Wu <hokein.wu@gmail.com> | 2023-06-15 15:26:48 +0200 |
commit | eed4a4d02e4f33cc2f2a9980466d1c7a1cf37398 (patch) | |
tree | e5b61fcab6ea6f885d00be1bff16e8bf33f5a743 /clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp | |
parent | 015323ff9b21086448eb8ea92328244455b82c37 (diff) | |
download | llvm-eed4a4d02e4f33cc2f2a9980466d1c7a1cf37398.zip llvm-eed4a4d02e4f33cc2f2a9980466d1c7a1cf37398.tar.gz llvm-eed4a4d02e4f33cc2f2a9980466d1c7a1cf37398.tar.bz2 |
[clang-tidy] Correct the include-cleaner-check diagnostic message for missing-includes.
We should print the symbol name rather than the header name in the
message.
Differential Revision: https://reviews.llvm.org/D153013
Diffstat (limited to 'clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp')
-rw-r--r-- | clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp b/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp index 49e7581..b9f44c9 100644 --- a/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp @@ -45,7 +45,7 @@ namespace clang::tidy::misc { namespace { struct MissingIncludeInfo { - SourceLocation SymRefLocation; + include_cleaner::SymbolReference SymRef; include_cleaner::Header Missing; }; } // namespace @@ -134,7 +134,7 @@ void IncludeCleanerCheck::check(const MatchFinder::MatchResult &Result) { if (!Satisfied && !Providers.empty() && Ref.RT == include_cleaner::RefType::Explicit && !shouldIgnore(Providers.front())) - Missing.push_back({Ref.RefLocation, Providers.front()}); + Missing.push_back({Ref, Providers.front()}); }); std::vector<const include_cleaner::Include *> Unused; @@ -190,9 +190,9 @@ void IncludeCleanerCheck::check(const MatchFinder::MatchResult &Result) { if (auto Replacement = HeaderIncludes.insert(llvm::StringRef{Spelling}.trim("\"<>"), Angled, tooling::IncludeDirective::Include)) - diag(SM->getSpellingLoc(Inc.SymRefLocation), - "no header providing %0 is directly included") - << Spelling + diag(SM->getSpellingLoc(Inc.SymRef.RefLocation), + "no header providing \"%0\" is directly included") + << Inc.SymRef.Target.name() << FixItHint::CreateInsertion( SM->getComposedLoc(SM->getMainFileID(), Replacement->getOffset()), |