[clang-tools-extra] ac80017 - [clang-tidy][NFC] Fix modernize-use-emplace findings
Piotr Zegar via cfe-commits
cfe-commits at lists.llvm.org
Sun Aug 27 01:53:38 PDT 2023
Author: Piotr Zegar
Date: 2023-08-27T08:52:09Z
New Revision: ac80017522241a30ed6b87273e1a3b39fb73c6dc
URL: https://github.com/llvm/llvm-project/commit/ac80017522241a30ed6b87273e1a3b39fb73c6dc
DIFF: https://github.com/llvm/llvm-project/commit/ac80017522241a30ed6b87273e1a3b39fb73c6dc.diff
LOG: [clang-tidy][NFC] Fix modernize-use-emplace findings
Fix issues found by clang-tidy in clang-tidy source directory.
Added:
Modified:
clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp
clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
clang-tools-extra/clang-tidy/utils/UsingInserter.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp b/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
index 7d4659c1eaac43..9dacf1562429ce 100644
--- a/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
@@ -199,11 +199,12 @@ void IncludeModernizePPCallbacks::InclusionDirective(
// 3. Do nothing and let the user deal with the migration himself.
SourceLocation DiagLoc = FilenameRange.getBegin();
if (CStyledHeaderToCxx.count(FileName) != 0) {
- IncludesToBeProcessed.push_back(
+ IncludesToBeProcessed.emplace_back(
IncludeMarker{CStyledHeaderToCxx[FileName], FileName,
FilenameRange.getAsRange(), DiagLoc});
} else if (DeleteHeaders.count(FileName) != 0) {
- IncludesToBeProcessed.push_back(
+ IncludesToBeProcessed.emplace_back(
+ // NOLINTNEXTLINE(modernize-use-emplace) - false-positive
IncludeMarker{std::string{}, FileName,
SourceRange{HashLoc, FilenameRange.getEnd()}, DiagLoc});
}
diff --git a/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp
index b1e1189d4ed775..660996aba7b70d 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp
@@ -39,10 +39,10 @@ UseStdPrintCheck::UseStdPrintCheck(StringRef Name, ClangTidyContext *Context)
MaybeHeaderToInclude(Options.get("PrintHeader")) {
if (PrintfLikeFunctions.empty() && FprintfLikeFunctions.empty()) {
- PrintfLikeFunctions.push_back("::printf");
- PrintfLikeFunctions.push_back("absl::PrintF");
- FprintfLikeFunctions.push_back("::fprintf");
- FprintfLikeFunctions.push_back("absl::FPrintF");
+ PrintfLikeFunctions.emplace_back("::printf");
+ PrintfLikeFunctions.emplace_back("absl::PrintF");
+ FprintfLikeFunctions.emplace_back("::fprintf");
+ FprintfLikeFunctions.emplace_back("absl::FPrintF");
}
if (!MaybeHeaderToInclude && (ReplacementPrintFunction == "std::print" ||
diff --git a/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp b/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
index 5bf77bb8600642..57f13db078020a 100644
--- a/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
@@ -35,9 +35,9 @@ RedundantStringCStrCheck::RedundantStringCStrCheck(StringRef Name,
StringParameterFunctions(utils::options::parseStringList(
Options.get("StringParameterFunctions", ""))) {
if (getLangOpts().CPlusPlus20)
- StringParameterFunctions.push_back("::std::format");
+ StringParameterFunctions.emplace_back("::std::format");
if (getLangOpts().CPlusPlus23)
- StringParameterFunctions.push_back("::std::print");
+ StringParameterFunctions.emplace_back("::std::print");
}
void RedundantStringCStrCheck::registerMatchers(
diff --git a/clang-tools-extra/clang-tidy/utils/UsingInserter.cpp b/clang-tools-extra/clang-tidy/utils/UsingInserter.cpp
index d9e0f3fc0f61b7..3a2c16ff05dae9 100644
--- a/clang-tools-extra/clang-tidy/utils/UsingInserter.cpp
+++ b/clang-tools-extra/clang-tidy/utils/UsingInserter.cpp
@@ -53,7 +53,7 @@ std::optional<FixItHint> UsingInserter::createUsingDeclaration(
Statement, Context)
.empty();
if (AlreadyHasUsingDecl) {
- AddedUsing.emplace(NameInFunction(Function, QualifiedName.str()));
+ AddedUsing.emplace(Function, QualifiedName.str());
return std::nullopt;
}
// Find conflicting declarations and references.
@@ -69,7 +69,7 @@ std::optional<FixItHint> UsingInserter::createUsingDeclaration(
std::string Declaration =
(llvm::Twine("\nusing ") + QualifiedName + ";").str();
- AddedUsing.emplace(std::make_pair(Function, QualifiedName.str()));
+ AddedUsing.emplace(Function, QualifiedName.str());
return FixItHint::CreateInsertion(InsertLoc, Declaration);
}
More information about the cfe-commits
mailing list