Skip to content

[clang] Use *Set::insert_range (NFC) #133357

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions clang/lib/Analysis/FlowSensitive/ASTOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ static void getFieldsFromClassHierarchy(QualType Type, FieldSet &Fields) {
!Type->isRecordType())
return;

for (const FieldDecl *Field : Type->getAsRecordDecl()->fields())
Fields.insert(Field);
Fields.insert_range(Type->getAsRecordDecl()->fields());
if (auto *CXXRecord = Type->getAsCXXRecordDecl())
for (const CXXBaseSpecifier &Base : CXXRecord->bases())
getFieldsFromClassHierarchy(Base.getType(), Fields);
Expand Down Expand Up @@ -260,15 +259,13 @@ class ReferencedDeclsVisitor : public AnalysisASTVisitor {

bool VisitInitListExpr(InitListExpr *InitList) override {
if (InitList->getType()->isRecordType())
for (const auto *FD : getFieldsForInitListExpr(InitList))
Referenced.Fields.insert(FD);
Referenced.Fields.insert_range(getFieldsForInitListExpr(InitList));
return true;
}

bool VisitCXXParenListInitExpr(CXXParenListInitExpr *ParenInitList) override {
if (ParenInitList->getType()->isRecordType())
for (const auto *FD : getFieldsForInitListExpr(ParenInitList))
Referenced.Fields.insert(FD);
Referenced.Fields.insert_range(getFieldsForInitListExpr(ParenInitList));
return true;
}

Expand Down
5 changes: 2 additions & 3 deletions clang/lib/Basic/TargetID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,8 @@ parseTargetID(const llvm::Triple &T, llvm::StringRef TargetID,
if (Processor.empty())
return std::nullopt;

llvm::SmallSet<llvm::StringRef, 4> AllFeatures;
for (auto &&F : getAllPossibleTargetIDFeatures(T, Processor))
AllFeatures.insert(F);
llvm::SmallSet<llvm::StringRef, 4> AllFeatures(
llvm::from_range, getAllPossibleTargetIDFeatures(T, Processor));

for (auto &&F : *FeatureMap)
if (!AllFeatures.count(F.first()))
Expand Down
6 changes: 2 additions & 4 deletions clang/lib/CodeGen/CGDeclCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -703,8 +703,7 @@ void CodeGenModule::EmitCXXModuleInitFunc(Module *Primary) {
for (auto I : Primary->Exports)
AllImports.insert(I.getPointer());
// Ones that we only import.
for (Module *M : Primary->Imports)
AllImports.insert(M);
AllImports.insert_range(Primary->Imports);
// Ones that we import in the global module fragment or the private module
// fragment.
for (Module *SubM : Primary->submodules()) {
Expand All @@ -714,8 +713,7 @@ void CodeGenModule::EmitCXXModuleInitFunc(Module *Primary) {
assert(SubM->Exports.empty() &&
"The global mdoule fragments and the private module fragments are "
"not allowed to export import modules.");
for (Module *M : SubM->Imports)
AllImports.insert(M);
AllImports.insert_range(SubM->Imports);
}

SmallVector<llvm::Function *, 8> ModuleInits;
Expand Down
5 changes: 2 additions & 3 deletions clang/lib/Sema/SemaChecking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14731,9 +14731,8 @@ static bool isLayoutCompatibleStruct(const ASTContext &C, const RecordDecl *RD1,
/// (C++11 [class.mem] p18)
static bool isLayoutCompatibleUnion(const ASTContext &C, const RecordDecl *RD1,
const RecordDecl *RD2) {
llvm::SmallPtrSet<const FieldDecl *, 8> UnmatchedFields;
for (auto *Field2 : RD2->fields())
UnmatchedFields.insert(Field2);
llvm::SmallPtrSet<const FieldDecl *, 8> UnmatchedFields(llvm::from_range,
RD2->fields());

for (auto *Field1 : RD1->fields()) {
auto I = UnmatchedFields.begin();
Expand Down
8 changes: 3 additions & 5 deletions clang/lib/Sema/SemaObjCProperty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2075,10 +2075,9 @@ void SemaObjC::DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl *IMPDecl,
for (const auto *I : IMPDecl->property_impls())
PropImplMap.insert(I->getPropertyDecl());

llvm::SmallPtrSet<const ObjCMethodDecl *, 8> InsMap;
// Collect property accessors implemented in current implementation.
for (const auto *I : IMPDecl->methods())
InsMap.insert(I);
llvm::SmallPtrSet<const ObjCMethodDecl *, 8> InsMap(llvm::from_range,
IMPDecl->methods());

ObjCCategoryDecl *C = dyn_cast<ObjCCategoryDecl>(CDecl);
ObjCInterfaceDecl *PrimaryClass = nullptr;
Expand All @@ -2089,8 +2088,7 @@ void SemaObjC::DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl *IMPDecl,
// When reporting on missing setter/getters, do not report when
// setter/getter is implemented in category's primary class
// implementation.
for (const auto *I : IMP->methods())
InsMap.insert(I);
InsMap.insert_range(IMP->methods());
}

for (ObjCContainerDecl::PropertyMap::iterator
Expand Down
4 changes: 1 addition & 3 deletions clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1175,9 +1175,7 @@ StringRef OpenCLBuiltinFileEmitterBase::emitTypeExtensionGuards(
// The TypeExtensions are space-separated in the .td file.
SmallVector<StringRef, 2> ExtVec;
TypeExt.split(ExtVec, " ");
for (const auto Ext : ExtVec) {
ExtSet.insert(Ext);
}
ExtSet.insert_range(ExtVec);
}
}

Expand Down
Loading