Skip to content

[Clang][NFC] improve RewriteModernObjC code quality by using const reference for function parameters #93252

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
merged 2 commits into from
Jul 2, 2024
Merged
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
37 changes: 18 additions & 19 deletions clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,15 +465,15 @@ namespace {

std::string SynthesizeByrefCopyDestroyHelper(VarDecl *VD, int flag);
std::string SynthesizeBlockHelperFuncs(BlockExpr *CE, int i,
StringRef funcName, std::string Tag);
std::string SynthesizeBlockFunc(BlockExpr *CE, int i,
StringRef funcName, std::string Tag);
std::string SynthesizeBlockImpl(BlockExpr *CE,
std::string Tag, std::string Desc);
std::string SynthesizeBlockDescriptor(std::string DescTag,
std::string ImplTag,
int i, StringRef funcName,
unsigned hasCopy);
StringRef funcName,
const std::string &Tag);
std::string SynthesizeBlockFunc(BlockExpr *CE, int i, StringRef funcName,
const std::string &Tag);
std::string SynthesizeBlockImpl(BlockExpr *CE, const std::string &Tag,
const std::string &Desc);
std::string SynthesizeBlockDescriptor(const std::string &DescTag,
const std::string &ImplTag, int i,
StringRef funcName, unsigned hasCopy);
Stmt *SynthesizeBlockCall(CallExpr *Exp, const Expr* BlockExp);
void SynthesizeBlockLiterals(SourceLocation FunLocStart,
StringRef FunName);
Expand Down Expand Up @@ -4037,7 +4037,7 @@ static bool HasLocalVariableExternalStorage(ValueDecl *VD) {

std::string RewriteModernObjC::SynthesizeBlockFunc(BlockExpr *CE, int i,
StringRef funcName,
std::string Tag) {
const std::string &Tag) {
const FunctionType *AFT = CE->getFunctionType();
QualType RT = AFT->getReturnType();
std::string StructRef = "struct " + Tag;
Expand Down Expand Up @@ -4131,9 +4131,8 @@ std::string RewriteModernObjC::SynthesizeBlockFunc(BlockExpr *CE, int i,
return S;
}

std::string RewriteModernObjC::SynthesizeBlockHelperFuncs(BlockExpr *CE, int i,
StringRef funcName,
std::string Tag) {
std::string RewriteModernObjC::SynthesizeBlockHelperFuncs(
BlockExpr *CE, int i, StringRef funcName, const std::string &Tag) {
std::string StructRef = "struct " + Tag;
std::string S = "static void __";

Expand Down Expand Up @@ -4175,8 +4174,9 @@ std::string RewriteModernObjC::SynthesizeBlockHelperFuncs(BlockExpr *CE, int i,
return S;
}

std::string RewriteModernObjC::SynthesizeBlockImpl(BlockExpr *CE, std::string Tag,
std::string Desc) {
std::string RewriteModernObjC::SynthesizeBlockImpl(BlockExpr *CE,
const std::string &Tag,
const std::string &Desc) {
std::string S = "\nstruct " + Tag;
std::string Constructor = " " + Tag;

Expand Down Expand Up @@ -4290,10 +4290,9 @@ std::string RewriteModernObjC::SynthesizeBlockImpl(BlockExpr *CE, std::string Ta
return S;
}

std::string RewriteModernObjC::SynthesizeBlockDescriptor(std::string DescTag,
std::string ImplTag, int i,
StringRef FunName,
unsigned hasCopy) {
std::string RewriteModernObjC::SynthesizeBlockDescriptor(
const std::string &DescTag, const std::string &ImplTag, int i,
StringRef FunName, unsigned hasCopy) {
std::string S = "\nstatic struct " + DescTag;

S += " {\n size_t reserved;\n";
Expand Down
Loading