[clang-tidy] Use DenseSet<SourceLocation> in UpgradeDurationConversionsCheck, NFCI

This change replaces `unordered_set<unsigned>` (which used to store
internal representation of `SourceLocation`-s) with
`DenseSet<SourceLocation>` (which stores `SourceLocation`-s directly).

Reviewed By: aaron.ballman, njames93

Differential Revision: https://reviews.llvm.org/D94601
This commit is contained in:
Mikhail Maltsev 2021-01-14 13:50:16 +00:00
parent 6abbba3fca
commit 176f5e95e1
2 changed files with 5 additions and 4 deletions

View File

@ -128,7 +128,7 @@ void UpgradeDurationConversionsCheck::check(
if (!match(isInTemplateInstantiation(), *OuterExpr, *Result.Context)
.empty()) {
if (MatchedTemplateLocations.count(Loc.getRawEncoding()) == 0) {
if (MatchedTemplateLocations.count(Loc) == 0) {
// For each location matched in a template instantiation, we check if the
// location can also be found in `MatchedTemplateLocations`. If it is not
// found, that means the expression did not create a match without the
@ -144,7 +144,7 @@ void UpgradeDurationConversionsCheck::check(
internal::Matcher<Stmt> IsInsideTemplate =
hasAncestor(decl(anyOf(classTemplateDecl(), functionTemplateDecl())));
if (!match(IsInsideTemplate, *ArgExpr, *Result.Context).empty())
MatchedTemplateLocations.insert(Loc.getRawEncoding());
MatchedTemplateLocations.insert(Loc);
DiagnosticBuilder Diag = diag(Loc, Message);
CharSourceRange SourceRange = Lexer::makeFileCharRange(

View File

@ -11,7 +11,8 @@
#include "../ClangTidyCheck.h"
#include <unordered_set>
#include "clang/Basic/SourceLocation.h"
#include "llvm/ADT/DenseSet.h"
namespace clang {
namespace tidy {
@ -32,7 +33,7 @@ public:
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
private:
std::unordered_set<unsigned> MatchedTemplateLocations;
llvm::DenseSet<SourceLocation> MatchedTemplateLocations;
};
} // namespace abseil