forked from OSchip/llvm-project
Replace push_back(Constructor(foo)) with emplace_back(foo) for non-trivial types
If the type isn't trivially moveable emplace can skip a potentially expensive move. It also saves a couple of characters. Call sites were found with the ASTMatcher + some semi-automated cleanup. memberCallExpr( argumentCountIs(1), callee(methodDecl(hasName("push_back"))), on(hasType(recordDecl(has(namedDecl(hasName("emplace_back")))))), hasArgument(0, bindTemporaryExpr( hasType(recordDecl(hasNonTrivialDestructor())), has(constructExpr()))), unless(isInTemplateInstantiation())) No functional change intended. llvm-svn: 238601
This commit is contained in:
parent
36cbc0901f
commit
3204b152b5
|
@ -180,14 +180,14 @@ public:
|
|||
/// AddPath - Add the \p Path path to the specified \p Group list.
|
||||
void AddPath(StringRef Path, frontend::IncludeDirGroup Group,
|
||||
bool IsFramework, bool IgnoreSysRoot) {
|
||||
UserEntries.push_back(Entry(Path, Group, IsFramework, IgnoreSysRoot));
|
||||
UserEntries.emplace_back(Path, Group, IsFramework, IgnoreSysRoot);
|
||||
}
|
||||
|
||||
/// AddSystemHeaderPrefix - Override whether \#include directives naming a
|
||||
/// path starting with \p Prefix should be considered as naming a system
|
||||
/// header.
|
||||
void AddSystemHeaderPrefix(StringRef Prefix, bool IsSystemHeader) {
|
||||
SystemHeaderPrefixes.push_back(SystemHeaderPrefix(Prefix, IsSystemHeader));
|
||||
SystemHeaderPrefixes.emplace_back(Prefix, IsSystemHeader);
|
||||
}
|
||||
|
||||
void AddVFSOverlayFile(StringRef Name) {
|
||||
|
|
|
@ -1617,9 +1617,9 @@ private:
|
|||
|
||||
void PushIncludeMacroStack() {
|
||||
assert(CurLexerKind != CLK_CachingLexer && "cannot push a caching lexer");
|
||||
IncludeMacroStack.push_back(IncludeStackInfo(
|
||||
IncludeMacroStack.emplace_back(
|
||||
CurLexerKind, CurSubmodule, std::move(CurLexer), std::move(CurPTHLexer),
|
||||
CurPPLexer, std::move(CurTokenLexer), CurDirLookup));
|
||||
CurPPLexer, std::move(CurTokenLexer), CurDirLookup);
|
||||
CurPPLexer = nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -149,18 +149,14 @@ public:
|
|||
RetainRemappedFileBuffers(false),
|
||||
ObjCXXARCStandardLibrary(ARCXX_nolib) { }
|
||||
|
||||
void addMacroDef(StringRef Name) {
|
||||
Macros.push_back(std::make_pair(Name, false));
|
||||
}
|
||||
void addMacroUndef(StringRef Name) {
|
||||
Macros.push_back(std::make_pair(Name, true));
|
||||
}
|
||||
void addMacroDef(StringRef Name) { Macros.emplace_back(Name, false); }
|
||||
void addMacroUndef(StringRef Name) { Macros.emplace_back(Name, true); }
|
||||
void addRemappedFile(StringRef From, StringRef To) {
|
||||
RemappedFiles.push_back(std::make_pair(From, To));
|
||||
RemappedFiles.emplace_back(From, To);
|
||||
}
|
||||
|
||||
void addRemappedFile(StringRef From, llvm::MemoryBuffer *To) {
|
||||
RemappedFileBuffers.push_back(std::make_pair(From, To));
|
||||
RemappedFileBuffers.emplace_back(From, To);
|
||||
}
|
||||
|
||||
void clearRemappedFiles() {
|
||||
|
|
|
@ -2283,7 +2283,7 @@ bool arcmt::getFileRemappingsFromFileList(
|
|||
continue;
|
||||
}
|
||||
|
||||
remap.push_back(std::make_pair(I->first->getName(), TempFile));
|
||||
remap.emplace_back(I->first->getName(), TempFile);
|
||||
}
|
||||
|
||||
return hasErrorOccurred;
|
||||
|
|
|
@ -592,7 +592,7 @@ unsigned GCCAsmStmt::AnalyzeAsmString(SmallVectorImpl<AsmStringPiece>&Pieces,
|
|||
SourceLocation EndLoc =
|
||||
getAsmString()->getLocationOfByte(CurPtr - StrStart, SM, LO, TI);
|
||||
|
||||
Pieces.push_back(AsmStringPiece(N, Str, BeginLoc, EndLoc));
|
||||
Pieces.emplace_back(N, std::move(Str), BeginLoc, EndLoc);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -626,7 +626,7 @@ unsigned GCCAsmStmt::AnalyzeAsmString(SmallVectorImpl<AsmStringPiece>&Pieces,
|
|||
SourceLocation EndLoc =
|
||||
getAsmString()->getLocationOfByte(NameEnd + 1 - StrStart, SM, LO, TI);
|
||||
|
||||
Pieces.push_back(AsmStringPiece(N, Str, BeginLoc, EndLoc));
|
||||
Pieces.emplace_back(N, std::move(Str), BeginLoc, EndLoc);
|
||||
|
||||
CurPtr = NameEnd+1;
|
||||
continue;
|
||||
|
|
|
@ -912,37 +912,37 @@ MatchFinder::~MatchFinder() {}
|
|||
|
||||
void MatchFinder::addMatcher(const DeclarationMatcher &NodeMatch,
|
||||
MatchCallback *Action) {
|
||||
Matchers.DeclOrStmt.push_back(std::make_pair(NodeMatch, Action));
|
||||
Matchers.DeclOrStmt.emplace_back(NodeMatch, Action);
|
||||
Matchers.AllCallbacks.push_back(Action);
|
||||
}
|
||||
|
||||
void MatchFinder::addMatcher(const TypeMatcher &NodeMatch,
|
||||
MatchCallback *Action) {
|
||||
Matchers.Type.push_back(std::make_pair(NodeMatch, Action));
|
||||
Matchers.Type.emplace_back(NodeMatch, Action);
|
||||
Matchers.AllCallbacks.push_back(Action);
|
||||
}
|
||||
|
||||
void MatchFinder::addMatcher(const StatementMatcher &NodeMatch,
|
||||
MatchCallback *Action) {
|
||||
Matchers.DeclOrStmt.push_back(std::make_pair(NodeMatch, Action));
|
||||
Matchers.DeclOrStmt.emplace_back(NodeMatch, Action);
|
||||
Matchers.AllCallbacks.push_back(Action);
|
||||
}
|
||||
|
||||
void MatchFinder::addMatcher(const NestedNameSpecifierMatcher &NodeMatch,
|
||||
MatchCallback *Action) {
|
||||
Matchers.NestedNameSpecifier.push_back(std::make_pair(NodeMatch, Action));
|
||||
Matchers.NestedNameSpecifier.emplace_back(NodeMatch, Action);
|
||||
Matchers.AllCallbacks.push_back(Action);
|
||||
}
|
||||
|
||||
void MatchFinder::addMatcher(const NestedNameSpecifierLocMatcher &NodeMatch,
|
||||
MatchCallback *Action) {
|
||||
Matchers.NestedNameSpecifierLoc.push_back(std::make_pair(NodeMatch, Action));
|
||||
Matchers.NestedNameSpecifierLoc.emplace_back(NodeMatch, Action);
|
||||
Matchers.AllCallbacks.push_back(Action);
|
||||
}
|
||||
|
||||
void MatchFinder::addMatcher(const TypeLocMatcher &NodeMatch,
|
||||
MatchCallback *Action) {
|
||||
Matchers.TypeLoc.push_back(std::make_pair(NodeMatch, Action));
|
||||
Matchers.TypeLoc.emplace_back(NodeMatch, Action);
|
||||
Matchers.AllCallbacks.push_back(Action);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace ast_matchers {
|
|||
namespace dynamic {
|
||||
Diagnostics::ArgStream Diagnostics::pushContextFrame(ContextType Type,
|
||||
SourceRange Range) {
|
||||
ContextStack.push_back(ContextFrame());
|
||||
ContextStack.emplace_back();
|
||||
ContextFrame& data = ContextStack.back();
|
||||
data.Type = Type;
|
||||
data.Range = Range;
|
||||
|
@ -65,10 +65,10 @@ Diagnostics::ArgStream &Diagnostics::ArgStream::operator<<(const Twine &Arg) {
|
|||
|
||||
Diagnostics::ArgStream Diagnostics::addError(const SourceRange &Range,
|
||||
ErrorType Error) {
|
||||
Errors.push_back(ErrorContent());
|
||||
Errors.emplace_back();
|
||||
ErrorContent &Last = Errors.back();
|
||||
Last.ContextStack = ContextStack;
|
||||
Last.Messages.push_back(ErrorContent::Message());
|
||||
Last.Messages.emplace_back();
|
||||
Last.Messages.back().Range = Range;
|
||||
Last.Messages.back().Type = Error;
|
||||
return ArgStream(&Last.Messages.back().Args);
|
||||
|
|
|
@ -112,7 +112,7 @@ void DiagnosticsEngine::Reset() {
|
|||
|
||||
// Create a DiagState and DiagStatePoint representing diagnostic changes
|
||||
// through command-line.
|
||||
DiagStates.push_back(DiagState());
|
||||
DiagStates.emplace_back();
|
||||
DiagStatePoints.push_back(DiagStatePoint(&DiagStates.back(), FullSourceLoc()));
|
||||
}
|
||||
|
||||
|
|
|
@ -1057,7 +1057,7 @@ llvm::Value *CGObjCGNU::GetSelector(CodeGenFunction &CGF, Selector Sel,
|
|||
SelValue = llvm::GlobalAlias::create(
|
||||
SelectorTy, llvm::GlobalValue::PrivateLinkage,
|
||||
".objc_selector_" + Sel.getAsString(), &TheModule);
|
||||
Types.push_back(TypedSelector(TypeEncoding, SelValue));
|
||||
Types.emplace_back(TypeEncoding, SelValue);
|
||||
}
|
||||
|
||||
if (lval) {
|
||||
|
@ -2121,9 +2121,8 @@ void CGObjCGNU::RegisterAlias(const ObjCCompatibleAliasDecl *OAD) {
|
|||
// Get the class declaration for which the alias is specified.
|
||||
ObjCInterfaceDecl *ClassDecl =
|
||||
const_cast<ObjCInterfaceDecl *>(OAD->getClassInterface());
|
||||
std::string ClassName = ClassDecl->getNameAsString();
|
||||
std::string AliasName = OAD->getNameAsString();
|
||||
ClassAliases.push_back(ClassAliasPair(ClassName,AliasName));
|
||||
ClassAliases.emplace_back(ClassDecl->getNameAsString(),
|
||||
OAD->getNameAsString());
|
||||
}
|
||||
|
||||
void CGObjCGNU::GenerateClass(const ObjCImplementationDecl *OID) {
|
||||
|
|
|
@ -921,13 +921,13 @@ void CodeGenModule::SetFunctionAttributes(GlobalDecl GD, llvm::Function *F,
|
|||
void CodeGenModule::addUsedGlobal(llvm::GlobalValue *GV) {
|
||||
assert(!GV->isDeclaration() &&
|
||||
"Only globals with definition can force usage.");
|
||||
LLVMUsed.push_back(GV);
|
||||
LLVMUsed.emplace_back(GV);
|
||||
}
|
||||
|
||||
void CodeGenModule::addCompilerUsedGlobal(llvm::GlobalValue *GV) {
|
||||
assert(!GV->isDeclaration() &&
|
||||
"Only globals with definition can force usage.");
|
||||
LLVMCompilerUsed.push_back(GV);
|
||||
LLVMCompilerUsed.emplace_back(GV);
|
||||
}
|
||||
|
||||
static void emitUsed(CodeGenModule &CGM, StringRef Name,
|
||||
|
|
|
@ -329,7 +329,7 @@ private:
|
|||
};
|
||||
std::vector<DeferredGlobal> DeferredDeclsToEmit;
|
||||
void addDeferredDeclToEmit(llvm::GlobalValue *GV, GlobalDecl GD) {
|
||||
DeferredDeclsToEmit.push_back(DeferredGlobal(GV, GD));
|
||||
DeferredDeclsToEmit.emplace_back(GV, GD);
|
||||
}
|
||||
|
||||
/// List of alias we have emitted. Used to make sure that what they point to
|
||||
|
@ -876,7 +876,7 @@ public:
|
|||
|
||||
/// Add a destructor and object to add to the C++ global destructor function.
|
||||
void AddCXXDtorEntry(llvm::Constant *DtorFn, llvm::Constant *Object) {
|
||||
CXXGlobalDtors.push_back(std::make_pair(DtorFn, Object));
|
||||
CXXGlobalDtors.emplace_back(DtorFn, Object);
|
||||
}
|
||||
|
||||
/// Create a new runtime function with the specified type and name.
|
||||
|
|
|
@ -6741,7 +6741,7 @@ static bool extractFieldType(SmallVectorImpl<FieldEncoding> &FE,
|
|||
if (Field->isBitField())
|
||||
Enc += ')';
|
||||
Enc += '}';
|
||||
FE.push_back(FieldEncoding(!Field->getName().empty(), Enc));
|
||||
FE.emplace_back(!Field->getName().empty(), Enc);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1878,8 +1878,8 @@ void
|
|||
Driver::generatePrefixedToolNames(const char *Tool, const ToolChain &TC,
|
||||
SmallVectorImpl<std::string> &Names) const {
|
||||
// FIXME: Needs a better variable than DefaultTargetTriple
|
||||
Names.push_back(DefaultTargetTriple + "-" + Tool);
|
||||
Names.push_back(Tool);
|
||||
Names.emplace_back(DefaultTargetTriple + "-" + Tool);
|
||||
Names.emplace_back(Tool);
|
||||
}
|
||||
|
||||
static bool ScanDirForExecutable(SmallString<128> &Dir,
|
||||
|
|
|
@ -5608,7 +5608,7 @@ static void constructHexagonLinkArgs(Compilation &C, const JobAction &JA,
|
|||
for (arg_iterator it = Args.filtered_begin(options::OPT_moslib_EQ),
|
||||
ie = Args.filtered_end(); it != ie; ++it) {
|
||||
(*it)->claim();
|
||||
oslibs.push_back((*it)->getValue());
|
||||
oslibs.emplace_back((*it)->getValue());
|
||||
hasStandalone = hasStandalone || (oslibs.back() == "standalone");
|
||||
}
|
||||
if (oslibs.empty()) {
|
||||
|
|
|
@ -613,7 +613,7 @@ void StoredDiagnosticConsumer::HandleDiagnostic(DiagnosticsEngine::Level Level,
|
|||
// about. This effectively drops diagnostics from modules we're building.
|
||||
// FIXME: In the long run, ee don't want to drop source managers from modules.
|
||||
if (!Info.hasSourceManager() || &Info.getSourceManager() == SourceMgr)
|
||||
StoredDiags.push_back(StoredDiagnostic(Level, Info));
|
||||
StoredDiags.emplace_back(Level, Info);
|
||||
}
|
||||
|
||||
ASTMutationListener *ASTUnit::getASTMutationListener() {
|
||||
|
|
|
@ -946,12 +946,11 @@ static bool compileModuleImpl(CompilerInstance &ImportingInstance,
|
|||
if (const FileEntry *ModuleMapFile =
|
||||
ModMap.getContainingModuleMapFile(Module)) {
|
||||
// Use the module map where this module resides.
|
||||
FrontendOpts.Inputs.push_back(
|
||||
FrontendInputFile(ModuleMapFile->getName(), IK));
|
||||
FrontendOpts.Inputs.emplace_back(ModuleMapFile->getName(), IK);
|
||||
} else {
|
||||
SmallString<128> FakeModuleMapFile(Module->Directory->getName());
|
||||
llvm::sys::path::append(FakeModuleMapFile, "__inferred_module.map");
|
||||
FrontendOpts.Inputs.push_back(FrontendInputFile(FakeModuleMapFile, IK));
|
||||
FrontendOpts.Inputs.emplace_back(FakeModuleMapFile, IK);
|
||||
|
||||
llvm::raw_string_ostream OS(InferredModuleMapContent);
|
||||
Module->print(OS);
|
||||
|
|
|
@ -126,7 +126,7 @@ static void addDiagnosticArgs(ArgList &Args, OptSpecifier Group,
|
|||
} else {
|
||||
// Otherwise, add its value (for OPT_W_Joined and similar).
|
||||
for (const char *Arg : A->getValues())
|
||||
Diagnostics.push_back(Arg);
|
||||
Diagnostics.emplace_back(Arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -250,8 +250,8 @@ static bool ParseAnalyzerArgs(AnalyzerOptions &Opts, ArgList &Args,
|
|||
StringRef checkerList = A->getValue();
|
||||
SmallVector<StringRef, 4> checkers;
|
||||
checkerList.split(checkers, ",");
|
||||
for (unsigned i = 0, e = checkers.size(); i != e; ++i)
|
||||
Opts.CheckersControlList.push_back(std::make_pair(checkers[i], enable));
|
||||
for (StringRef checker : checkers)
|
||||
Opts.CheckersControlList.emplace_back(checker, enable);
|
||||
}
|
||||
|
||||
// Go through the analyzer configuration options.
|
||||
|
@ -867,14 +867,14 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
|
|||
}
|
||||
|
||||
if (const Arg* A = Args.getLastArg(OPT_plugin)) {
|
||||
Opts.Plugins.push_back(A->getValue(0));
|
||||
Opts.Plugins.emplace_back(A->getValue(0));
|
||||
Opts.ProgramAction = frontend::PluginAction;
|
||||
Opts.ActionName = A->getValue();
|
||||
|
||||
for (arg_iterator it = Args.filtered_begin(OPT_plugin_arg),
|
||||
end = Args.filtered_end(); it != end; ++it) {
|
||||
if ((*it)->getValue(0) == Opts.ActionName)
|
||||
Opts.PluginArgs.push_back((*it)->getValue(1));
|
||||
Opts.PluginArgs.emplace_back((*it)->getValue(1));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -884,7 +884,7 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
|
|||
for (arg_iterator it = Args.filtered_begin(OPT_plugin_arg),
|
||||
end = Args.filtered_end(); it != end; ++it) {
|
||||
if ((*it)->getValue(0) == Opts.AddPluginActions[i])
|
||||
Opts.AddPluginArgs[i].push_back((*it)->getValue(1));
|
||||
Opts.AddPluginArgs[i].emplace_back((*it)->getValue(1));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1035,7 +1035,7 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
|
|||
if (i == 0)
|
||||
DashX = IK;
|
||||
}
|
||||
Opts.Inputs.push_back(FrontendInputFile(Inputs[i], IK));
|
||||
Opts.Inputs.emplace_back(std::move(Inputs[i]), IK);
|
||||
}
|
||||
|
||||
return DashX;
|
||||
|
@ -1745,18 +1745,18 @@ static void ParsePreprocessorArgs(PreprocessorOptions &Opts, ArgList &Args,
|
|||
for (arg_iterator it = Args.filtered_begin(OPT_include),
|
||||
ie = Args.filtered_end(); it != ie; ++it) {
|
||||
const Arg *A = *it;
|
||||
Opts.Includes.push_back(A->getValue());
|
||||
Opts.Includes.emplace_back(A->getValue());
|
||||
}
|
||||
|
||||
for (arg_iterator it = Args.filtered_begin(OPT_chain_include),
|
||||
ie = Args.filtered_end(); it != ie; ++it) {
|
||||
const Arg *A = *it;
|
||||
Opts.ChainedIncludes.push_back(A->getValue());
|
||||
Opts.ChainedIncludes.emplace_back(A->getValue());
|
||||
}
|
||||
|
||||
// Include 'altivec.h' if -faltivec option present
|
||||
if (Args.hasArg(OPT_faltivec))
|
||||
Opts.Includes.push_back("altivec.h");
|
||||
Opts.Includes.emplace_back("altivec.h");
|
||||
|
||||
for (arg_iterator it = Args.filtered_begin(OPT_remap_file),
|
||||
ie = Args.filtered_end(); it != ie; ++it) {
|
||||
|
|
|
@ -65,7 +65,7 @@ public:
|
|||
/// AddSystemHeaderPrefix - Add the specified prefix to the system header
|
||||
/// prefix list.
|
||||
void AddSystemHeaderPrefix(StringRef Prefix, bool IsSystemHeader) {
|
||||
SystemHeaderPrefixes.push_back(std::make_pair(Prefix, IsSystemHeader));
|
||||
SystemHeaderPrefixes.emplace_back(Prefix, IsSystemHeader);
|
||||
}
|
||||
|
||||
/// AddGnuCPlusPlusIncludePaths - Add the necessary paths to support a gnu
|
||||
|
|
|
@ -30,17 +30,17 @@ void TextDiagnosticBuffer::HandleDiagnostic(DiagnosticsEngine::Level Level,
|
|||
default: llvm_unreachable(
|
||||
"Diagnostic not handled during diagnostic buffering!");
|
||||
case DiagnosticsEngine::Note:
|
||||
Notes.push_back(std::make_pair(Info.getLocation(), Buf.str()));
|
||||
Notes.emplace_back(Info.getLocation(), Buf.str());
|
||||
break;
|
||||
case DiagnosticsEngine::Warning:
|
||||
Warnings.push_back(std::make_pair(Info.getLocation(), Buf.str()));
|
||||
Warnings.emplace_back(Info.getLocation(), Buf.str());
|
||||
break;
|
||||
case DiagnosticsEngine::Remark:
|
||||
Remarks.push_back(std::make_pair(Info.getLocation(), Buf.str()));
|
||||
Remarks.emplace_back(Info.getLocation(), Buf.str());
|
||||
break;
|
||||
case DiagnosticsEngine::Error:
|
||||
case DiagnosticsEngine::Fatal:
|
||||
Errors.push_back(std::make_pair(Info.getLocation(), Buf.str()));
|
||||
Errors.emplace_back(Info.getLocation(), Buf.str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1463,7 +1463,7 @@ class ThreadSafetyReporter : public clang::threadSafety::ThreadSafetyHandler {
|
|||
PartialDiagnosticAt FNote(CurrentFunction->getBody()->getLocStart(),
|
||||
S.PDiag(diag::note_thread_warning_in_fun)
|
||||
<< CurrentFunction->getNameAsString());
|
||||
ONS.push_back(FNote);
|
||||
ONS.push_back(std::move(FNote));
|
||||
}
|
||||
return ONS;
|
||||
}
|
||||
|
@ -1477,7 +1477,7 @@ class ThreadSafetyReporter : public clang::threadSafety::ThreadSafetyHandler {
|
|||
PartialDiagnosticAt FNote(CurrentFunction->getBody()->getLocStart(),
|
||||
S.PDiag(diag::note_thread_warning_in_fun)
|
||||
<< CurrentFunction->getNameAsString());
|
||||
ONS.push_back(FNote);
|
||||
ONS.push_back(std::move(FNote));
|
||||
}
|
||||
return ONS;
|
||||
}
|
||||
|
@ -1490,7 +1490,7 @@ class ThreadSafetyReporter : public clang::threadSafety::ThreadSafetyHandler {
|
|||
if (!Loc.isValid())
|
||||
Loc = FunLocation;
|
||||
PartialDiagnosticAt Warning(Loc, S.PDiag(DiagID) << Kind << LockName);
|
||||
Warnings.push_back(DelayedDiag(Warning, getNotes()));
|
||||
Warnings.emplace_back(std::move(Warning), getNotes());
|
||||
}
|
||||
|
||||
public:
|
||||
|
@ -1516,7 +1516,7 @@ class ThreadSafetyReporter : public clang::threadSafety::ThreadSafetyHandler {
|
|||
void handleInvalidLockExp(StringRef Kind, SourceLocation Loc) override {
|
||||
PartialDiagnosticAt Warning(Loc, S.PDiag(diag::warn_cannot_resolve_lock)
|
||||
<< Loc);
|
||||
Warnings.push_back(DelayedDiag(Warning, getNotes()));
|
||||
Warnings.emplace_back(std::move(Warning), getNotes());
|
||||
}
|
||||
|
||||
void handleUnmatchedUnlock(StringRef Kind, Name LockName,
|
||||
|
@ -1532,7 +1532,7 @@ class ThreadSafetyReporter : public clang::threadSafety::ThreadSafetyHandler {
|
|||
PartialDiagnosticAt Warning(Loc, S.PDiag(diag::warn_unlock_kind_mismatch)
|
||||
<< Kind << LockName << Received
|
||||
<< Expected);
|
||||
Warnings.push_back(DelayedDiag(Warning, getNotes()));
|
||||
Warnings.emplace_back(std::move(Warning), getNotes());
|
||||
}
|
||||
|
||||
void handleDoubleLock(StringRef Kind, Name LockName, SourceLocation Loc) override {
|
||||
|
@ -1566,10 +1566,10 @@ class ThreadSafetyReporter : public clang::threadSafety::ThreadSafetyHandler {
|
|||
if (LocLocked.isValid()) {
|
||||
PartialDiagnosticAt Note(LocLocked, S.PDiag(diag::note_locked_here)
|
||||
<< Kind);
|
||||
Warnings.push_back(DelayedDiag(Warning, getNotes(Note)));
|
||||
Warnings.emplace_back(std::move(Warning), getNotes(Note));
|
||||
return;
|
||||
}
|
||||
Warnings.push_back(DelayedDiag(Warning, getNotes()));
|
||||
Warnings.emplace_back(std::move(Warning), getNotes());
|
||||
}
|
||||
|
||||
void handleExclusiveAndShared(StringRef Kind, Name LockName,
|
||||
|
@ -1580,7 +1580,7 @@ class ThreadSafetyReporter : public clang::threadSafety::ThreadSafetyHandler {
|
|||
<< Kind << LockName);
|
||||
PartialDiagnosticAt Note(Loc2, S.PDiag(diag::note_lock_exclusive_and_shared)
|
||||
<< Kind << LockName);
|
||||
Warnings.push_back(DelayedDiag(Warning, getNotes(Note)));
|
||||
Warnings.emplace_back(std::move(Warning), getNotes(Note));
|
||||
}
|
||||
|
||||
void handleNoMutexHeld(StringRef Kind, const NamedDecl *D,
|
||||
|
@ -1593,7 +1593,7 @@ class ThreadSafetyReporter : public clang::threadSafety::ThreadSafetyHandler {
|
|||
diag::warn_var_deref_requires_any_lock;
|
||||
PartialDiagnosticAt Warning(Loc, S.PDiag(DiagID)
|
||||
<< D->getNameAsString() << getLockKindFromAccessKind(AK));
|
||||
Warnings.push_back(DelayedDiag(Warning, getNotes()));
|
||||
Warnings.emplace_back(std::move(Warning), getNotes());
|
||||
}
|
||||
|
||||
void handleMutexNotHeld(StringRef Kind, const NamedDecl *D,
|
||||
|
@ -1628,9 +1628,9 @@ class ThreadSafetyReporter : public clang::threadSafety::ThreadSafetyHandler {
|
|||
PartialDiagnosticAt VNote(D->getLocation(),
|
||||
S.PDiag(diag::note_guarded_by_declared_here)
|
||||
<< D->getNameAsString());
|
||||
Warnings.push_back(DelayedDiag(Warning, getNotes(Note, VNote)));
|
||||
Warnings.emplace_back(std::move(Warning), getNotes(Note, VNote));
|
||||
} else
|
||||
Warnings.push_back(DelayedDiag(Warning, getNotes(Note)));
|
||||
Warnings.emplace_back(std::move(Warning), getNotes(Note));
|
||||
} else {
|
||||
switch (POK) {
|
||||
case POK_VarAccess:
|
||||
|
@ -1656,9 +1656,9 @@ class ThreadSafetyReporter : public clang::threadSafety::ThreadSafetyHandler {
|
|||
PartialDiagnosticAt Note(D->getLocation(),
|
||||
S.PDiag(diag::note_guarded_by_declared_here)
|
||||
<< D->getNameAsString());
|
||||
Warnings.push_back(DelayedDiag(Warning, getNotes(Note)));
|
||||
Warnings.emplace_back(std::move(Warning), getNotes(Note));
|
||||
} else
|
||||
Warnings.push_back(DelayedDiag(Warning, getNotes()));
|
||||
Warnings.emplace_back(std::move(Warning), getNotes());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1667,7 +1667,7 @@ class ThreadSafetyReporter : public clang::threadSafety::ThreadSafetyHandler {
|
|||
PartialDiagnosticAt Warning(Loc,
|
||||
S.PDiag(diag::warn_acquire_requires_negative_cap)
|
||||
<< Kind << LockName << Neg);
|
||||
Warnings.push_back(DelayedDiag(Warning, getNotes()));
|
||||
Warnings.emplace_back(std::move(Warning), getNotes());
|
||||
}
|
||||
|
||||
|
||||
|
@ -1675,20 +1675,20 @@ class ThreadSafetyReporter : public clang::threadSafety::ThreadSafetyHandler {
|
|||
SourceLocation Loc) override {
|
||||
PartialDiagnosticAt Warning(Loc, S.PDiag(diag::warn_fun_excludes_mutex)
|
||||
<< Kind << FunName << LockName);
|
||||
Warnings.push_back(DelayedDiag(Warning, getNotes()));
|
||||
Warnings.emplace_back(std::move(Warning), getNotes());
|
||||
}
|
||||
|
||||
void handleLockAcquiredBefore(StringRef Kind, Name L1Name, Name L2Name,
|
||||
SourceLocation Loc) override {
|
||||
PartialDiagnosticAt Warning(Loc,
|
||||
S.PDiag(diag::warn_acquired_before) << Kind << L1Name << L2Name);
|
||||
Warnings.push_back(DelayedDiag(Warning, getNotes()));
|
||||
Warnings.emplace_back(std::move(Warning), getNotes());
|
||||
}
|
||||
|
||||
void handleBeforeAfterCycle(Name L1Name, SourceLocation Loc) override {
|
||||
PartialDiagnosticAt Warning(Loc,
|
||||
S.PDiag(diag::warn_acquired_before_after_cycle) << L1Name);
|
||||
Warnings.push_back(DelayedDiag(Warning, getNotes()));
|
||||
Warnings.emplace_back(std::move(Warning), getNotes());
|
||||
}
|
||||
|
||||
void enterFunction(const FunctionDecl* FD) override {
|
||||
|
@ -1732,8 +1732,8 @@ public:
|
|||
StringRef VariableName) override {
|
||||
PartialDiagnosticAt Warning(Loc, S.PDiag(diag::warn_loop_state_mismatch) <<
|
||||
VariableName);
|
||||
|
||||
Warnings.push_back(DelayedDiag(Warning, OptionalNotes()));
|
||||
|
||||
Warnings.emplace_back(std::move(Warning), OptionalNotes());
|
||||
}
|
||||
|
||||
void warnParamReturnTypestateMismatch(SourceLocation Loc,
|
||||
|
@ -1744,8 +1744,8 @@ public:
|
|||
PartialDiagnosticAt Warning(Loc, S.PDiag(
|
||||
diag::warn_param_return_typestate_mismatch) << VariableName <<
|
||||
ExpectedState << ObservedState);
|
||||
|
||||
Warnings.push_back(DelayedDiag(Warning, OptionalNotes()));
|
||||
|
||||
Warnings.emplace_back(std::move(Warning), OptionalNotes());
|
||||
}
|
||||
|
||||
void warnParamTypestateMismatch(SourceLocation Loc, StringRef ExpectedState,
|
||||
|
@ -1753,16 +1753,16 @@ public:
|
|||
|
||||
PartialDiagnosticAt Warning(Loc, S.PDiag(
|
||||
diag::warn_param_typestate_mismatch) << ExpectedState << ObservedState);
|
||||
|
||||
Warnings.push_back(DelayedDiag(Warning, OptionalNotes()));
|
||||
|
||||
Warnings.emplace_back(std::move(Warning), OptionalNotes());
|
||||
}
|
||||
|
||||
void warnReturnTypestateForUnconsumableType(SourceLocation Loc,
|
||||
StringRef TypeName) override {
|
||||
PartialDiagnosticAt Warning(Loc, S.PDiag(
|
||||
diag::warn_return_typestate_for_unconsumable_type) << TypeName);
|
||||
|
||||
Warnings.push_back(DelayedDiag(Warning, OptionalNotes()));
|
||||
|
||||
Warnings.emplace_back(std::move(Warning), OptionalNotes());
|
||||
}
|
||||
|
||||
void warnReturnTypestateMismatch(SourceLocation Loc, StringRef ExpectedState,
|
||||
|
@ -1770,8 +1770,8 @@ public:
|
|||
|
||||
PartialDiagnosticAt Warning(Loc, S.PDiag(
|
||||
diag::warn_return_typestate_mismatch) << ExpectedState << ObservedState);
|
||||
|
||||
Warnings.push_back(DelayedDiag(Warning, OptionalNotes()));
|
||||
|
||||
Warnings.emplace_back(std::move(Warning), OptionalNotes());
|
||||
}
|
||||
|
||||
void warnUseOfTempInInvalidState(StringRef MethodName, StringRef State,
|
||||
|
@ -1779,8 +1779,8 @@ public:
|
|||
|
||||
PartialDiagnosticAt Warning(Loc, S.PDiag(
|
||||
diag::warn_use_of_temp_in_invalid_state) << MethodName << State);
|
||||
|
||||
Warnings.push_back(DelayedDiag(Warning, OptionalNotes()));
|
||||
|
||||
Warnings.emplace_back(std::move(Warning), OptionalNotes());
|
||||
}
|
||||
|
||||
void warnUseInInvalidState(StringRef MethodName, StringRef VariableName,
|
||||
|
@ -1788,8 +1788,8 @@ public:
|
|||
|
||||
PartialDiagnosticAt Warning(Loc, S.PDiag(diag::warn_use_in_invalid_state) <<
|
||||
MethodName << VariableName << State);
|
||||
|
||||
Warnings.push_back(DelayedDiag(Warning, OptionalNotes()));
|
||||
|
||||
Warnings.emplace_back(std::move(Warning), OptionalNotes());
|
||||
}
|
||||
};
|
||||
}}}
|
||||
|
|
|
@ -1018,9 +1018,7 @@ void ResultBuilder::AddResult(Result R) {
|
|||
}
|
||||
|
||||
/// \brief Enter into a new scope.
|
||||
void ResultBuilder::EnterNewScope() {
|
||||
ShadowMaps.push_back(ShadowMap());
|
||||
}
|
||||
void ResultBuilder::EnterNewScope() { ShadowMaps.emplace_back(); }
|
||||
|
||||
/// \brief Exit from the current scope.
|
||||
void ResultBuilder::ExitScope() {
|
||||
|
|
|
@ -3062,7 +3062,7 @@ class ShadowContextRAII {
|
|||
|
||||
public:
|
||||
ShadowContextRAII(VisibleDeclsRecord &Visible) : Visible(Visible) {
|
||||
Visible.ShadowMaps.push_back(ShadowMap());
|
||||
Visible.ShadowMaps.emplace_back();
|
||||
}
|
||||
|
||||
~ShadowContextRAII() {
|
||||
|
|
|
@ -4514,16 +4514,15 @@ bool ASTReader::ParseHeaderSearchOptions(const RecordData &Record,
|
|||
= static_cast<frontend::IncludeDirGroup>(Record[Idx++]);
|
||||
bool IsFramework = Record[Idx++];
|
||||
bool IgnoreSysRoot = Record[Idx++];
|
||||
HSOpts.UserEntries.push_back(
|
||||
HeaderSearchOptions::Entry(Path, Group, IsFramework, IgnoreSysRoot));
|
||||
HSOpts.UserEntries.emplace_back(std::move(Path), Group, IsFramework,
|
||||
IgnoreSysRoot);
|
||||
}
|
||||
|
||||
// System header prefixes.
|
||||
for (unsigned N = Record[Idx++]; N; --N) {
|
||||
std::string Prefix = ReadString(Record, Idx);
|
||||
bool IsSystemHeader = Record[Idx++];
|
||||
HSOpts.SystemHeaderPrefixes.push_back(
|
||||
HeaderSearchOptions::SystemHeaderPrefix(Prefix, IsSystemHeader));
|
||||
HSOpts.SystemHeaderPrefixes.emplace_back(std::move(Prefix), IsSystemHeader);
|
||||
}
|
||||
|
||||
HSOpts.ResourceDir = ReadString(Record, Idx);
|
||||
|
|
|
@ -69,7 +69,7 @@ void ModelInjector::onBodySynthesis(const NamedDecl *D) {
|
|||
FrontendOptions &FrontendOpts = Invocation->getFrontendOpts();
|
||||
InputKind IK = IK_CXX; // FIXME
|
||||
FrontendOpts.Inputs.clear();
|
||||
FrontendOpts.Inputs.push_back(FrontendInputFile(fileName, IK));
|
||||
FrontendOpts.Inputs.emplace_back(fileName, IK);
|
||||
FrontendOpts.DisableFree = true;
|
||||
|
||||
Invocation->getDiagnosticOpts().VerifyDiagnostics = 0;
|
||||
|
|
|
@ -302,8 +302,7 @@ FixedCompilationDatabase(Twine Directory, ArrayRef<std::string> CommandLine) {
|
|||
std::vector<std::string> ToolCommandLine(1, "clang-tool");
|
||||
ToolCommandLine.insert(ToolCommandLine.end(),
|
||||
CommandLine.begin(), CommandLine.end());
|
||||
CompileCommands.push_back(
|
||||
CompileCommand(Directory, std::move(ToolCommandLine)));
|
||||
CompileCommands.emplace_back(Directory, std::move(ToolCommandLine));
|
||||
}
|
||||
|
||||
std::vector<CompileCommand>
|
||||
|
|
|
@ -220,10 +220,10 @@ void JSONCompilationDatabase::getCommands(
|
|||
for (int I = 0, E = CommandsRef.size(); I != E; ++I) {
|
||||
SmallString<8> DirectoryStorage;
|
||||
SmallString<1024> CommandStorage;
|
||||
Commands.push_back(CompileCommand(
|
||||
// FIXME: Escape correctly:
|
||||
CommandsRef[I].first->getValue(DirectoryStorage),
|
||||
unescapeCommandLine(CommandsRef[I].second->getValue(CommandStorage))));
|
||||
Commands.emplace_back(
|
||||
// FIXME: Escape correctly:
|
||||
CommandsRef[I].first->getValue(DirectoryStorage),
|
||||
unescapeCommandLine(CommandsRef[I].second->getValue(CommandStorage)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -64,10 +64,9 @@ GetFlattenedSpellings(const Record &Attr) {
|
|||
for (const auto &Spelling : Spellings) {
|
||||
if (Spelling->getValueAsString("Variety") == "GCC") {
|
||||
// Gin up two new spelling objects to add into the list.
|
||||
Ret.push_back(FlattenedSpelling("GNU", Spelling->getValueAsString("Name"),
|
||||
"", true));
|
||||
Ret.push_back(FlattenedSpelling(
|
||||
"CXX11", Spelling->getValueAsString("Name"), "gnu", true));
|
||||
Ret.emplace_back("GNU", Spelling->getValueAsString("Name"), "", true);
|
||||
Ret.emplace_back("CXX11", Spelling->getValueAsString("Name"), "gnu",
|
||||
true);
|
||||
} else
|
||||
Ret.push_back(FlattenedSpelling(*Spelling));
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ void EmitClangCommentCommandInfo(RecordKeeper &Records, raw_ostream &OS) {
|
|||
std::string Name = Tag.getValueAsString("Name");
|
||||
std::string Return;
|
||||
raw_string_ostream(Return) << "return &Commands[" << i << "];";
|
||||
Matches.push_back(StringMatcher::StringPair(Name, Return));
|
||||
Matches.emplace_back(std::move(Name), std::move(Return));
|
||||
}
|
||||
|
||||
OS << "const CommandInfo *CommandTraits::getBuiltinCommandInfo(\n"
|
||||
|
|
|
@ -24,8 +24,7 @@ void clang::EmitClangCommentHTMLTags(RecordKeeper &Records, raw_ostream &OS) {
|
|||
std::vector<Record *> Tags = Records.getAllDerivedDefinitions("Tag");
|
||||
std::vector<StringMatcher::StringPair> Matches;
|
||||
for (Record *Tag : Tags) {
|
||||
std::string Spelling = Tag->getValueAsString("Spelling");
|
||||
Matches.push_back(StringMatcher::StringPair(Spelling, "return true;"));
|
||||
Matches.emplace_back(Tag->getValueAsString("Spelling"), "return true;");
|
||||
}
|
||||
|
||||
emitSourceFileHeader("HTML tag name matcher", OS);
|
||||
|
|
|
@ -337,9 +337,9 @@ public:
|
|||
// Modify the TypeSpec per-argument to get a concrete Type, and create
|
||||
// known variables for each.
|
||||
// Types[0] is the return value.
|
||||
Types.push_back(Type(OutTS, Proto[0]));
|
||||
Types.emplace_back(OutTS, Proto[0]);
|
||||
for (unsigned I = 1; I < Proto.size(); ++I)
|
||||
Types.push_back(Type(InTS, Proto[I]));
|
||||
Types.emplace_back(InTS, Proto[I]);
|
||||
}
|
||||
|
||||
/// Get the Record that this intrinsic is based off.
|
||||
|
|
Loading…
Reference in New Issue