Skip to content

Commit 2b8a053

Browse files
committed
Refactoring: replace push by emplace where temporaries are passed
Found using clang-tidy's modernize-use-emplace check
1 parent eb11063 commit 2b8a053

23 files changed

+169
-168
lines changed

src/classdef.cpp

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ void ClassDefImpl::insertBaseClass(ClassDef *cd,const QCString &n,Protection p,
882882
Specifier s,const QCString &t)
883883
{
884884
//printf("*** insert base class %s into %s\n",qPrint(cd->name()),qPrint(name()));
885-
m_impl->inherits.push_back(BaseClassDef(cd,n,p,s,t));
885+
m_impl->inherits.emplace_back(cd,n,p,s,t);
886886
m_impl->isSimple = FALSE;
887887
}
888888

@@ -893,7 +893,7 @@ void ClassDefImpl::insertSubClass(ClassDef *cd,Protection p,
893893
//printf("*** insert sub class %s into %s\n",qPrint(cd->name()),qPrint(name()));
894894
bool extractPrivate = Config_getBool(EXTRACT_PRIVATE);
895895
if (!extractPrivate && cd->protection()==Protection::Private) return;
896-
m_impl->inheritedBy.push_back(BaseClassDef(cd,QCString(),p,s,t));
896+
m_impl->inheritedBy.emplace_back(cd,QCString(),p,s,t);
897897
m_impl->isSimple = FALSE;
898898
}
899899

