[clang] [AST] Use llvm::iterator_range::empty (NFC) (PR #151904)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Sun Aug 3 22:57:49 PDT 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/151904
None
>From 707fa648c0cf4de66adf34d307dec3e41559f962 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 3 Aug 2025 11:23:05 -0700
Subject: [PATCH] [AST] Use llvm::iterator_range::empty (NFC)
---
clang/lib/AST/ByteCode/Compiler.cpp | 2 +-
clang/lib/AST/ByteCode/Context.cpp | 2 +-
clang/lib/AST/DeclCXX.cpp | 2 +-
clang/lib/AST/DeclPrinter.cpp | 8 +++-----
clang/lib/AST/ExprConstant.cpp | 2 +-
clang/lib/AST/QualTypeNames.cpp | 2 +-
6 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index 6e451acd4b6b4..a1d82f52e67e6 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -5895,7 +5895,7 @@ bool Compiler<Emitter>::emitLambdaStaticInvokerBody(const CXXMethodDecl *MD) {
const CXXRecordDecl *ClosureClass = MD->getParent();
const CXXMethodDecl *LambdaCallOp = ClosureClass->getLambdaCallOperator();
- assert(ClosureClass->captures_begin() == ClosureClass->captures_end());
+ assert(ClosureClass->captures().empty());
const Function *Func = this->getFunction(LambdaCallOp);
if (!Func)
return false;
diff --git a/clang/lib/AST/ByteCode/Context.cpp b/clang/lib/AST/ByteCode/Context.cpp
index 7215e1dd03ae1..037e17abc6bc3 100644
--- a/clang/lib/AST/ByteCode/Context.cpp
+++ b/clang/lib/AST/ByteCode/Context.cpp
@@ -474,7 +474,7 @@ const Function *Context::getOrCreateFunction(const FunctionDecl *FuncDecl) {
IsLambdaStaticInvoker = true;
const CXXRecordDecl *ClosureClass = MD->getParent();
- assert(ClosureClass->captures_begin() == ClosureClass->captures_end());
+ assert(ClosureClass->captures().empty());
if (ClosureClass->isGenericLambda()) {
const CXXMethodDecl *LambdaCallOp = ClosureClass->getLambdaCallOperator();
assert(MD->isFunctionTemplateSpecialization() &&
diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 673e3f73858c7..037a28c4255f4 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -1983,7 +1983,7 @@ CXXRecordDecl::getVisibleConversionFunctions() const {
ASTContext &Ctx = getASTContext();
ASTUnresolvedSet *Set;
- if (bases_begin() == bases_end()) {
+ if (bases().empty()) {
// If root class, all conversions are visible.
Set = &data().Conversions.get(Ctx);
} else {
diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp
index 9273f5816d5ac..f4265dd07bd46 100644
--- a/clang/lib/AST/DeclPrinter.cpp
+++ b/clang/lib/AST/DeclPrinter.cpp
@@ -1443,7 +1443,7 @@ void DeclPrinter::VisitObjCMethodDecl(ObjCMethodDecl *OMD) {
lastPos = pos + 1;
}
- if (OMD->param_begin() == OMD->param_end())
+ if (OMD->parameters().empty())
Out << name;
if (OMD->isVariadic())
@@ -1480,8 +1480,7 @@ void DeclPrinter::VisitObjCImplementationDecl(ObjCImplementationDecl *OID) {
}
Indentation -= Policy.Indentation;
Out << "}\n";
- }
- else if (SID || (OID->decls_begin() != OID->decls_end())) {
+ } else if (SID || !OID->decls().empty()) {
Out << "\n";
eolnOut = true;
}
@@ -1540,8 +1539,7 @@ void DeclPrinter::VisitObjCInterfaceDecl(ObjCInterfaceDecl *OID) {
}
Indentation -= Policy.Indentation;
Out << "}\n";
- }
- else if (SID || (OID->decls_begin() != OID->decls_end())) {
+ } else if (SID || !OID->decls().empty()) {
Out << "\n";
eolnOut = true;
}
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 20b7c447956b4..3a47fa87b5f77 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -8436,7 +8436,7 @@ class ExprEvaluatorBase
// doesn't have an implicit argument passed in.
const CXXRecordDecl *ClosureClass = MD->getParent();
assert(
- ClosureClass->captures_begin() == ClosureClass->captures_end() &&
+ ClosureClass->captures().empty() &&
"Number of captures must be zero for conversion to function-ptr");
const CXXMethodDecl *LambdaCallOp =
diff --git a/clang/lib/AST/QualTypeNames.cpp b/clang/lib/AST/QualTypeNames.cpp
index b43bcd8d1f1c1..9731b3a1a3e3b 100644
--- a/clang/lib/AST/QualTypeNames.cpp
+++ b/clang/lib/AST/QualTypeNames.cpp
@@ -273,7 +273,7 @@ static NestedNameSpecifier *createNestedNameSpecifierForScopeOf(
//
// Make the situation is 'useable' but looking a bit odd by
// picking a random instance as the declaring context.
- if (ClassTempl->spec_begin() != ClassTempl->spec_end()) {
+ if (!ClassTempl->specializations().empty()) {
Decl = *(ClassTempl->spec_begin());
Outer = dyn_cast<NamedDecl>(Decl);
OuterNS = dyn_cast<NamespaceDecl>(Decl);
More information about the cfe-commits
mailing list