[clang-tools-extra] 176f5e9 - [clang-tidy] Use DenseSet<SourceLocation> in UpgradeDurationConversionsCheck, NFCI
Mikhail Maltsev via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 14 05:50:32 PST 2021
Author: Mikhail Maltsev
Date: 2021-01-14T13:50:16Z
New Revision: 176f5e95e1afad75ff045a00f0fa9c781bd5f54a
URL: https://github.com/llvm/llvm-project/commit/176f5e95e1afad75ff045a00f0fa9c781bd5f54a
DIFF: https://github.com/llvm/llvm-project/commit/176f5e95e1afad75ff045a00f0fa9c781bd5f54a.diff
LOG: [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
Added:
Modified:
clang-tools-extra/clang-tidy/abseil/UpgradeDurationConversionsCheck.cpp
clang-tools-extra/clang-tidy/abseil/UpgradeDurationConversionsCheck.h
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-tidy/abseil/UpgradeDurationConversionsCheck.cpp b/clang-tools-extra/clang-tidy/abseil/UpgradeDurationConversionsCheck.cpp
index 208d1df27763..539b575d1880 100644
--- a/clang-tools-extra/clang-tidy/abseil/UpgradeDurationConversionsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/UpgradeDurationConversionsCheck.cpp
@@ -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(
diff --git a/clang-tools-extra/clang-tidy/abseil/UpgradeDurationConversionsCheck.h b/clang-tools-extra/clang-tidy/abseil/UpgradeDurationConversionsCheck.h
index 7a450a8e9249..23af29299f78 100644
--- a/clang-tools-extra/clang-tidy/abseil/UpgradeDurationConversionsCheck.h
+++ b/clang-tools-extra/clang-tidy/abseil/UpgradeDurationConversionsCheck.h
@@ -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 @@ class UpgradeDurationConversionsCheck : public ClangTidyCheck {
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
private:
- std::unordered_set<unsigned> MatchedTemplateLocations;
+ llvm::DenseSet<SourceLocation> MatchedTemplateLocations;
};
} // namespace abseil
More information about the cfe-commits
mailing list