@@ -1282,9 +1282,9 @@ static void writeInheritanceSpecifier(OutputList &ol,const BaseClassDef &bcd)
12821282
ol.startTypewriter();
12831283
ol.docify(" [");
12841284
StringVector sl;
1285-
if (bcd.prot==Protection::Protected) sl.push_back("protected");
1286-
else if (bcd.prot==Protection::Private) sl.push_back("private");
1287-
if (bcd.virt==Specifier::Virtual) sl.push_back("virtual");
1285+
if (bcd.prot==Protection::Protected) sl.emplace_back("protected");
1286+
else if (bcd.prot==Protection::Private) sl.emplace_back("private");
1287+
if (bcd.virt==Specifier::Virtual) sl.emplace_back("virtual");
12881288
bool first=true;
12891289
for (const auto &s : sl)
12901290
{
@@ -2535,11 +2535,11 @@ void ClassDefImpl::writeDeclarationLink(OutputList &ol,bool &found,const QCStrin
25352535
void ClassDefImpl::addClassAttributes(OutputList &ol) const
25362536
{
25372537
StringVector sl;
2538-
if (isFinal()) sl.push_back("final");
2539-
if (isSealed()) sl.push_back("sealed");
2540-
if (isAbstract()) sl.push_back("abstract");
2541-
if (isExported()) sl.push_back("export");
2542-
if (getLanguage()==SrcLangExt::IDL && isPublished()) sl.push_back("published");
2538+
if (isFinal()) sl.emplace_back("final");
2539+
if (isSealed()) sl.emplace_back("sealed");
2540+
if (isAbstract()) sl.emplace_back("abstract");
2541+
if (isExported()) sl.emplace_back("export");
2542+
if (getLanguage()==SrcLangExt::IDL && isPublished()) sl.emplace_back("published");
25432543

25442544
for (const auto &sx : m_impl->qualifiers)
25452545
{
@@ -3130,35 +3130,35 @@ void ClassDefImpl::writeMemberList(OutputList &ol) const
31303130
{
31313131
sl.push_back(theTranslator->trVhdlType(md->getVhdlSpecifiers(),TRUE).str()); //append vhdl type
31323132
}
3133-
else if (md->isFriend()) sl.push_back("friend");
3134-
else if (md->isRelated()) sl.push_back("related");
3133+
else if (md->isFriend()) sl.emplace_back("friend");
3134+
else if (md->isRelated()) sl.emplace_back("related");
31353135
else
31363136
{
31373137
if (Config_getBool(INLINE_INFO) && md->isInline())
3138-
sl.push_back("inline");
3139-
if (md->isExplicit()) sl.push_back("explicit");
3140-
if (md->isMutable()) sl.push_back("mutable");
3141-
if (prot==Protection::Protected) sl.push_back("protected");
3142-
else if (prot==Protection::Private) sl.push_back("private");
3143-
else if (prot==Protection::Package) sl.push_back("package");
3138+
sl.emplace_back("inline");
3139+
if (md->isExplicit()) sl.emplace_back("explicit");
3140+
if (md->isMutable()) sl.emplace_back("mutable");
3141+
if (prot==Protection::Protected) sl.emplace_back("protected");
3142+
else if (prot==Protection::Private) sl.emplace_back("private");
3143+
else if (prot==Protection::Package) sl.emplace_back("package");
31443144
if (virt==Specifier::Virtual && getLanguage()!=SrcLangExt::ObjC)
3145-
sl.push_back("virtual");
3146-
else if (virt==Specifier::Pure) sl.push_back("pure virtual");
3147-
if (md->isStatic()) sl.push_back("static");
3148-
if (md->isSignal()) sl.push_back("signal");
3149-
if (md->isSlot()) sl.push_back("slot");
3145+
sl.emplace_back("virtual");
3146+
else if (virt==Specifier::Pure) sl.emplace_back("pure virtual");
3147+
if (md->isStatic()) sl.emplace_back("static");
3148+
if (md->isSignal()) sl.emplace_back("signal");
3149+
if (md->isSlot()) sl.emplace_back("slot");
31503150
// this is the extra member page
3151-
if (md->isOptional()) sl.push_back("optional");
3152-
if (md->isAttribute()) sl.push_back("attribute");
3153-
if (md->isUNOProperty()) sl.push_back("property");
3154-
if (md->isReadonly()) sl.push_back("readonly");
3155-
if (md->isBound()) sl.push_back("bound");
3156-
if (md->isRemovable()) sl.push_back("removable");
3157-
if (md->isConstrained()) sl.push_back("constrained");
3158-
if (md->isTransient()) sl.push_back("transient");
3159-
if (md->isMaybeVoid()) sl.push_back("maybevoid");
3160-
if (md->isMaybeDefault()) sl.push_back("maybedefault");
3161-
if (md->isMaybeAmbiguous()) sl.push_back("maybeambiguous");
3151+
if (md->isOptional()) sl.emplace_back("optional");
3152+
if (md->isAttribute()) sl.emplace_back("attribute");
3153+
if (md->isUNOProperty()) sl.emplace_back("property");
3154+
if (md->isReadonly()) sl.emplace_back("readonly");
3155+
if (md->isBound()) sl.emplace_back("bound");
3156+
if (md->isRemovable()) sl.emplace_back("removable");
3157+
if (md->isConstrained()) sl.emplace_back("constrained");
3158+
if (md->isTransient()) sl.emplace_back("transient");
3159+
if (md->isMaybeVoid()) sl.emplace_back("maybevoid");
3160+
if (md->isMaybeDefault()) sl.emplace_back("maybedefault");
3161+
if (md->isMaybeAmbiguous()) sl.emplace_back("maybeambiguous");
31623162
}
31633163
bool firstSpan=true;
31643164
for (const auto &s : sl)
@@ -4093,7 +4093,7 @@ ClassDef *ClassDefImpl::insertTemplateInstance(const QCString &fileName,
40934093
templateClass->setOuterScope(getOuterScope());
40944094
templateClass->setHidden(isHidden());
40954095
templateClass->setArtificial(isArtificial());
4096-
m_impl->templateInstances.push_back(TemplateInstanceDef(templSpec,templateClass));
4096+
m_impl->templateInstances.emplace_back(templSpec,templateClass);
40974097

40984098
// also add nested classes
40994099
for (const auto &innerCd : m_impl->innerClasses)

src/code.l

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ ENDQopt ("const"|"volatile"|"sealed"|"override")({BN}+("const"|"volatile"|"seale
823823
var.localDef()->insertBaseClass(bcd->name());
824824
}
825825
}
826-
yyextra->codeClassMap.emplace(std::make_pair(yyextra->curClassName.str(),std::move(var)));
826+
yyextra->codeClassMap.emplace(yyextra->curClassName.str(),std::move(var));
827827
}
828828
//printf("yyextra->codeClassList.count()=%d\n",yyextra->codeClassList.count());
829829
}
@@ -843,7 +843,7 @@ ENDQopt ("const"|"volatile"|"sealed"|"override")({BN}+("const"|"volatile"|"seale
843843
}
844844
<Bases>{SEP}?({ID}{SEP})*{ID} {
845845
DBG_CTX((stderr,"%s:addBase(%s)\n",qPrint(yyextra->curClassName),yytext));
846-
yyextra->curClassBases.push_back(yytext);
846+
yyextra->curClassBases.emplace_back(yytext);
847847
generateClassOrGlobalLink(yyscanner,*yyextra->code,yytext);
848848
}
849849
<Bases>"<" {
@@ -3928,7 +3928,7 @@ static QCString escapeName(yyscan_t yyscanner,const char *s)
39283928
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
39293929
QCString result;
39303930
result.sprintf("$n%d",yyextra->currentNameId);
3931-
yyextra->nameMap.emplace(std::make_pair(yyextra->currentNameId,s));
3931+
yyextra->nameMap.emplace(yyextra->currentNameId,s);
39323932
yyextra->currentNameId++;
39333933
return result;
39343934
}
@@ -3938,7 +3938,7 @@ static QCString escapeObject(yyscan_t yyscanner,const char *s)
39383938
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
39393939
QCString result;
39403940
result.sprintf("$o%d",yyextra->currentObjId);
3941-
yyextra->objectMap.emplace(std::make_pair(yyextra->currentObjId,s));
3941+
yyextra->objectMap.emplace(yyextra->currentObjId,s);
39423942
yyextra->currentObjId++;
39433943
return result;
39443944
}
@@ -3948,7 +3948,7 @@ static QCString escapeWord(yyscan_t yyscanner,const char *s)
39483948
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
39493949
QCString result;
39503950
result.sprintf("$w%d",yyextra->currentWordId);
3951-
yyextra->wordMap.emplace(std::make_pair(yyextra->currentWordId,s));
3951+
yyextra->wordMap.emplace(yyextra->currentWordId,s);
39523952
yyextra->currentWordId++;
39533953
return result;
39543954
}
@@ -3958,7 +3958,7 @@ static QCString escapeComment(yyscan_t yyscanner,const char *s)
39583958
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
39593959
QCString result;
39603960
result.sprintf("$d%d",yyextra->currentCommentId);
3961-
yyextra->commentMap.emplace(std::make_pair(yyextra->currentCommentId,s));
3961+
yyextra->commentMap.emplace(yyextra->currentCommentId,s);
39623962
yyextra->currentCommentId++;
39633963
return result;
39643964
}
@@ -4055,7 +4055,7 @@ static void saveObjCContext(yyscan_t yyscanner)
40554055
newCtx->method = 0;
40564056
DBG_CTX((stderr,"save state=%d\n",YY_START));
40574057
yyextra->currentCtx = newCtx.get();
4058-
yyextra->contextMap.emplace(std::make_pair(yyextra->currentCtxId,std::move(newCtx)));
4058+
yyextra->contextMap.emplace(yyextra->currentCtxId,std::move(newCtx));
40594059
yyextra->braceCount = 0;
40604060
yyextra->currentCtxId++;
40614061
}

