[clang] 64e7cb2 - [Rewrite] Use auto (NFC)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 23 19:47:49 PDT 2024
Author: Kazu Hirata
Date: 2024-09-23T19:47:41-07:00
New Revision: 64e7cb266e54e689791ad499965ddb0f8a1a2262
URL: https://github.com/llvm/llvm-project/commit/64e7cb266e54e689791ad499965ddb0f8a1a2262
DIFF: https://github.com/llvm/llvm-project/commit/64e7cb266e54e689791ad499965ddb0f8a1a2262.diff
LOG: [Rewrite] Use auto (NFC)
I'm planning to change the type of BlockByCopyDecls and
BlockByRefDecls to SetVector. Declaring these iterators with auto
makes it easier to migrate to the new type.
Added:
Modified:
clang/lib/Frontend/Rewrite/RewriteObjC.cpp
Removed:
################################################################################
diff --git a/clang/lib/Frontend/Rewrite/RewriteObjC.cpp b/clang/lib/Frontend/Rewrite/RewriteObjC.cpp
index ac5baf72a65c90..a1e792bf772ba2 100644
--- a/clang/lib/Frontend/Rewrite/RewriteObjC.cpp
+++ b/clang/lib/Frontend/Rewrite/RewriteObjC.cpp
@@ -3292,8 +3292,8 @@ std::string RewriteObjC::SynthesizeBlockFunc(BlockExpr *CE, int i,
// Create local declarations to avoid rewriting all closure decl ref exprs.
// First, emit a declaration for all "by ref" decls.
- for (SmallVectorImpl<ValueDecl *>::iterator I = BlockByRefDecls.begin(),
- E = BlockByRefDecls.end(); I != E; ++I) {
+ for (auto I = BlockByRefDecls.begin(), E = BlockByRefDecls.end(); I != E;
+ ++I) {
S += " ";
std::string Name = (*I)->getNameAsString();
std::string TypeString;
@@ -3303,8 +3303,8 @@ std::string RewriteObjC::SynthesizeBlockFunc(BlockExpr *CE, int i,
S += Name + " = __cself->" + (*I)->getNameAsString() + "; // bound by ref\n";
}
// Next, emit a declaration for all "by copy" declarations.
- for (SmallVectorImpl<ValueDecl *>::iterator I = BlockByCopyDecls.begin(),
- E = BlockByCopyDecls.end(); I != E; ++I) {
+ for (auto I = BlockByCopyDecls.begin(), E = BlockByCopyDecls.end(); I != E;
+ ++I) {
S += " ";
// Handle nested closure invocation. For example:
//
@@ -3400,8 +3400,8 @@ std::string RewriteObjC::SynthesizeBlockImpl(BlockExpr *CE, std::string Tag,
if (BlockDeclRefs.size()) {
// Output all "by copy" declarations.
- for (SmallVectorImpl<ValueDecl *>::iterator I = BlockByCopyDecls.begin(),
- E = BlockByCopyDecls.end(); I != E; ++I) {
+ for (auto I = BlockByCopyDecls.begin(), E = BlockByCopyDecls.end(); I != E;
+ ++I) {
S += " ";
std::string FieldName = (*I)->getNameAsString();
std::string ArgName = "_" + FieldName;
@@ -3429,8 +3429,8 @@ std::string RewriteObjC::SynthesizeBlockImpl(BlockExpr *CE, std::string Tag,
S += FieldName + ";\n";
}
// Output all "by ref" declarations.
- for (SmallVectorImpl<ValueDecl *>::iterator I = BlockByRefDecls.begin(),
- E = BlockByRefDecls.end(); I != E; ++I) {
+ for (auto I = BlockByRefDecls.begin(), E = BlockByRefDecls.end(); I != E;
+ ++I) {
S += " ";
std::string FieldName = (*I)->getNameAsString();
std::string ArgName = "_" + FieldName;
@@ -3448,8 +3448,8 @@ std::string RewriteObjC::SynthesizeBlockImpl(BlockExpr *CE, std::string Tag,
Constructor += ", int flags=0)";
// Initialize all "by copy" arguments.
bool firsTime = true;
- for (SmallVectorImpl<ValueDecl *>::iterator I = BlockByCopyDecls.begin(),
- E = BlockByCopyDecls.end(); I != E; ++I) {
+ for (auto I = BlockByCopyDecls.begin(), E = BlockByCopyDecls.end(); I != E;
+ ++I) {
std::string Name = (*I)->getNameAsString();
if (firsTime) {
Constructor += " : ";
@@ -3463,8 +3463,8 @@ std::string RewriteObjC::SynthesizeBlockImpl(BlockExpr *CE, std::string Tag,
Constructor += Name + "(_" + Name + ")";
}
// Initialize all "by ref" arguments.
- for (SmallVectorImpl<ValueDecl *>::iterator I = BlockByRefDecls.begin(),
- E = BlockByRefDecls.end(); I != E; ++I) {
+ for (auto I = BlockByRefDecls.begin(), E = BlockByRefDecls.end(); I != E;
+ ++I) {
std::string Name = (*I)->getNameAsString();
if (firsTime) {
Constructor += " : ";
@@ -4439,8 +4439,8 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp,
if (BlockDeclRefs.size()) {
Expr *Exp;
// Output all "by copy" declarations.
- for (SmallVectorImpl<ValueDecl *>::iterator I = BlockByCopyDecls.begin(),
- E = BlockByCopyDecls.end(); I != E; ++I) {
+ for (auto I = BlockByCopyDecls.begin(), E = BlockByCopyDecls.end(); I != E;
+ ++I) {
if (isObjCType((*I)->getType())) {
// FIXME: Conform to ABI ([[obj retain] autorelease]).
FD = SynthBlockInitFunctionDecl((*I)->getName());
@@ -4476,8 +4476,8 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp,
InitExprs.push_back(Exp);
}
// Output all "by ref" declarations.
- for (SmallVectorImpl<ValueDecl *>::iterator I = BlockByRefDecls.begin(),
- E = BlockByRefDecls.end(); I != E; ++I) {
+ for (auto I = BlockByRefDecls.begin(), E = BlockByRefDecls.end(); I != E;
+ ++I) {
ValueDecl *ND = (*I);
std::string Name(ND->getNameAsString());
std::string RecName;
More information about the cfe-commits
mailing list