diff options
| author | Alexander Kornienko <alexfh@google.com> | 2018-11-27 10:53:44 +0000 |
|---|---|---|
| committer | Alexander Kornienko <alexfh@google.com> | 2018-11-27 10:53:44 +0000 |
| commit | 8577dcc53341f45bef0d0f13f39c05225674f72b (patch) | |
| tree | 7bf1169d33a6fe2b859f7b4867262134a8f190e3 /clang-tools-extra/clang-tidy | |
| parent | 6f6b2ba9ab6ac980293ba6bb653c1ad1ff326371 (diff) | |
| download | bcm5719-llvm-8577dcc53341f45bef0d0f13f39c05225674f72b.tar.gz bcm5719-llvm-8577dcc53341f45bef0d0f13f39c05225674f72b.zip | |
[clang-tidy] Avoid inconsistent notes in readability-container-size-empty
When a warning is issued in a template instantiation, the check would previously
use template arguments in a note, which would result in inconsistent or
duplicate warnings (depending on how deduplication was done). This patch removes
template arguments from the note.
llvm-svn: 347652
Diffstat (limited to 'clang-tools-extra/clang-tidy')
| -rw-r--r-- | clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp b/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp index 60a153a8032..97f9eb714be 100644 --- a/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp @@ -213,6 +213,14 @@ void ContainerSizeEmptyCheck::check(const MatchFinder::MatchResult &Result) { } const auto *Container = Result.Nodes.getNodeAs<NamedDecl>("container"); + if (const auto *CTS = dyn_cast<ClassTemplateSpecializationDecl>(Container)) { + // The definition of the empty() method is the same for all implicit + // instantiations. In order to avoid duplicate or inconsistent warnings + // (depending on how deduplication is done), we use the same class name + // for all implicit instantiations of a template. + if (CTS->getSpecializationKind() == TSK_ImplicitInstantiation) + Container = CTS->getSpecializedTemplate(); + } const auto *Empty = Result.Nodes.getNodeAs<FunctionDecl>("empty"); diag(Empty->getLocation(), "method %0::empty() defined here", |

