Skip to content

Commit 136b541

Browse files
[clang] Replace SmallSet with SmallPtrSet (NFC) (#154262)
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 30 instances that rely on this "redirection", with about half of them under clang/. 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 965b7c2 commit 136b541

File tree

15 files changed

+17
-17
lines changed

15 files changed

+17
-17
lines changed

clang/include/clang/AST/CXXInheritance.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ class CXXFinalOverriderMap
359359

360360
/// A set of all the primary bases for a class.
361361
class CXXIndirectPrimaryBaseSet
362-
: public llvm::SmallSet<const CXXRecordDecl*, 32> {};
362+
: public llvm::SmallPtrSet<const CXXRecordDecl *, 32> {};
363363

364364
inline bool
365365
inheritanceModelHasVBPtrOffsetField(MSInheritanceModel Inheritance) {

clang/include/clang/Sema/ScopeInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ class LambdaScopeInfo final :
933933
/// to local variables that are usable as constant expressions and
934934
/// do not involve an odr-use (they may still need to be captured
935935
/// if the enclosing full-expression is instantiation dependent).
936-
llvm::SmallSet<Expr *, 8> NonODRUsedCapturingExprs;
936+
llvm::SmallPtrSet<Expr *, 8> NonODRUsedCapturingExprs;
937937

938938
/// A map of explicit capture indices to their introducer source ranges.
939939
llvm::DenseMap<unsigned, SourceRange> ExplicitCaptureRanges;

clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ class PathSensitiveBugReport : public BugReport {
320320

321321
/// A set of location contexts that correspoind to call sites which should be
322322
/// considered "interesting".
323-
llvm::SmallSet<const LocationContext *, 2> InterestingLocationContexts;
323+
llvm::SmallPtrSet<const LocationContext *, 2> InterestingLocationContexts;
324324

325325
/// A set of custom visitors which generate "event" diagnostics at
326326
/// interesting points in the path.
@@ -348,7 +348,7 @@ class PathSensitiveBugReport : public BugReport {
348348
llvm::SmallSet<InvalidationRecord, 4> Invalidations;
349349

350350
/// Conditions we're already tracking.
351-
llvm::SmallSet<const ExplodedNode *, 4> TrackedConditions;
351+
llvm::SmallPtrSet<const ExplodedNode *, 4> TrackedConditions;
352352

353353
/// Reports with different uniqueing locations are considered to be different
354354
/// for the purposes of deduplication.

clang/lib/Analysis/UnsafeBufferUsage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2256,7 +2256,7 @@ namespace {
22562256
// declarations to its uses and make sure we've covered all uses with our
22572257
// analysis before we try to fix the declaration.
22582258
class DeclUseTracker {
2259-
using UseSetTy = llvm::SmallSet<const DeclRefExpr *, 16>;
2259+
using UseSetTy = llvm::SmallPtrSet<const DeclRefExpr *, 16>;
22602260
using DefMapTy = llvm::DenseMap<const VarDecl *, const DeclStmt *>;
22612261

22622262
// Allocate on the heap for easier move.

clang/lib/Parse/ParseDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7394,7 +7394,7 @@ void Parser::ParseFunctionDeclaratorIdentifierList(
73947394
Diag(Tok, diag::ext_ident_list_in_param);
73957395

73967396
// Maintain an efficient lookup of params we have seen so far.
7397-
llvm::SmallSet<const IdentifierInfo*, 16> ParamsSoFar;
7397+
llvm::SmallPtrSet<const IdentifierInfo *, 16> ParamsSoFar;
73987398

73997399
do {
74007400
// If this isn't an identifier, report the error and skip until ')'.

clang/lib/Sema/HeuristicResolver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class HeuristicResolverImpl {
5757
ASTContext &Ctx;
5858

5959
// Recursion protection sets
60-
llvm::SmallSet<const DependentNameType *, 4> SeenDependentNameTypes;
60+
llvm::SmallPtrSet<const DependentNameType *, 4> SeenDependentNameTypes;
6161

6262
// Given a tag-decl type and a member name, heuristically resolve the
6363
// name to one or more declarations.

clang/lib/Sema/Sema.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1434,7 +1434,7 @@ void Sema::ActOnEndOfTranslationUnit() {
14341434
// translation unit contains a file scope declaration of that
14351435
// identifier, with the composite type as of the end of the
14361436
// translation unit, with an initializer equal to 0.
1437-
llvm::SmallSet<VarDecl *, 32> Seen;
1437+
llvm::SmallPtrSet<VarDecl *, 32> Seen;
14381438
for (TentativeDefinitionsType::iterator
14391439
T = TentativeDefinitions.begin(ExternalSource.get()),
14401440
TEnd = TentativeDefinitions.end();

clang/lib/Sema/SemaDeclCXX.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2151,7 +2151,7 @@ static bool CheckConstexprDeclStmt(Sema &SemaRef, const FunctionDecl *Dcl,
21512151
static bool CheckConstexprCtorInitializer(Sema &SemaRef,
21522152
const FunctionDecl *Dcl,
21532153
FieldDecl *Field,
2154-
llvm::SmallSet<Decl*, 16> &Inits,
2154+
llvm::SmallPtrSet<Decl *, 16> &Inits,
21552155
bool &Diagnosed,
21562156
Sema::CheckConstexprKind Kind) {
21572157
// In C++20 onwards, there's nothing to check for validity.
@@ -2473,7 +2473,7 @@ static bool CheckConstexprFunctionBody(Sema &SemaRef, const FunctionDecl *Dcl,
24732473
// Check initialization of non-static data members. Base classes are
24742474
// always initialized so do not need to be checked. Dependent bases
24752475
// might not have initializers in the member initializer list.
2476-
llvm::SmallSet<Decl*, 16> Inits;
2476+
llvm::SmallPtrSet<Decl *, 16> Inits;
24772477
for (const auto *I: Constructor->inits()) {
24782478
if (FieldDecl *FD = I->getMember())
24792479
Inits.insert(FD);

clang/lib/Sema/SemaExprCXX.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ collectPublicBases(CXXRecordDecl *RD,
946946
static void getUnambiguousPublicSubobjects(
947947
CXXRecordDecl *RD, llvm::SmallVectorImpl<CXXRecordDecl *> &Objects) {
948948
llvm::DenseMap<CXXRecordDecl *, unsigned> SubobjectsSeen;
949-
llvm::SmallSet<CXXRecordDecl *, 2> VBases;
949+
llvm::SmallPtrSet<CXXRecordDecl *, 2> VBases;
950950
llvm::SetVector<CXXRecordDecl *> PublicSubobjectsSeen;
951951
SubobjectsSeen[RD] = 1;
952952
PublicSubobjectsSeen.insert(RD);

clang/lib/Sema/SemaModule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ makeTransitiveImportsVisible(ASTContext &Ctx, VisibleModuleSet &VisibleModules,
137137
"modules only.");
138138

139139
llvm::SmallVector<Module *, 4> Worklist;
140-
llvm::SmallSet<Module *, 16> Visited;
140+
llvm::SmallPtrSet<Module *, 16> Visited;
141141
Worklist.push_back(Imported);
142142

143143
Module *FoundPrimaryModuleInterface =

0 commit comments

Comments
 (0)