Skip to content

Commit ccd5dda

Browse files
[clang-tools-extra] Replace SmallSet with SmallPtrSet (NFC) (llvm#154365)
This patch replaces SmallSet<T *, N> with SmallPtrSet<T *, N>. Note that SmallSet.h "redirects" SmallSet to SmallPtrSet for pointer element types: template <typename PointeeType, unsigned N> class SmallSet<PointeeType*, N> : public SmallPtrSet<PointeeType*, N> {}; We only have 10 instances that rely on this "redirection", with more than half of them under clang-tools-extra/. Since the redirection doesn't improve readability, this patch replaces SmallSet with SmallPtrSet for pointer element types. I'm planning to remove the redirection eventually.
1 parent 4c9b7ff commit ccd5dda

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ static bool isKnownToHaveValue(const Expr &Cond, const ASTContext &Ctx,
188188
/// \return true iff all `CallExprs` visited have callees; false otherwise
189189
/// indicating there is an unresolved indirect call.
190190
static bool populateCallees(const Stmt *StmtNode,
191-
llvm::SmallSet<const Decl *, 16> &Callees) {
191+
llvm::SmallPtrSet<const Decl *, 16> &Callees) {
192192
if (const auto *Call = dyn_cast<CallExpr>(StmtNode)) {
193193
const Decl *Callee = Call->getDirectCallee();
194194

@@ -212,7 +212,7 @@ static bool populateCallees(const Stmt *StmtNode,
212212
/// returns true iff `SCC` contains `Func` and its' function set overlaps with
213213
/// `Callees`
214214
static bool overlap(ArrayRef<CallGraphNode *> SCC,
215-
const llvm::SmallSet<const Decl *, 16> &Callees,
215+
const llvm::SmallPtrSet<const Decl *, 16> &Callees,
216216
const Decl *Func) {
217217
bool ContainsFunc = false, Overlap = false;
218218

@@ -264,7 +264,7 @@ static bool hasRecursionOverStaticLoopCondVariables(const Expr *Cond,
264264
if (!hasStaticLocalVariable(Cond))
265265
return false;
266266

267-
llvm::SmallSet<const Decl *, 16> CalleesInLoop;
267+
llvm::SmallPtrSet<const Decl *, 16> CalleesInLoop;
268268

269269
if (!populateCallees(LoopStmt, CalleesInLoop)) {
270270
// If there are unresolved indirect calls, we assume there could

clang-tools-extra/clangd/AST.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,7 @@ resolveForwardingParameters(const FunctionDecl *D, unsigned MaxDepth) {
985985
// Recurse on pack parameters
986986
size_t Depth = 0;
987987
const FunctionDecl *CurrentFunction = D;
988-
llvm::SmallSet<const FunctionTemplateDecl *, 4> SeenTemplates;
988+
llvm::SmallPtrSet<const FunctionTemplateDecl *, 4> SeenTemplates;
989989
if (const auto *Template = D->getPrimaryTemplate()) {
990990
SeenTemplates.insert(Template);
991991
}

clang-tools-extra/clangd/XRefs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1876,7 +1876,7 @@ static void fillSubTypes(const SymbolID &ID,
18761876
});
18771877
}
18781878

1879-
using RecursionProtectionSet = llvm::SmallSet<const CXXRecordDecl *, 4>;
1879+
using RecursionProtectionSet = llvm::SmallPtrSet<const CXXRecordDecl *, 4>;
18801880

18811881
// Extracts parents from AST and populates the type hierarchy item.
18821882
static void fillSuperTypes(const CXXRecordDecl &CXXRD, llvm::StringRef TUPath,

clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ struct ExtractionZone {
181181
bool requiresHoisting(const SourceManager &SM,
182182
const HeuristicResolver *Resolver) const {
183183
// First find all the declarations that happened inside extraction zone.
184-
llvm::SmallSet<const Decl *, 1> DeclsInExtZone;
184+
llvm::SmallPtrSet<const Decl *, 1> DeclsInExtZone;
185185
for (auto *RootStmt : RootStmts) {
186186
findExplicitReferences(
187187
RootStmt,

0 commit comments

Comments
 (0)