src/commentcnv.l

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1490,7 +1490,7 @@ static void startCondSection(yyscan_t yyscanner,const QCString &sectId)
14901490
//printf("startCondSection: skip=%d stack=%d\n",g_skip,g_condStack.count());
14911491
CondParser prs;
14921492
bool expResult = prs.parse(yyextra->fileName,yyextra->lineNr,sectId);
1493-
yyextra->condStack.push(commentcnvYY_CondCtx(yyextra->lineNr,sectId,yyextra->skip));
1493+
yyextra->condStack.emplace(yyextra->lineNr,sectId,yyextra->skip);
14941494
if (!expResult) // not enabled
14951495
{
14961496
yyextra->skip=TRUE;

src/commentscan.l

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1693,7 +1693,7 @@ STopt [^\n@\\]*
16931693

16941694
/* ----- handle arguments of the qualifier command ----- */
16951695
<Qualifier>{LABELID} { // unquoted version, simple label
1696-
yyextra->current->qualifiers.push_back(yytext);
1696+
yyextra->current->qualifiers.emplace_back(yytext);
16971697
BEGIN( Comment );
16981698
}
16991699
<Qualifier>"\""[^\"]*"\"" { // quotes version, add without quotes
@@ -2084,7 +2084,7 @@ STopt [^\n@\\]*
20842084
addOutput(yyscanner,yytext);
20852085
// we add subpage labels as a kind of "inheritance" relation to prevent
20862086
// needing to add another list to the Entry class.
2087-
yyextra->current->extends.push_back(BaseInfo(QCString(yytext),Protection::Public,Specifier::Normal));
2087+
yyextra->current->extends.emplace_back(QCString(yytext),Protection::Public,Specifier::Normal);
20882088
BEGIN(SubpageTitle);
20892089
}
20902090
<SubpageLabel>{DOCNL} { // missing argument
@@ -2292,12 +2292,12 @@ STopt [^\n@\\]*
22922292

22932293
<SkipGuardedSection>{CMD}"ifnot"/{NW} {
22942294
yyextra->guardType = Guard_IfNot;
2295-
yyextra->guards.push(GuardedSection(false));
2295+
yyextra->guards.emplace(false);
22962296
BEGIN( GuardParam );
22972297
}
22982298
<SkipGuardedSection>{CMD}"if"/{NW} {
22992299
yyextra->guardType = Guard_If;
2300-
yyextra->guards.push(GuardedSection(false));
2300+
yyextra->guards.emplace(false);
23012301
BEGIN( GuardParam );
23022302
}
23032303
<SkipGuardedSection>{CMD}"endif"/{NW} {
@@ -2523,8 +2523,8 @@ STopt [^\n@\\]*
25232523
/* ----- handle argument of ingroup command ------- */
25242524

25252525
<InGroupParam>{LABELID} { // group id
2526-
yyextra->current->groups.push_back(
2527-
Grouping(QCString(yytext), Grouping::GROUPING_INGROUP)
2526+
yyextra->current->groups.emplace_back(
2527+
QCString(yytext), Grouping::GROUPING_INGROUP
25282528
);
25292529
yyextra->inGroupParamFound=TRUE;
25302530
}
@@ -2617,8 +2617,8 @@ STopt [^\n@\\]*
26172617
/* ----- handle argument of inherit command ------- */
26182618

26192619
<InheritParam>({ID}("::"|"."))*{ID} { // found argument
2620-
yyextra->current->extends.push_back(
2621-
BaseInfo(removeRedundantWhiteSpace(QCString(yytext)),Protection::Public,Specifier::Normal)
2620+
yyextra->current->extends.emplace_back(
2621+
removeRedundantWhiteSpace(QCString(yytext)),Protection::Public,Specifier::Normal
26222622
);
26232623
BEGIN( Comment );
26242624
}
@@ -2640,8 +2640,8 @@ STopt [^\n@\\]*
26402640
/* ----- handle argument of extends and implements commands ------- */
26412641

26422642
<ExtendsParam>({ID}("::"|"."))*{ID} { // found argument
2643-
yyextra->current->extends.push_back(
2644-
BaseInfo(removeRedundantWhiteSpace(QCString(yytext)),Protection::Public,Specifier::Normal)
2643+
yyextra->current->extends.emplace_back(
2644+
removeRedundantWhiteSpace(QCString(yytext)),Protection::Public,Specifier::Normal
26452645
);
26462646
BEGIN( Comment );
26472647
}
@@ -3488,12 +3488,12 @@ static bool handleIf(yyscan_t yyscanner,const QCString &, const StringVector &)
34883488
yyextra->spaceBeforeIf = yyextra->spaceBeforeCmd;
34893489
if (yyextra->guards.empty())
34903490
{
3491-
yyextra->guards.push(GuardedSection(true));
3491+
yyextra->guards.emplace(true);
34923492
}
34933493
else
34943494
{
34953495
bool enabled = yyextra->guards.top().isEnabled();
3496-
yyextra->guards.push(GuardedSection(enabled));
3496+
yyextra->guards.emplace(enabled);
34973497
}
34983498
BEGIN(GuardParam);
34993499
return FALSE;
@@ -3506,12 +3506,12 @@ static bool handleIfNot(yyscan_t yyscanner,const QCString &, const StringVector
35063506
yyextra->spaceBeforeIf = yyextra->spaceBeforeCmd;
35073507
if (yyextra->guards.empty())
35083508
{
3509-
yyextra->guards.push(GuardedSection(true));
3509+
yyextra->guards.emplace(true);
35103510
}
35113511
else
35123512
{
35133513
bool enabled = yyextra->guards.top().isEnabled();
3514-
yyextra->guards.push(GuardedSection(enabled));
3514+
yyextra->guards.emplace(enabled);
35153515
}
35163516
BEGIN(GuardParam);
35173517
return FALSE;

src/configimpl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class ConfigList : public ConfigOption
131131
m_doc = doc;
132132
m_widgetType = String;
133133
}
134-
void addValue(const char *v) { m_defaultValue.push_back(v); }
134+
void addValue(const char *v) { m_defaultValue.emplace_back(v); }
135135
void setWidgetType(WidgetType w) { m_widgetType = w; }
136136
WidgetType widgetType() const { return m_widgetType; }
137137
StringVector *valueRef() { return &m_value; }
@@ -163,7 +163,7 @@ class ConfigEnum : public ConfigOption
163163
m_value = defVal;
164164
m_defValue = defVal;
165165
}
166-
void addValue(const char *v) { m_valueRange.push_back(v); }
166+
void addValue(const char *v) { m_valueRange.emplace_back(v); }
167167
const std::vector<QCString> &values() const { return m_valueRange; }
168168
QCString *valueRef() { return &m_value; }
169169
void substEnvVars();

src/docgroup.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ void DocGroup::open(Entry *e,const QCString &,int, bool implicit)
112112
// qPrint(e->name),e->section,m_autoGroupStack.size());
113113
if (e->section.isGroupDoc()) // auto group
114114
{
115-
m_autoGroupStack.push_back(Grouping(e->name,e->groupingPri()));
115+
m_autoGroupStack.emplace_back(e->name,e->groupingPri());
116116
}
117117
else // start of a member group
118118
{
@@ -194,7 +194,7 @@ void DocGroup::initGroupInfo(Entry *e)
194194
//printf("Appending group %s to %s: count=%zu entry=%p\n",
195195
// qPrint(m_autoGroupStack.back().groupname),
196196
// qPrint(e->name),e->groups.size(),(void*)e);
197-
e->groups.push_back(Grouping(m_autoGroupStack.back()));
197+
e->groups.emplace_back(m_autoGroupStack.back());
198198
}
199199
}
200200

src/docparser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void DocParser::pushContext()
6363
//printf("%sdocParserPushContext() count=%zu\n",qPrint(indent),context.nodeStack.size());
6464

6565
tokenizer.pushContext();
66-
contextStack.push(DocParserContext());
66+
contextStack.emplace();
6767
auto &ctx = contextStack.top();
6868
ctx = context;
6969
ctx.lineNo = tokenizer.getLineNr();

src/dot.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ DotFilePatcher *DotManager::createFilePatcher(const QCString &fileName)
120120

121121
if (patcher != m_filePatchers.end()) return &(patcher->second);
122122

123-
auto rv = m_filePatchers.emplace(std::make_pair(fileName.str(), fileName));
123+
auto rv = m_filePatchers.emplace(fileName.str(), fileName);
124124
assert(rv.second);
125125
return &(rv.first->second);
126126
}

src/doxygen.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,7 +1354,7 @@ static void resolveClassNestingRelations()
13541354
{
13551355
auto aliasCd = createClassDefAlias(d,cd);
13561356
QCString aliasFullName = d->qualifiedName()+"::"+aliasCd->localName();
1357-
aliases.push_back(ClassAlias(aliasFullName,std::move(aliasCd),dm));
1357+
aliases.emplace_back(aliasFullName,std::move(aliasCd),dm);
13581358
//printf("adding %s to %s as %s\n",qPrint(aliasCd->name()),qPrint(d->name()),qPrint(aliasFullName));
13591359
}
13601360
}
@@ -7288,7 +7288,7 @@ static void addEnumValuesToEnums(const Entry *root)
72887288
fmmd->setAnchor();
72897289
md->insertEnumField(fmd.get());
72907290
fmmd->setEnumScope(md,TRUE);
7291-
extraMembers.push_back(EnumValueInfo(e->name,std::move(fmd)));
7291+
extraMembers.emplace_back(e->name,std::move(fmd));
72927292
}
72937293
}
72947294
else
@@ -11420,7 +11420,7 @@ void adjustConfiguration()
1142011420
portable_iconv_close(cd);
1142111421
}
1142211422

11423-
Doxygen::inputFileEncodingList.push_back(InputFileEncoding(pattern, encoding));
11423+
Doxygen::inputFileEncodingList.emplace_back(pattern, encoding);
1142411424
}
1142511425
}
1142611426

src/fortrancode.l

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1371,7 +1371,7 @@ static void startScope(yyscan_t yyscanner)
13711371
{
13721372
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
13731373
DBG_CTX((stderr, "===> startScope %s",yytext));
1374-
yyextra->scopeStack.push_back(Scope());
1374+
yyextra->scopeStack.emplace_back();
13751375
}
13761376

13771377
/** end scope */

0 commit comments

Comments
 (0)