[clang] 319d29d - [Sema] Fix a warning
Author: Kazu Hirata Date: 2024-07-25T10:53:03-07:00 New Revision: 319d29d21ea9f04cd8530c77b558796bf5db0197 URL: https://github.com/llvm/llvm-project/commit/319d29d21ea9f04cd8530c77b558796bf5db0197 DIFF: https://github.com/llvm/llvm-project/commit/319d29d21ea9f04cd8530c77b558796bf5db0197.diff LOG: [Sema] Fix a warning This patch fixes: clang/lib/Sema/SemaChecking.cpp:8220:3: error: default label in switch which covers all enumeration values [-Werror,-Wcovered-switch-default] Added: Modified: clang/lib/Sema/SemaChecking.cpp Removed: diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 99a1471d9d06d..bde92e04b6b83 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -8217,9 +8217,8 @@ static bool IsInfOrNanFunction(StringRef calleeName, MathCheck Check) { case MathCheck::Inf: return MatchesAny({"__builtin_inf", "__builtin_inff", "__builtin_infl", "__builtin_inff16", "__builtin_inff128"}); - default: -return false; } + llvm_unreachable("unknown MathCheck"); } void Sema::CheckInfNaNFunction(const CallExpr *Call, ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clangd] Use std::make_unique (NFC) (PR #97915)
https://github.com/kazutakahirata closed https://github.com/llvm/llvm-project/pull/97915 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clangd] Use std::make_unique (NFC) (PR #97915)
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/97915 None >From 91325539452e0fabef33894d66a0f643319891f2 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sat, 29 Jun 2024 12:40:11 -0700 Subject: [PATCH] [clangd] Use std::make_unique (NFC) --- clang-tools-extra/clangd/support/ThreadsafeFS.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang-tools-extra/clangd/support/ThreadsafeFS.cpp b/clang-tools-extra/clangd/support/ThreadsafeFS.cpp index 0e249d07d2fd9..7398e4258527b 100644 --- a/clang-tools-extra/clangd/support/ThreadsafeFS.cpp +++ b/clang-tools-extra/clangd/support/ThreadsafeFS.cpp @@ -41,7 +41,7 @@ class VolatileFileSystem : public llvm::vfs::ProxyFileSystem { llvm::StringRef FileName = llvm::sys::path::filename(Path); if (FileName.starts_with("preamble-") && FileName.ends_with(".pch")) return File; -return std::unique_ptr(new VolatileFile(std::move(*File))); +return std::make_unique(std::move(*File)); } private: ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Use std::make_unique (NFC) (PR #97176)
https://github.com/kazutakahirata closed https://github.com/llvm/llvm-project/pull/97176 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Use std::make_unique (NFC) (PR #97176)
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/97176 This patch is based on clang-tidy's modernize-make-unique but limited to those cases where type names are mentioned twice like std::unique_ptr(new Type()), which is a bit mouthful. >From 84e939e920af0c54092362d854850be2c6dd2897 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sat, 29 Jun 2024 06:28:42 -0700 Subject: [PATCH] [clang] Use std::make_unique (NFC) This patch is based on clang-tidy's modernize-make-unique but limited to those cases where type names are mentioned twice like std::unique_ptr(new Type()), which is a bit mouthful. --- clang/lib/CodeGen/CGCoroutine.cpp| 2 +- clang/lib/Interpreter/CodeCompletion.cpp | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/clang/lib/CodeGen/CGCoroutine.cpp b/clang/lib/CodeGen/CGCoroutine.cpp index b4c724422c14a..a8a70186c2c5a 100644 --- a/clang/lib/CodeGen/CGCoroutine.cpp +++ b/clang/lib/CodeGen/CGCoroutine.cpp @@ -103,7 +103,7 @@ static void createCoroData(CodeGenFunction , return; } - CurCoro.Data = std::unique_ptr(new CGCoroData); + CurCoro.Data = std::make_unique(); CurCoro.Data->CoroId = CoroId; CurCoro.Data->CoroIdExpr = CoroIdExpr; } diff --git a/clang/lib/Interpreter/CodeCompletion.cpp b/clang/lib/Interpreter/CodeCompletion.cpp index 25183ae9eeb99..791426807cb91 100644 --- a/clang/lib/Interpreter/CodeCompletion.cpp +++ b/clang/lib/Interpreter/CodeCompletion.cpp @@ -368,8 +368,7 @@ void ReplCodeCompleter::codeComplete(CompilerInstance *InterpCI, llvm::SmallVector tb = {}; InterpCI->getFrontendOpts().Inputs[0] = FrontendInputFile( CodeCompletionFileName, Language::CXX, InputKind::Source); - auto Act = std::unique_ptr( - new IncrementalSyntaxOnlyAction(ParentCI)); + auto Act = std::make_unique(ParentCI); std::unique_ptr MB = llvm::MemoryBuffer::getMemBufferCopy(Content, CodeCompletionFileName); llvm::SmallVector RemappedFiles; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 2f57df5 - [CodeGen] Fix a warning
Author: Kazu Hirata Date: 2024-06-26T14:37:06-07:00 New Revision: 2f57df5826a6df8ad5549ed98aede0d60e01e08b URL: https://github.com/llvm/llvm-project/commit/2f57df5826a6df8ad5549ed98aede0d60e01e08b DIFF: https://github.com/llvm/llvm-project/commit/2f57df5826a6df8ad5549ed98aede0d60e01e08b.diff LOG: [CodeGen] Fix a warning This patch fixes: clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp:1662:8: error: unused variable 'ParallelReduction' [-Werror,-Wunused-variable] Added: Modified: clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp Removed: diff --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp index fb71b27de9cd0..f4eba14da51a5 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp @@ -1668,6 +1668,7 @@ void CGOpenMPRuntimeGPU::emitReduction( if (Options.SimpleReduction) { assert(!TeamsReduction && !ParallelReduction && "Invalid reduction selection in emitReduction."); +(void)ParallelReduction; CGOpenMPRuntime::emitReduction(CGF, Loc, Privates, LHSExprs, RHSExprs, ReductionOps, Options); return; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CodeGen] Remove extraneous ArrayRef (NFC) (PR #96085)
https://github.com/kazutakahirata closed https://github.com/llvm/llvm-project/pull/96085 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CodeGen] Remove extraneous ArrayRef (NFC) (PR #96085)
@@ -1200,15 +1200,14 @@ void CodeGenPGO::emitCounterSetOrIncrement(CGBuilderTy , const Stmt *S, if (llvm::EnableSingleByteCoverage) Builder.CreateCall(CGM.getIntrinsic(llvm::Intrinsic::instrprof_cover), - ArrayRef(Args, 4)); + Args); else { if (!StepV) Builder.CreateCall(CGM.getIntrinsic(llvm::Intrinsic::instrprof_increment), - ArrayRef(Args, 4)); + Args); else kazutakahirata wrote: Thank you for catching this. Corrected in the latest iteration. https://github.com/llvm/llvm-project/pull/96085 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CodeGen] Remove extraneous ArrayRef (NFC) (PR #96085)
https://github.com/kazutakahirata edited https://github.com/llvm/llvm-project/pull/96085 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CodeGen] Remove extraneous ArrayRef (NFC) (PR #96085)
https://github.com/kazutakahirata updated https://github.com/llvm/llvm-project/pull/96085 >From 62c24545350105e24a5be6334fe7c8075c2a633d Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Wed, 19 Jun 2024 08:43:00 -0700 Subject: [PATCH 1/2] [CodeGen] Remove extraneous ArrayRef (NFC) ArrayRef can infer the size of a C array. Also, C arrays can be implicitly cast to ArrayRef. --- clang/lib/CodeGen/CodeGenPGO.cpp | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/clang/lib/CodeGen/CodeGenPGO.cpp b/clang/lib/CodeGen/CodeGenPGO.cpp index 2839697614595..f2cdeb5796d3a 100644 --- a/clang/lib/CodeGen/CodeGenPGO.cpp +++ b/clang/lib/CodeGen/CodeGenPGO.cpp @@ -1200,15 +1200,14 @@ void CodeGenPGO::emitCounterSetOrIncrement(CGBuilderTy , const Stmt *S, if (llvm::EnableSingleByteCoverage) Builder.CreateCall(CGM.getIntrinsic(llvm::Intrinsic::instrprof_cover), - ArrayRef(Args, 4)); + Args); else { if (!StepV) Builder.CreateCall(CGM.getIntrinsic(llvm::Intrinsic::instrprof_increment), - ArrayRef(Args, 4)); + Args); else Builder.CreateCall( - CGM.getIntrinsic(llvm::Intrinsic::instrprof_increment_step), - ArrayRef(Args)); + CGM.getIntrinsic(llvm::Intrinsic::instrprof_increment_step), Args); } } >From e2a507bb29cbd4778ceb147f7947ba0e3fd397c4 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Wed, 19 Jun 2024 09:10:44 -0700 Subject: [PATCH 2/2] Partially revert changes. --- clang/lib/CodeGen/CodeGenPGO.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/lib/CodeGen/CodeGenPGO.cpp b/clang/lib/CodeGen/CodeGenPGO.cpp index f2cdeb5796d3a..ea726b5708a4a 100644 --- a/clang/lib/CodeGen/CodeGenPGO.cpp +++ b/clang/lib/CodeGen/CodeGenPGO.cpp @@ -1200,11 +1200,11 @@ void CodeGenPGO::emitCounterSetOrIncrement(CGBuilderTy , const Stmt *S, if (llvm::EnableSingleByteCoverage) Builder.CreateCall(CGM.getIntrinsic(llvm::Intrinsic::instrprof_cover), - Args); + ArrayRef(Args, 4)); else { if (!StepV) Builder.CreateCall(CGM.getIntrinsic(llvm::Intrinsic::instrprof_increment), - Args); + ArrayRef(Args, 4)); else Builder.CreateCall( CGM.getIntrinsic(llvm::Intrinsic::instrprof_increment_step), Args); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CodeGen] Remove extraneous ArrayRef (NFC) (PR #96085)
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/96085 ArrayRef can infer the size of a C array. Also, C arrays can be implicitly cast to ArrayRef. >From 62c24545350105e24a5be6334fe7c8075c2a633d Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Wed, 19 Jun 2024 08:43:00 -0700 Subject: [PATCH] [CodeGen] Remove extraneous ArrayRef (NFC) ArrayRef can infer the size of a C array. Also, C arrays can be implicitly cast to ArrayRef. --- clang/lib/CodeGen/CodeGenPGO.cpp | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/clang/lib/CodeGen/CodeGenPGO.cpp b/clang/lib/CodeGen/CodeGenPGO.cpp index 2839697614595..f2cdeb5796d3a 100644 --- a/clang/lib/CodeGen/CodeGenPGO.cpp +++ b/clang/lib/CodeGen/CodeGenPGO.cpp @@ -1200,15 +1200,14 @@ void CodeGenPGO::emitCounterSetOrIncrement(CGBuilderTy , const Stmt *S, if (llvm::EnableSingleByteCoverage) Builder.CreateCall(CGM.getIntrinsic(llvm::Intrinsic::instrprof_cover), - ArrayRef(Args, 4)); + Args); else { if (!StepV) Builder.CreateCall(CGM.getIntrinsic(llvm::Intrinsic::instrprof_increment), - ArrayRef(Args, 4)); + Args); else Builder.CreateCall( - CGM.getIntrinsic(llvm::Intrinsic::instrprof_increment_step), - ArrayRef(Args)); + CGM.getIntrinsic(llvm::Intrinsic::instrprof_increment_step), Args); } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Sema] Use llvm::erase_if (NFC) (PR #96068)
https://github.com/kazutakahirata closed https://github.com/llvm/llvm-project/pull/96068 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Sema] Use llvm::erase_if (NFC) (PR #96068)
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/96068 While I am at it, I'm constructing SmallVector directly from ArrayRef. >From 85dd4232f6510055a536bd5f7f0ce21a06295dfd Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Wed, 19 Jun 2024 06:06:15 -0700 Subject: [PATCH] [Sema] Use llvm::erase_if (NFC) While I am at it, I'm constructing SmallVector directly from ArrayRef. --- clang/lib/Sema/SemaOpenACC.cpp | 24 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/clang/lib/Sema/SemaOpenACC.cpp b/clang/lib/Sema/SemaOpenACC.cpp index 97586a037eee4..cf207be33175c 100644 --- a/clang/lib/Sema/SemaOpenACC.cpp +++ b/clang/lib/Sema/SemaOpenACC.cpp @@ -841,14 +841,10 @@ OpenACCClause *SemaOpenACCClauseVisitor::VisitAttachClause( // ActOnVar ensured that everything is a valid variable reference, but we // still have to make sure it is a pointer type. - llvm::SmallVector VarList{Clause.getVarList().begin(), -Clause.getVarList().end()}; - VarList.erase(std::remove_if(VarList.begin(), VarList.end(), - [&](Expr *E) { - return SemaRef.CheckVarIsPointerType( - OpenACCClauseKind::Attach, E); - }), -VarList.end()); + llvm::SmallVector VarList{Clause.getVarList()}; + llvm::erase_if(VarList, [&](Expr *E) { +return SemaRef.CheckVarIsPointerType(OpenACCClauseKind::Attach, E); + }); Clause.setVarListDetails(VarList, /*IsReadOnly=*/false, /*IsZero=*/false); return OpenACCAttachClause::Create(Ctx, Clause.getBeginLoc(), @@ -866,14 +862,10 @@ OpenACCClause *SemaOpenACCClauseVisitor::VisitDevicePtrClause( // ActOnVar ensured that everything is a valid variable reference, but we // still have to make sure it is a pointer type. - llvm::SmallVector VarList{Clause.getVarList().begin(), -Clause.getVarList().end()}; - VarList.erase(std::remove_if(VarList.begin(), VarList.end(), - [&](Expr *E) { - return SemaRef.CheckVarIsPointerType( - OpenACCClauseKind::DevicePtr, E); - }), -VarList.end()); + llvm::SmallVector VarList{Clause.getVarList()}; + llvm::erase_if(VarList, [&](Expr *E) { +return SemaRef.CheckVarIsPointerType(OpenACCClauseKind::DevicePtr, E); + }); Clause.setVarListDetails(VarList, /*IsReadOnly=*/false, /*IsZero=*/false); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [llvm] [mlir] Use StringRef::starts_with (NFC) (PR #94886)
https://github.com/kazutakahirata closed https://github.com/llvm/llvm-project/pull/94886 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [llvm] [mlir] Use StringRef::starts_with (NFC) (PR #94886)
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/94886 None >From b33680b77672ac4881032113e2302c02c1dd62b5 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Mon, 20 May 2024 19:02:40 -0700 Subject: [PATCH] Use StringRef::starts_with (NFC) --- bolt/lib/Profile/BoltAddressTranslation.cpp | 2 +- clang-tools-extra/clang-query/QueryParser.cpp | 6 ++ mlir/lib/Query/QueryParser.cpp| 6 ++ 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/bolt/lib/Profile/BoltAddressTranslation.cpp b/bolt/lib/Profile/BoltAddressTranslation.cpp index cdfca2b9871ac..519f282a2351c 100644 --- a/bolt/lib/Profile/BoltAddressTranslation.cpp +++ b/bolt/lib/Profile/BoltAddressTranslation.cpp @@ -304,7 +304,7 @@ std::error_code BoltAddressTranslation::parse(raw_ostream , StringRef Buf) { StringRef Name = Buf.slice(Offset, Offset + NameSz); Offset = alignTo(Offset + NameSz, 4); - if (Name.substr(0, 4) != "BOLT") + if (!Name.starts_with("BOLT")) return make_error_code(llvm::errc::io_error); Error Err(Error::success()); diff --git a/clang-tools-extra/clang-query/QueryParser.cpp b/clang-tools-extra/clang-query/QueryParser.cpp index 1d0b7d9bc6fc8..97cb264a611af 100644 --- a/clang-tools-extra/clang-query/QueryParser.cpp +++ b/clang-tools-extra/clang-query/QueryParser.cpp @@ -144,13 +144,11 @@ QueryRef QueryParser::endQuery(QueryRef Q) { StringRef Extra = Line; StringRef ExtraTrimmed = Extra.ltrim(" \t\v\f\r"); - if ((!ExtraTrimmed.empty() && ExtraTrimmed[0] == '\n') || - (ExtraTrimmed.size() >= 2 && ExtraTrimmed[0] == '\r' && - ExtraTrimmed[1] == '\n')) + if (ExtraTrimmed.starts_with('\n') || ExtraTrimmed.starts_with("\r\n")) Q->RemainingContent = Extra; else { StringRef TrailingWord = lexWord(); -if (!TrailingWord.empty() && TrailingWord.front() == '#') { +if (TrailingWord.starts_with('#')) { Line = Line.drop_until([](char c) { return c == '\n'; }); Line = Line.drop_while([](char c) { return c == '\n'; }); return endQuery(Q); diff --git a/mlir/lib/Query/QueryParser.cpp b/mlir/lib/Query/QueryParser.cpp index 595055a42965f..8a034634c5b89 100644 --- a/mlir/lib/Query/QueryParser.cpp +++ b/mlir/lib/Query/QueryParser.cpp @@ -91,13 +91,11 @@ QueryRef QueryParser::endQuery(QueryRef queryRef) { llvm::StringRef extra = line; llvm::StringRef extraTrimmed = extra.ltrim(" \t\v\f\r"); - if ((!extraTrimmed.empty() && extraTrimmed[0] == '\n') || - (extraTrimmed.size() >= 2 && extraTrimmed[0] == '\r' && - extraTrimmed[1] == '\n')) + if (extraTrimmed.starts_with('\n') || extraTrimmed.starts_with("\r\n")) queryRef->remainingContent = extra; else { llvm::StringRef trailingWord = lexWord(); -if (!trailingWord.empty() && trailingWord.front() == '#') { +if (trailingWord.starts_with('#')) { line = line.drop_until([](char c) { return c == '\n'; }); line = line.drop_while([](char c) { return c == '\n'; }); return endQuery(queryRef); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [mlir] Use llvm::less_first (NFC) (PR #94136)
https://github.com/kazutakahirata closed https://github.com/llvm/llvm-project/pull/94136 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [mlir] Use llvm::less_first (NFC) (PR #94136)
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/94136 None >From f154605958e5bb7481013861c96fe3c42156a834 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sat, 1 Jun 2024 18:15:17 -0700 Subject: [PATCH] Use llvm::less_first (NFC) --- clang/lib/Serialization/ASTWriter.cpp | 4 +--- .../DependencyScanning/DependencyScanningWorker.cpp| 4 +--- llvm/lib/MC/MCPseudoProbe.cpp | 10 ++ llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.h | 5 + .../SparseTensor/Transforms/SparseReinterpretMap.cpp | 4 +--- .../SparseTensor/Transforms/Utils/LoopEmitter.cpp | 3 +-- 6 files changed, 7 insertions(+), 23 deletions(-) diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index e830c4026ea78..eb41a205bc82c 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -3205,9 +3205,7 @@ void ASTWriter::WritePragmaDiagnosticMappings(const DiagnosticsEngine , } // Sort by diag::kind for deterministic output. - llvm::sort(Mappings, [](const auto , const auto ) { -return LHS.first < RHS.first; - }); + llvm::sort(Mappings, llvm::less_first()); for (const auto : Mappings) { Record.push_back(I.first); diff --git a/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp b/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp index 0c047b6c5da2f..0f82f22d8b9a8 100644 --- a/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp +++ b/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp @@ -259,9 +259,7 @@ static void canonicalizeDefines(PreprocessorOptions ) { ++Index; } - llvm::stable_sort(SimpleNames, [](const MacroOpt , const MacroOpt ) { -return A.first < B.first; - }); + llvm::stable_sort(SimpleNames, llvm::less_first()); // Keep the last instance of each macro name by going in reverse auto NewEnd = std::unique( SimpleNames.rbegin(), SimpleNames.rend(), diff --git a/llvm/lib/MC/MCPseudoProbe.cpp b/llvm/lib/MC/MCPseudoProbe.cpp index cec50322bb9f9..040f3aab88128 100644 --- a/llvm/lib/MC/MCPseudoProbe.cpp +++ b/llvm/lib/MC/MCPseudoProbe.cpp @@ -182,13 +182,10 @@ void MCPseudoProbeInlineTree::emit(MCObjectStreamer *MCOS, // Emit sorted descendant. InlineSite is unique for each pair, so there will // be no ordering of Inlinee based on MCPseudoProbeInlineTree* using InlineeType = std::pair; - auto Comparer = [](const InlineeType , const InlineeType ) { -return A.first < B.first; - }; std::vector Inlinees; for (const auto : Children) Inlinees.emplace_back(Child.first, Child.second.get()); - std::sort(Inlinees.begin(), Inlinees.end(), Comparer); + llvm::sort(Inlinees, llvm::less_first()); for (const auto : Inlinees) { // Emit probe index @@ -230,13 +227,10 @@ void MCPseudoProbeSections::emit(MCObjectStreamer *MCOS) { // Emit sorted descendant. InlineSite is unique for each pair, so there // will be no ordering of Inlinee based on MCPseudoProbeInlineTree* using InlineeType = std::pair; - auto Comparer = [](const InlineeType , const InlineeType ) { -return A.first < B.first; - }; std::vector Inlinees; for (const auto : Root.getChildren()) Inlinees.emplace_back(Child.first, Child.second.get()); - std::sort(Inlinees.begin(), Inlinees.end(), Comparer); + llvm::sort(Inlinees, llvm::less_first()); for (const auto : Inlinees) { // Emit the group guarded by a sentinel probe. diff --git a/llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.h b/llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.h index 8c014832f5e46..9fe02e24c8a15 100644 --- a/llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.h +++ b/llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.h @@ -597,10 +597,7 @@ class SIMachineFunctionInfo final : public AMDGPUMachineFunction, const ReservedRegSet () const { return WWMReservedRegs; } ArrayRef getPrologEpilogSGPRSpills() const { -assert( -is_sorted(PrologEpilogSGPRSpills, [](const auto , const auto ) { - return LHS.first < RHS.first; -})); +assert(is_sorted(PrologEpilogSGPRSpills, llvm::less_first())); return PrologEpilogSGPRSpills; } diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseReinterpretMap.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparseReinterpretMap.cpp index 36ecf692b02c5..ce7f6b2865375 100644 --- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseReinterpretMap.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseReinterpretMap.cpp @@ -557,9 +557,7 @@ struct GenericOpScheduler : public OpRewritePattern { unsigned lvl = llvm::cast(expr).getPosition(); lvlSeq.push_back(std::make_pair(lvl, lvlSeq.size())); } - std::sort(lvlSeq.begin(), lvlSeq.end(), [](auto , auto ) -> bool { -return
[clang] [libcxx] [clang] Preserve Qualifiers and type sugar in TemplateNames (PR #93433)
https://github.com/kazutakahirata updated https://github.com/llvm/llvm-project/pull/93433 >From 8322ce12520d1d4ab96b58195bd91f62a7b95c06 Mon Sep 17 00:00:00 2001 From: Matheus Izvekov Date: Sat, 25 May 2024 13:57:39 -0300 Subject: [PATCH] [clang] Preserve Qualifiers and type sugar in TemplateNames This patch improves the preservation of qualifiers and loss of type sugar in TemplateNames. This problem is analogous to https://reviews.llvm.org/D112374 and this patch takes a very similar approach to that patch, except the impact here is much lesser. When a TemplateName was written bare, without qualifications, we wouldn't produce a QualifiedTemplate which could be used to disambiguate it from a Canonical TemplateName. This had effects in the TemplateName printer, which had workarounds to deal with this, and wouldn't print the TemplateName as-written in most situations. There are also some related fixes to help preserve this type sugar along the way into diagnostics, so that this patch can be properly tested. - Fix dropping the template keyword. - Fix type deduction to preserve sugar in TST TemplateNames. --- clang/docs/ReleaseNotes.rst | 2 + clang/include/clang/AST/TemplateName.h| 19 +++--- clang/include/clang/Sema/Sema.h | 3 + clang/lib/AST/ASTContext.cpp | 16 ++--- clang/lib/AST/DeclTemplate.cpp| 7 +- clang/lib/AST/ODRHash.cpp | 9 ++- clang/lib/AST/TemplateBase.cpp| 2 +- clang/lib/AST/TemplateName.cpp| 64 +-- clang/lib/AST/TextNodeDumper.cpp | 4 +- clang/lib/AST/Type.cpp| 3 +- clang/lib/AST/TypePrinter.cpp | 4 +- clang/lib/Sema/SemaDecl.cpp | 15 ++--- clang/lib/Sema/SemaDeclCXX.cpp| 12 ++-- clang/lib/Sema/SemaExpr.cpp | 4 +- clang/lib/Sema/SemaExprMember.cpp | 3 +- clang/lib/Sema/SemaTemplate.cpp | 25 +--- clang/lib/Sema/SemaTemplateDeduction.cpp | 62 +- clang/lib/Sema/SemaType.cpp | 14 ++-- clang/lib/Sema/TreeTransform.h| 8 +-- clang/test/AST/ast-dump-ctad-alias.cpp| 6 +- clang/test/AST/ast-dump-decl.cpp | 8 +-- clang/test/AST/ast-dump-expr.cpp | 2 +- clang/test/AST/ast-dump-template-decls.cpp| 6 +- clang/test/AST/ast-dump-template-name.cpp | 4 +- clang/test/AST/ast-dump-using-template.cpp| 6 +- clang/test/CXX/drs/cwg1xx.cpp | 4 +- .../over.match.oper/p3-2a.cpp | 4 +- .../temp.deduct/temp.deduct.type/p9-0x.cpp| 4 +- clang/test/Index/print-type.cpp | 2 +- clang/test/OpenMP/declare_mapper_messages.cpp | 2 +- .../Parser/cxx-template-template-recovery.cpp | 4 +- .../cxx1y-variable-templates_in_class.cpp | 10 +-- clang/test/SemaTemplate/cwg2398.cpp | 2 +- .../instantiate-requires-expr.cpp | 4 +- .../nested-implicit-deduction-guides.cpp | 2 +- clang/unittests/AST/TemplateNameTest.cpp | 40 ++-- .../map/map.cons/deduct.verify.cpp| 24 +++ .../multimap/multimap.cons/deduct.verify.cpp | 22 +++ .../multiset/multiset.cons/deduct.verify.cpp | 10 +-- .../set/set.cons/deduct.verify.cpp| 10 +-- .../priqueue.cons/deduct.verify.cpp | 10 +-- .../queue/queue.cons/deduct.verify.cpp| 6 +- .../stack/stack.cons/deduct.verify.cpp| 6 +- .../array/array.cons/deduct.verify.cpp| 2 +- .../deque/deque.cons/deduct.verify.cpp| 2 +- .../forwardlist.cons/deduct.verify.cpp| 2 +- .../list/list.cons/deduct.verify.cpp | 2 +- .../vector/vector.cons/deduct.verify.cpp | 2 +- .../unord.map.cnstr/deduct.verify.cpp | 16 ++--- .../unord.multimap.cnstr/deduct.verify.cpp| 16 ++--- .../unord.multiset.cnstr/deduct.verify.cpp| 16 ++--- .../unord.set.cnstr/deduct.verify.cpp | 16 ++--- .../range.adaptors/range.join/ctad.verify.cpp | 2 +- .../re.regex.construct/deduct.verify.cpp | 4 +- .../optional.object.ctor/deduct.verify.cpp| 2 +- 55 files changed, 316 insertions(+), 240 deletions(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index e1c6d55eeeacd..44035f48cb3f9 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -819,6 +819,8 @@ Bug Fixes to AST Handling - Clang now properly preserves ``FoundDecls`` within a ``ConceptReference``. (#GH82628) - The presence of the ``typename`` keyword is now stored in ``TemplateTemplateParmDecl``. - Fixed malformed AST generated for anonymous union access in templates. (#GH90842) +- Improved preservation of qualifiers and sugar in `TemplateNames`, including + template keyword. Miscellaneous Bug Fixes ^^^ diff --git
[clang] fea7399 - [clang] Fix a warning
Author: Kazu Hirata Date: 2024-05-28T09:03:06-07:00 New Revision: fea7399e97b73a3209fcbe3338d412069769a637 URL: https://github.com/llvm/llvm-project/commit/fea7399e97b73a3209fcbe3338d412069769a637 DIFF: https://github.com/llvm/llvm-project/commit/fea7399e97b73a3209fcbe3338d412069769a637.diff LOG: [clang] Fix a warning This patch fixes: clang/unittests/Interpreter/IncrementalProcessingTest.cpp:39:13: error: unused function 'HostSupportsJit' [-Werror,-Wunused-function] Added: Modified: clang/unittests/Interpreter/IncrementalProcessingTest.cpp Removed: diff --git a/clang/unittests/Interpreter/IncrementalProcessingTest.cpp b/clang/unittests/Interpreter/IncrementalProcessingTest.cpp index 54159173d91e3..f3b091b0c0e6c 100644 --- a/clang/unittests/Interpreter/IncrementalProcessingTest.cpp +++ b/clang/unittests/Interpreter/IncrementalProcessingTest.cpp @@ -36,14 +36,6 @@ using namespace clang; namespace { -static bool HostSupportsJit() { - auto J = llvm::orc::LLJITBuilder().create(); - if (J) -return true; - LLVMConsumeError(llvm::wrap(J.takeError())); - return false; -} - // Incremental processing produces several modules, all using the same "main // file". Make sure CodeGen can cope with that, e.g. for static initializers. const char TestProgram1[] = "extern \"C\" int funcForProg1() { return 17; }\n" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [mlir] Use StringRef::find_first_of(char), etc (NFC) (PR #92841)
https://github.com/kazutakahirata closed https://github.com/llvm/llvm-project/pull/92841 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [mlir] Use StringRef::find_first_of(char), etc (NFC) (PR #92841)
https://github.com/kazutakahirata edited https://github.com/llvm/llvm-project/pull/92841 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [mlir] Use StringRef::find_first_of(char), etc (NFC) (PR #92841)
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/92841 etc (NFC), >From 4711f9f61fd35f3388f665a396f95951ee4b3f5b Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Mon, 20 May 2024 09:10:04 -0700 Subject: [PATCH] Use StringRef::find_first_of(char), etc (NFC) --- clang/utils/TableGen/ClangDiagnosticsEmitter.cpp | 2 +- llvm/lib/Support/LockFileManager.cpp | 2 +- llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp | 4 ++-- mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp| 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp index 4512acfd19a1b..f564689fff7cf 100644 --- a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp +++ b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp @@ -1086,7 +1086,7 @@ Piece *DiagnosticTextBuilder::DiagText::parseDiagText(StringRef , PluralPiece *Plural = New(); do { Text = Text.drop_front(); // '{' or '|' -size_t End = Text.find_first_of(":"); +size_t End = Text.find_first_of(':'); if (End == StringRef::npos) Builder.PrintFatalError("expected ':' while parsing %plural"); ++End; diff --git a/llvm/lib/Support/LockFileManager.cpp b/llvm/lib/Support/LockFileManager.cpp index 083f8d7b37be3..3169aa25ec0d9 100644 --- a/llvm/lib/Support/LockFileManager.cpp +++ b/llvm/lib/Support/LockFileManager.cpp @@ -66,7 +66,7 @@ LockFileManager::readLockFile(StringRef LockFileName) { StringRef Hostname; StringRef PIDStr; std::tie(Hostname, PIDStr) = getToken(MB.getBuffer(), " "); - PIDStr = PIDStr.substr(PIDStr.find_first_not_of(" ")); + PIDStr = PIDStr.substr(PIDStr.find_first_not_of(' ')); int PID; if (!PIDStr.getAsInteger(10, PID)) { auto Owner = std::make_pair(std::string(Hostname), PID); diff --git a/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp b/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp index 4cb76f4347422..06ac98b0c5e13 100644 --- a/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp +++ b/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp @@ -649,9 +649,9 @@ void applySpecificSectionMappings(RuntimeDyld , const FileToSectionIDMap ) { for (StringRef Mapping : SpecificSectionMappings) { -size_t EqualsIdx = Mapping.find_first_of("="); +size_t EqualsIdx = Mapping.find_first_of('='); std::string SectionIDStr = std::string(Mapping.substr(0, EqualsIdx)); -size_t ComaIdx = Mapping.find_first_of(","); +size_t ComaIdx = Mapping.find_first_of(','); if (ComaIdx == StringRef::npos) report_fatal_error("Invalid section specification '" + Mapping + diff --git a/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp b/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp index ed75b4a90536e..4e19274c3da40 100644 --- a/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp +++ b/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp @@ -917,7 +917,7 @@ void MLIRDocument::getCodeActionForDiagnostic( edit.range = lsp::Range(lsp::Position(pos.line, 0)); // Use the indent of the current line for the expected-* diagnostic. - size_t indent = line.find_first_not_of(" "); + size_t indent = line.find_first_not_of(' '); if (indent == StringRef::npos) indent = line.size(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Use SmallString::str (NFC) (PR #92717)
https://github.com/kazutakahirata closed https://github.com/llvm/llvm-project/pull/92717 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Use SmallString::str (NFC) (PR #92717)
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/92717 None >From 46dc6749639faa9734028a61376d05bb38ebebad Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sun, 19 May 2024 22:50:49 -0700 Subject: [PATCH] [clang] Use SmallString::str (NFC) --- clang/lib/ARCMigrate/ARCMT.cpp | 3 +-- clang/lib/ARCMigrate/ObjCMT.cpp | 3 +-- clang/lib/Sema/SemaExpr.cpp | 4 +--- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/clang/lib/ARCMigrate/ARCMT.cpp b/clang/lib/ARCMigrate/ARCMT.cpp index b410d5f3b42a7..5835559bff6b7 100644 --- a/clang/lib/ARCMigrate/ARCMT.cpp +++ b/clang/lib/ARCMigrate/ARCMT.cpp @@ -606,8 +606,7 @@ bool MigrationProcess::applyTransform(TransformFn trans, llvm::raw_svector_ostream vecOS(newText); buf.write(vecOS); std::unique_ptr memBuf( -llvm::MemoryBuffer::getMemBufferCopy( -StringRef(newText.data(), newText.size()), newFname)); +llvm::MemoryBuffer::getMemBufferCopy(newText.str(), newFname)); SmallString<64> filePath(file->getName()); Unit->getFileManager().FixupRelativePath(filePath); Remapper.remap(filePath.str(), std::move(memBuf)); diff --git a/clang/lib/ARCMigrate/ObjCMT.cpp b/clang/lib/ARCMigrate/ObjCMT.cpp index aaf41dc4039cd..4357c8e3f09a5 100644 --- a/clang/lib/ARCMigrate/ObjCMT.cpp +++ b/clang/lib/ARCMigrate/ObjCMT.cpp @@ -1963,8 +1963,7 @@ void ObjCMigrateASTConsumer::HandleTranslationUnit(ASTContext ) { llvm::raw_svector_ostream vecOS(newText); buf.write(vecOS); std::unique_ptr memBuf( -llvm::MemoryBuffer::getMemBufferCopy( -StringRef(newText.data(), newText.size()), file->getName())); +llvm::MemoryBuffer::getMemBufferCopy(newText.str(), file->getName())); SmallString<64> filePath(file->getName()); FileMgr.FixupRelativePath(filePath); Remapper.remap(filePath.str(), std::move(memBuf)); diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 5ecfdee21f09d..f2d0a93d9a1e7 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -3718,9 +3718,7 @@ static Expr *BuildFloatingLiteral(Sema , NumericLiteralParser , APFloat::getSmallest(Format).toString(buffer); } -S.Diag(Loc, diagnostic) - << Ty - << StringRef(buffer.data(), buffer.size()); +S.Diag(Loc, diagnostic) << Ty << buffer.str(); } bool isExact = (result == APFloat::opOK); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [clang] Use operator==(StringRef, StringRef) (NFC) (PR #92708)
https://github.com/kazutakahirata closed https://github.com/llvm/llvm-project/pull/92708 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [clang] Use operator==(StringRef, StringRef) (NFC) (PR #92708)
@@ -435,9 +435,8 @@ static std::string replaceDotDot(StringRef Path) { llvm::sys::path::const_iterator B = llvm::sys::path::begin(Path), E = llvm::sys::path::end(Path); while (B != E) { -if (B->compare(".") == 0) { -} -else if (B->compare("..") == 0) +if (*B == ".") { +} else if (*B == "..") llvm::sys::path::remove_filename(Buffer); else kazutakahirata wrote: Thank you for reviewing the patch! Fixed. https://github.com/llvm/llvm-project/pull/92708 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [clang] Use operator==(StringRef, StringRef) (NFC) (PR #92708)
https://github.com/kazutakahirata updated https://github.com/llvm/llvm-project/pull/92708 >From cf3992f72b340cd402709c24bb8363a2f896635e Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sun, 19 May 2024 09:22:14 -0700 Subject: [PATCH 1/2] [clang] Use operator==(StringRef, StringRef) (NFC) --- clang-tools-extra/modularize/ModularizeUtilities.cpp | 5 ++--- clang/lib/Driver/ToolChains/Clang.cpp| 2 +- clang/utils/TableGen/ClangAttrEmitter.cpp| 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/clang-tools-extra/modularize/ModularizeUtilities.cpp b/clang-tools-extra/modularize/ModularizeUtilities.cpp index 53e8a49d1a548..8752946822fed 100644 --- a/clang-tools-extra/modularize/ModularizeUtilities.cpp +++ b/clang-tools-extra/modularize/ModularizeUtilities.cpp @@ -435,9 +435,8 @@ static std::string replaceDotDot(StringRef Path) { llvm::sys::path::const_iterator B = llvm::sys::path::begin(Path), E = llvm::sys::path::end(Path); while (B != E) { -if (B->compare(".") == 0) { -} -else if (B->compare("..") == 0) +if (*B == ".") { +} else if (*B == "..") llvm::sys::path::remove_filename(Buffer); else llvm::sys::path::append(Buffer, *B); diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index c3e6d563f3bd2..6d2015b2cd156 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -1522,7 +1522,7 @@ static void CollectARMPACBTIOptions(const ToolChain , const ArgList , auto isPAuthLR = [](const char *member) { llvm::AArch64::ExtensionInfo pauthlr_extension = llvm::AArch64::getExtensionByID(llvm::AArch64::AEK_PAUTHLR); -return (pauthlr_extension.Feature.compare(member) == 0); +return pauthlr_extension.Feature == member; }; if (std::any_of(CmdArgs.begin(), CmdArgs.end(), isPAuthLR)) diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp index aafbf1f40949a..ca7630adfbb7b 100644 --- a/clang/utils/TableGen/ClangAttrEmitter.cpp +++ b/clang/utils/TableGen/ClangAttrEmitter.cpp @@ -1845,7 +1845,7 @@ static LateAttrParseKind getLateAttrParseKind(const Record *Attr) { PrintFatalError(Attr, "Field `" + llvm::Twine(LateParsedStr) + "`should only have one super class"); - if (SuperClasses[0]->getName().compare(LateAttrParseKindStr) != 0) + if (SuperClasses[0]->getName() != LateAttrParseKindStr) PrintFatalError(Attr, "Field `" + llvm::Twine(LateParsedStr) + "`should only have type `" + llvm::Twine(LateAttrParseKindStr) + >From 924326be4d21d6eb3f1428ad12184ccd6c8d0b55 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sun, 19 May 2024 16:43:35 -0700 Subject: [PATCH 2/2] Address a comment. --- clang-tools-extra/modularize/ModularizeUtilities.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/clang-tools-extra/modularize/ModularizeUtilities.cpp b/clang-tools-extra/modularize/ModularizeUtilities.cpp index 8752946822fed..b202b3aae8f8a 100644 --- a/clang-tools-extra/modularize/ModularizeUtilities.cpp +++ b/clang-tools-extra/modularize/ModularizeUtilities.cpp @@ -435,10 +435,9 @@ static std::string replaceDotDot(StringRef Path) { llvm::sys::path::const_iterator B = llvm::sys::path::begin(Path), E = llvm::sys::path::end(Path); while (B != E) { -if (*B == ".") { -} else if (*B == "..") +if (*B == "..") llvm::sys::path::remove_filename(Buffer); -else +else if (*B != ".") llvm::sys::path::append(Buffer, *B); ++B; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [clang] Use operator==(StringRef, StringRef) (NFC) (PR #92708)
https://github.com/kazutakahirata edited https://github.com/llvm/llvm-project/pull/92708 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [clang] Use operator==(StringRef, StringRef) (NFC) (PR #92708)
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/92708 StringRef) (NFC), >From cf3992f72b340cd402709c24bb8363a2f896635e Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sun, 19 May 2024 09:22:14 -0700 Subject: [PATCH] [clang] Use operator==(StringRef, StringRef) (NFC) --- clang-tools-extra/modularize/ModularizeUtilities.cpp | 5 ++--- clang/lib/Driver/ToolChains/Clang.cpp| 2 +- clang/utils/TableGen/ClangAttrEmitter.cpp| 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/clang-tools-extra/modularize/ModularizeUtilities.cpp b/clang-tools-extra/modularize/ModularizeUtilities.cpp index 53e8a49d1a548..8752946822fed 100644 --- a/clang-tools-extra/modularize/ModularizeUtilities.cpp +++ b/clang-tools-extra/modularize/ModularizeUtilities.cpp @@ -435,9 +435,8 @@ static std::string replaceDotDot(StringRef Path) { llvm::sys::path::const_iterator B = llvm::sys::path::begin(Path), E = llvm::sys::path::end(Path); while (B != E) { -if (B->compare(".") == 0) { -} -else if (B->compare("..") == 0) +if (*B == ".") { +} else if (*B == "..") llvm::sys::path::remove_filename(Buffer); else llvm::sys::path::append(Buffer, *B); diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index c3e6d563f3bd2..6d2015b2cd156 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -1522,7 +1522,7 @@ static void CollectARMPACBTIOptions(const ToolChain , const ArgList , auto isPAuthLR = [](const char *member) { llvm::AArch64::ExtensionInfo pauthlr_extension = llvm::AArch64::getExtensionByID(llvm::AArch64::AEK_PAUTHLR); -return (pauthlr_extension.Feature.compare(member) == 0); +return pauthlr_extension.Feature == member; }; if (std::any_of(CmdArgs.begin(), CmdArgs.end(), isPAuthLR)) diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp index aafbf1f40949a..ca7630adfbb7b 100644 --- a/clang/utils/TableGen/ClangAttrEmitter.cpp +++ b/clang/utils/TableGen/ClangAttrEmitter.cpp @@ -1845,7 +1845,7 @@ static LateAttrParseKind getLateAttrParseKind(const Record *Attr) { PrintFatalError(Attr, "Field `" + llvm::Twine(LateParsedStr) + "`should only have one super class"); - if (SuperClasses[0]->getName().compare(LateAttrParseKindStr) != 0) + if (SuperClasses[0]->getName() != LateAttrParseKindStr) PrintFatalError(Attr, "Field `" + llvm::Twine(LateParsedStr) + "`should only have type `" + llvm::Twine(LateAttrParseKindStr) + ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] f71749c - [clang] Drop explicit conversions of string literals to StringRef (NFC)
Author: Kazu Hirata Date: 2024-05-16T22:32:06-07:00 New Revision: f71749c5ef8667e3fc23820e8e94864653ea9ac9 URL: https://github.com/llvm/llvm-project/commit/f71749c5ef8667e3fc23820e8e94864653ea9ac9 DIFF: https://github.com/llvm/llvm-project/commit/f71749c5ef8667e3fc23820e8e94864653ea9ac9.diff LOG: [clang] Drop explicit conversions of string literals to StringRef (NFC) We routinely rely on implicit conversions of string literals to StringRef so that we can use operator==(StringRef, StringRef). The LHS here are all known to be of StringRef. Added: Modified: clang/lib/Analysis/ThreadSafetyCommon.cpp clang/lib/Sema/SemaDeclAttr.cpp clang/lib/Serialization/ASTWriter.cpp Removed: diff --git a/clang/lib/Analysis/ThreadSafetyCommon.cpp b/clang/lib/Analysis/ThreadSafetyCommon.cpp index 33f1f466df244..a3b378c42df33 100644 --- a/clang/lib/Analysis/ThreadSafetyCommon.cpp +++ b/clang/lib/Analysis/ThreadSafetyCommon.cpp @@ -177,7 +177,7 @@ CapabilityExpr SExprBuilder::translateAttrExpr(const Expr *AttrExp, return CapabilityExpr(); if (const auto* SLit = dyn_cast(AttrExp)) { -if (SLit->getString() == StringRef("*")) +if (SLit->getString() == "*") // The "*" expr is a universal lock, which essentially turns off // checks until it is removed from the lockset. return CapabilityExpr(new (Arena) til::Wildcard(), StringRef("wildcard"), diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 3760a4c917ad7..30776ff537fb5 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -640,7 +640,7 @@ static void checkAttrArgsAreCapabilityObjs(Sema , Decl *D, if (const auto *StrLit = dyn_cast(ArgExp)) { if (StrLit->getLength() == 0 || - (StrLit->isOrdinary() && StrLit->getString() == StringRef("*"))) { + (StrLit->isOrdinary() && StrLit->getString() == "*")) { // Pass empty strings to the analyzer without warnings. // Treat "*" as the universal lock. Args.push_back(ArgExp); diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index 129bc337c8924..dd5d65b2eb20e 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -1460,7 +1460,7 @@ void ASTWriter::WriteControlBlock(Preprocessor , ASTContext , (!PP.getHeaderSearchInfo() .getHeaderSearchOpts() .ModuleMapFileHomeIsCwd || - WritingModule->Directory->getName() != StringRef("."))) { + WritingModule->Directory->getName() != ".")) { // Module directory. auto Abbrev = std::make_shared(); Abbrev->Add(BitCodeAbbrevOp(MODULE_DIRECTORY)); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] a26fbf3 - [Sema] Use SmallString::empty (NFC)
Author: Kazu Hirata Date: 2024-05-16T22:04:03-07:00 New Revision: a26fbf36a78a703be2da0744131a8d6ecbdb7c67 URL: https://github.com/llvm/llvm-project/commit/a26fbf36a78a703be2da0744131a8d6ecbdb7c67 DIFF: https://github.com/llvm/llvm-project/commit/a26fbf36a78a703be2da0744131a8d6ecbdb7c67.diff LOG: [Sema] Use SmallString::empty (NFC) Added: Modified: clang/lib/Sema/SemaDeclAttr.cpp Removed: diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 777171f4f15f5..3760a4c917ad7 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -3645,7 +3645,7 @@ bool Sema::checkTargetClonesAttrString( llvm::sort(CurFeatures); SmallString<64> Res; for (auto : CurFeatures) { - if (!Res.equals("")) + if (!Res.empty()) Res.append("+"); Res.append(CurFeat); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [flang] [lld] [llvm] Use StringRef::operator== instead of StringRef::equals (NFC) (PR #91864)
https://github.com/kazutakahirata closed https://github.com/llvm/llvm-project/pull/91864 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [flang] [lld] [llvm] Use StringRef::operator== instead of StringRef::equals (NFC) (PR #91864)
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/91864 I'm planning to remove StringRef::equals in favor of StringRef::operator==. - StringRef::operator==/!= outnumber StringRef::equals by a factor of 276 under llvm-project/ in terms of their usage. - The elimination of StringRef::equals brings StringRef closer to std::string_view, which has operator== but not equals. - S == "foo" is more readable than S.equals("foo"), especially for !Long.Expression.equals("str") vs Long.Expression != "str". >From 2beeb9267a23341ff8c313ee52b1ffc36a889ab2 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Fri, 26 Jan 2024 00:05:21 -0800 Subject: [PATCH] Use StringRef::operator== instead of StringRef::equals (NFC) I'm planning to remove StringRef::equals in favor of StringRef::operator==. - StringRef::operator==/!= outnumber StringRef::equals by a factor of 276 under llvm-project/ in terms of their usage. - The elimination of StringRef::equals brings StringRef closer to std::string_view, which has operator== but not equals. - S == "foo" is more readable than S.equals("foo"), especially for !Long.Expression.equals("str") vs Long.Expression != "str". --- bolt/lib/Profile/DataAggregator.cpp| 2 +- bolt/lib/Profile/DataReader.cpp| 3 +-- bolt/lib/Rewrite/DWARFRewriter.cpp | 10 +- bolt/lib/Rewrite/SDTRewriter.cpp | 2 +- clang-tools-extra/clang-tidy/ClangTidyCheck.cpp| 2 +- .../bugprone/ForwardingReferenceOverloadCheck.cpp | 4 ++-- .../clang-tidy/modernize/LoopConvertCheck.cpp | 2 +- .../clang-tidy/readability/IdentifierNamingCheck.cpp | 2 +- .../readability/SuspiciousCallArgumentCheck.cpp| 4 ++-- clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp | 3 +-- .../clang-tidy/utils/RenamerClangTidyCheck.cpp | 2 +- flang/lib/Frontend/CompilerInvocation.cpp | 4 ++-- flang/lib/Optimizer/Builder/IntrinsicCall.cpp | 2 +- flang/lib/Optimizer/CodeGen/CodeGen.cpp| 8 lld/COFF/DebugTypes.cpp| 2 +- lld/ELF/InputSection.cpp | 2 +- lld/ELF/Writer.cpp | 2 +- lld/MachO/Driver.cpp | 2 +- lld/wasm/InputChunks.cpp | 4 ++-- 19 files changed, 30 insertions(+), 32 deletions(-) diff --git a/bolt/lib/Profile/DataAggregator.cpp b/bolt/lib/Profile/DataAggregator.cpp index 2f6380e186e1d..f199d499a180f 100644 --- a/bolt/lib/Profile/DataAggregator.cpp +++ b/bolt/lib/Profile/DataAggregator.cpp @@ -1999,7 +1999,7 @@ std::error_code DataAggregator::parseMMapEvents() { std::pair FileMMapInfo = FileMMapInfoRes.get(); if (FileMMapInfo.second.PID == -1) continue; -if (FileMMapInfo.first.equals("(deleted)")) +if (FileMMapInfo.first == "(deleted)") continue; // Consider only the first mapping of the file for any given PID diff --git a/bolt/lib/Profile/DataReader.cpp b/bolt/lib/Profile/DataReader.cpp index 67f357fe4d3f0..b2511ba103998 100644 --- a/bolt/lib/Profile/DataReader.cpp +++ b/bolt/lib/Profile/DataReader.cpp @@ -1205,8 +1205,7 @@ std::error_code DataReader::parse() { // Add entry data for branches to another function or branches // to entry points (including recursive calls) -if (BI.To.IsSymbol && -(!BI.From.Name.equals(BI.To.Name) || BI.To.Offset == 0)) { +if (BI.To.IsSymbol && (BI.From.Name != BI.To.Name || BI.To.Offset == 0)) { I = GetOrCreateFuncEntry(BI.To.Name); I->second.EntryData.emplace_back(std::move(BI)); } diff --git a/bolt/lib/Rewrite/DWARFRewriter.cpp b/bolt/lib/Rewrite/DWARFRewriter.cpp index 26e4889faadac..9d4297f913f3a 100644 --- a/bolt/lib/Rewrite/DWARFRewriter.cpp +++ b/bolt/lib/Rewrite/DWARFRewriter.cpp @@ -1550,7 +1550,7 @@ CUOffsetMap DWARFRewriter::finalizeTypeSections(DIEBuilder , for (const SectionRef : Obj->sections()) { StringRef Contents = cantFail(Section.getContents()); StringRef Name = cantFail(Section.getName()); -if (Name.equals(".debug_types")) +if (Name == ".debug_types") BC.registerOrUpdateNoteSection(".debug_types", copyByteArray(Contents), Contents.size()); } @@ -1633,10 +1633,10 @@ void DWARFRewriter::finalizeDebugSections( for (const SectionRef : Obj->sections()) { StringRef Contents = cantFail(Secs.getContents()); StringRef Name = cantFail(Secs.getName()); -if (Name.equals(".debug_abbrev")) { +if (Name == ".debug_abbrev") { BC.registerOrUpdateNoteSection(".debug_abbrev", copyByteArray(Contents), Contents.size()); -} else if (Name.equals(".debug_info")) { +} else if (Name == ".debug_info") { BC.registerOrUpdateNoteSection(".debug_info",
[clang] [clang] Use StringRef::operator== instead of StringRef::equals (NFC) (PR #91844)
https://github.com/kazutakahirata closed https://github.com/llvm/llvm-project/pull/91844 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Use StringRef::operator== instead of StringRef::equals (NFC) (PR #91844)
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/91844 I'm planning to remove StringRef::equals in favor of StringRef::operator==. - StringRef::operator==/!= outnumber StringRef::equals by a factor of 24 under clang/ in terms of their usage. - The elimination of StringRef::equals brings StringRef closer to std::string_view, which has operator== but not equals. - S == "foo" is more readable than S.equals("foo"), especially for !Long.Expression.equals("str") vs Long.Expression != "str". >From 8b4328567ca3406d63ff21d599cfb787efc81b26 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Thu, 9 May 2024 23:15:31 -0700 Subject: [PATCH] [clang] Use StringRef::operator== instead of StringRef::equals (NFC) I'm planning to remove StringRef::equals in favor of StringRef::operator==. - StringRef::operator==/!= outnumber StringRef::equals by a factor of 24 under clang/ in terms of their usage. - The elimination of StringRef::equals brings StringRef closer to std::string_view, which has operator== but not equals. - S == "foo" is more readable than S.equals("foo"), especially for !Long.Expression.equals("str") vs Long.Expression != "str". --- clang/include/clang/Basic/IdentifierTable.h | 2 +- clang/include/clang/Basic/SourceManager.h| 6 +++--- clang/lib/ARCMigrate/ObjCMT.cpp | 2 +- clang/lib/AST/PrintfFormatString.cpp | 8 clang/lib/ASTMatchers/Dynamic/Marshallers.cpp| 4 ++-- clang/lib/Basic/Builtins.cpp | 2 +- clang/lib/Basic/Diagnostic.cpp | 3 +-- clang/lib/Basic/LangOptions.cpp | 2 +- clang/lib/Basic/Targets/ARM.cpp | 5 ++--- clang/lib/Basic/Targets/PPC.h| 2 +- clang/lib/Basic/Targets/SystemZ.h| 2 +- clang/lib/Basic/Targets/X86.h| 6 +++--- clang/lib/CodeGen/CodeGenFunction.cpp| 7 +++ clang/lib/Format/ContinuationIndenter.cpp| 2 +- clang/lib/Format/Format.cpp | 2 +- clang/lib/Frontend/CompilerInvocation.cpp| 2 +- clang/lib/Frontend/ModuleDependencyCollector.cpp | 2 +- clang/lib/Lex/PPDirectives.cpp | 4 ++-- clang/lib/Parse/ParseDecl.cpp| 2 +- clang/lib/Parse/ParseDeclCXX.cpp | 4 ++-- clang/lib/Parse/ParseHLSL.cpp| 2 +- clang/lib/Parse/ParseOpenMP.cpp | 4 ++-- clang/lib/Sema/SemaCodeComplete.cpp | 9 - clang/lib/Sema/SemaDecl.cpp | 8 clang/lib/Sema/SemaDeclCXX.cpp | 4 ++-- clang/lib/Sema/SemaStmtAsm.cpp | 2 +- clang/lib/Sema/SemaTemplate.cpp | 4 ++-- .../lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp | 7 +++ .../StaticAnalyzer/Checkers/LLVMConventionsChecker.cpp | 2 +- .../lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp | 2 +- clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp | 4 ++-- .../StaticAnalyzer/Checkers/ObjCContainersASTChecker.cpp | 4 ++-- .../StaticAnalyzer/Checkers/ObjCContainersChecker.cpp| 6 +++--- clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp | 2 +- clang/lib/StaticAnalyzer/Core/CheckerContext.cpp | 2 +- clang/lib/Tooling/Tooling.cpp| 2 +- clang/tools/diagtool/ShowEnabledWarnings.cpp | 4 ++-- clang/tools/diagtool/TreeView.cpp| 2 +- clang/unittests/CodeGen/IRMatchers.h | 2 +- 39 files changed, 68 insertions(+), 73 deletions(-) diff --git a/clang/include/clang/Basic/IdentifierTable.h b/clang/include/clang/Basic/IdentifierTable.h index a893e6f4d3d39..ae9ebd9f59154 100644 --- a/clang/include/clang/Basic/IdentifierTable.h +++ b/clang/include/clang/Basic/IdentifierTable.h @@ -738,7 +738,7 @@ class IdentifierTable { II->Entry = // If this is the 'import' contextual keyword, mark it as such. -if (Name.equals("import")) +if (Name == "import") II->setModulesImport(true); return *II; diff --git a/clang/include/clang/Basic/SourceManager.h b/clang/include/clang/Basic/SourceManager.h index d2ece14da0b11..5258bab584f49 100644 --- a/clang/include/clang/Basic/SourceManager.h +++ b/clang/include/clang/Basic/SourceManager.h @@ -1504,7 +1504,7 @@ class SourceManager : public RefCountedBase { if (Presumed.isInvalid()) return false; StringRef Filename(Presumed.getFilename()); -return Filename.equals(""); +return Filename == ""; } /// Returns whether \p Loc is located in a file. @@ -1513,7 +1513,7 @@ class SourceManager : public RefCountedBase { if (Presumed.isInvalid()) return false;
[clang] [Driver] Use StringRef::operator== instead of StringRef::equals (NFC) (PR #91698)
https://github.com/kazutakahirata closed https://github.com/llvm/llvm-project/pull/91698 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Use StringRef::operator== instead of StringRef::equals (NFC) (PR #91698)
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/91698 I'm planning to remove StringRef::equals in favor of StringRef::operator==. - StringRef::operator==/!= outnumber StringRef::equals by a factor of 13 under clang/ in terms of their usage. - The elimination of StringRef::equals brings StringRef closer to std::string_view, which has operator== but not equals. - S == "foo" is more readable than S.equals("foo"), especially for !Long.Expression.equals("str") vs Long.Expression != "str". >From 5a5154a06a8df048b0edc0d6413c28c565de0867 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Thu, 9 May 2024 00:51:45 -0700 Subject: [PATCH] [Driver] Use StringRef::operator== instead of StringRef::equals (NFC) I'm planning to remove StringRef::equals in favor of StringRef::operator==. - StringRef::operator==/!= outnumber StringRef::equals by a factor of 13 under clang/ in terms of their usage. - The elimination of StringRef::equals brings StringRef closer to std::string_view, which has operator== but not equals. - S == "foo" is more readable than S.equals("foo"), especially for !Long.Expression.equals("str") vs Long.Expression != "str". --- clang/lib/Driver/Driver.cpp| 6 +- clang/lib/Driver/ToolChains/AIX.cpp| 4 +- clang/lib/Driver/ToolChains/AMDGPU.cpp | 2 +- clang/lib/Driver/ToolChains/Clang.cpp | 66 +++--- clang/lib/Driver/ToolChains/CommonArgs.cpp | 2 +- clang/lib/Driver/ToolChains/Flang.cpp | 13 ++--- 6 files changed, 45 insertions(+), 48 deletions(-) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 114320f5d3146..7b36d8e5084cf 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -564,9 +564,9 @@ static llvm::Triple computeTargetTriple(const Driver , StringRef ObjectMode = *ObjectModeValue; llvm::Triple::ArchType AT = llvm::Triple::UnknownArch; - if (ObjectMode.equals("64")) { + if (ObjectMode == "64") { AT = Target.get64BitArchVariant().getArch(); - } else if (ObjectMode.equals("32")) { + } else if (ObjectMode == "32") { AT = Target.get32BitArchVariant().getArch(); } else { D.Diag(diag::err_drv_invalid_object_mode) << ObjectMode; @@ -6694,7 +6694,7 @@ llvm::StringRef clang::driver::getDriverMode(StringRef ProgName, return Opt.consume_front(OptName) ? Opt : ""; } -bool driver::IsClangCL(StringRef DriverMode) { return DriverMode.equals("cl"); } +bool driver::IsClangCL(StringRef DriverMode) { return DriverMode == "cl"; } llvm::Error driver::expandResponseFiles(SmallVectorImpl , bool ClangCLMode, diff --git a/clang/lib/Driver/ToolChains/AIX.cpp b/clang/lib/Driver/ToolChains/AIX.cpp index aab98506adb96..85825e1ea65b1 100644 --- a/clang/lib/Driver/ToolChains/AIX.cpp +++ b/clang/lib/Driver/ToolChains/AIX.cpp @@ -481,8 +481,8 @@ static void addTocDataOptions(const llvm::opt::ArgList , // Currently only supported for small code model. if (TOCDataGloballyinEffect && - (Args.getLastArgValue(options::OPT_mcmodel_EQ).equals("large") || - Args.getLastArgValue(options::OPT_mcmodel_EQ).equals("medium"))) { + (Args.getLastArgValue(options::OPT_mcmodel_EQ) == "large" || + Args.getLastArgValue(options::OPT_mcmodel_EQ) == "medium")) { D.Diag(clang::diag::warn_drv_unsupported_tocdata); return; } diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp index 07965b487ea79..9ffea57b005de 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.cpp +++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp @@ -732,7 +732,7 @@ AMDGPUToolChain::TranslateArgs(const DerivedArgList , StringRef BoundArch, checkTargetID(*DAL); - if (!Args.getLastArgValue(options::OPT_x).equals("cl")) + if (Args.getLastArgValue(options::OPT_x) != "cl") return DAL; // Phase 1 (.cl -> .bc) diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 775dc24e1..449eb9b2a965a 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -1526,7 +1526,7 @@ static void CollectARMPACBTIOptions(const ToolChain , const ArgList , CmdArgs.push_back( Args.MakeArgString(Twine("-msign-return-address=") + Scope)); - if (!Scope.equals("none")) + if (Scope != "none") CmdArgs.push_back( Args.MakeArgString(Twine("-msign-return-address-key=") + Key)); if (BranchProtectionPAuthLR) @@ -1719,10 +1719,9 @@ void Clang::AddAArch64TargetArgs(const ArgList , if (Arg *A = Args.getLastArg(options::OPT_msve_vector_bits_EQ)) { StringRef Val = A->getValue(); const Driver = getToolChain().getDriver(); -if (Val.equals("128") || Val.equals("256") || Val.equals("512") || -Val.equals("1024") || Val.equals("2048") || Val.equals("128+") || -Val.equals("256+") || Val.equals("512+") ||
[clang] 65e2fab - [Sema] Fix warnings
Author: Kazu Hirata Date: 2024-05-07T12:40:19-07:00 New Revision: 65e2fab401a2da55c51d3caceae8478c33f3c60f URL: https://github.com/llvm/llvm-project/commit/65e2fab401a2da55c51d3caceae8478c33f3c60f DIFF: https://github.com/llvm/llvm-project/commit/65e2fab401a2da55c51d3caceae8478c33f3c60f.diff LOG: [Sema] Fix warnings This patch fixes: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp:3937:12: error: unused variable 'CanonType' [-Werror,-Wunused-variable] clang/lib/Sema/SemaTemplate.cpp:9279:18: error: unused variable 'TemplateKWLoc' [-Werror,-Wunused-variable] Added: Modified: clang/lib/Sema/SemaTemplate.cpp clang/lib/Sema/SemaTemplateInstantiateDecl.cpp Removed: diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index b268d7c405df..6231b65bd842 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -9276,8 +9276,6 @@ DeclResult Sema::ActOnClassTemplateSpecialization( // NOTE: KWLoc is the location of the tag keyword. This will instead // store the location of the outermost template keyword in the declaration. - SourceLocation TemplateKWLoc = TemplateParameterLists.size() > 0 -? TemplateParameterLists[0]->getTemplateLoc() : KWLoc; SourceLocation TemplateNameLoc = TemplateId.TemplateNameLoc; SourceLocation LAngleLoc = TemplateId.LAngleLoc; SourceLocation RAngleLoc = TemplateId.RAngleLoc; diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 5315b143215e..884e98a300f5 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -3932,12 +3932,6 @@ TemplateDeclInstantiator::VisitClassTemplateSpecializationDecl( if (SubstQualifier(D, InstD)) return nullptr; - // Build the canonical type that describes the converted template - // arguments of the class template explicit specialization. - QualType CanonType = SemaRef.Context.getTemplateSpecializationType( - TemplateName(InstClassTemplate), CanonicalConverted, - SemaRef.Context.getRecordType(InstD)); - InstD->setAccess(D->getAccess()); InstD->setInstantiationOfMemberClass(D, TSK_ImplicitInstantiation); InstD->setSpecializationKind(D->getSpecializationKind()); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] ca09045 - [Interpreter] Fix warnings
Author: Kazu Hirata Date: 2024-04-20T11:10:49-07:00 New Revision: ca090452d64e229b539a66379a3be891c4e8f3d8 URL: https://github.com/llvm/llvm-project/commit/ca090452d64e229b539a66379a3be891c4e8f3d8 DIFF: https://github.com/llvm/llvm-project/commit/ca090452d64e229b539a66379a3be891c4e8f3d8.diff LOG: [Interpreter] Fix warnings This patch fixes: clang/lib/Interpreter/IncrementalParser.cpp:214:29: error: moving a temporary object prevents copy elision [-Werror,-Wpessimizing-move] clang/lib/Interpreter/IncrementalParser.cpp:232:22: error: moving a temporary object prevents copy elision [-Werror,-Wpessimizing-move] Added: Modified: clang/lib/Interpreter/IncrementalParser.cpp Removed: diff --git a/clang/lib/Interpreter/IncrementalParser.cpp b/clang/lib/Interpreter/IncrementalParser.cpp index c87972719b66b3..b72005d58f8391 100644 --- a/clang/lib/Interpreter/IncrementalParser.cpp +++ b/clang/lib/Interpreter/IncrementalParser.cpp @@ -211,7 +211,7 @@ IncrementalParser::IncrementalParser(Interpreter , CI->ExecuteAction(*Act); if (getCodeGen()) -CachedInCodeGenModule = std::move(GenModule()); +CachedInCodeGenModule = GenModule(); std::unique_ptr IncrConsumer = std::make_unique(Interp, CI->takeASTConsumer()); @@ -229,7 +229,7 @@ IncrementalParser::IncrementalParser(Interpreter , } if (getCodeGen()) { -PTU->TheModule = std::move(GenModule()); +PTU->TheModule = GenModule(); assert(PTU->TheModule && "Failed to create initial PTU"); } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] bd676f0 - [Sema] Fix a warning
Author: Kazu Hirata Date: 2024-04-18T21:00:13-07:00 New Revision: bd676f00b80a064e1d377a758aec5b7ae6814e5f URL: https://github.com/llvm/llvm-project/commit/bd676f00b80a064e1d377a758aec5b7ae6814e5f DIFF: https://github.com/llvm/llvm-project/commit/bd676f00b80a064e1d377a758aec5b7ae6814e5f.diff LOG: [Sema] Fix a warning This patch fixes clang/lib/Sema/SemaStmtAttr.cpp:114:18: error: unused variable 'R' [-Werror,-Wunused-variable] Added: Modified: clang/lib/Sema/SemaStmtAttr.cpp Removed: diff --git a/clang/lib/Sema/SemaStmtAttr.cpp b/clang/lib/Sema/SemaStmtAttr.cpp index fbeffda95cee76..7cd494b42250d4 100644 --- a/clang/lib/Sema/SemaStmtAttr.cpp +++ b/clang/lib/Sema/SemaStmtAttr.cpp @@ -114,6 +114,7 @@ static Attr *handleLoopHintAttr(Sema , Stmt *St, const ParsedAttr , ExprResult R = S.VerifyIntegerConstantExpression(ValueExpr, ); assert(!R.isInvalid() && "unroll count value must be a valid value, it's " "should be checked in Sema::CheckLoopHintExpr"); + (void)R; // The values of 0 and 1 block any unrolling of the loop. if (ValueAPS.isZero() || ValueAPS.isOne()) SetHints(LoopHintAttr::UnrollCount, LoopHintAttr::Disable); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Drop unaligned from calls to readNext (NFC) (PR #88842)
https://github.com/kazutakahirata closed https://github.com/llvm/llvm-project/pull/88842 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Drop unaligned from calls to readNext (NFC) (PR #88842)
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/88842 Now readNext defaults to unaligned accesses. This patch drops unaligned to improve readability. >From 9a07aaf809d8cb2e4b22aa7c4bd5eb274abbfe8a Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Mon, 15 Apr 2024 09:41:29 -0700 Subject: [PATCH] [clang] Drop unaligned from calls to readNext (NFC) Now readNext defaults to unaligned accesses. This patch drops unaligned to improve readability. --- clang/lib/APINotes/APINotesReader.cpp | 137 +++--- clang/lib/Serialization/ASTReader.cpp | 87 +-- clang/lib/Serialization/GlobalModuleIndex.cpp | 12 +- .../lib/Serialization/MultiOnDiskHashTable.h | 4 +- 4 files changed, 98 insertions(+), 142 deletions(-) diff --git a/clang/lib/APINotes/APINotesReader.cpp b/clang/lib/APINotes/APINotesReader.cpp index fbbe9c32ce1258..dfc3beb6fa13ee 100644 --- a/clang/lib/APINotes/APINotesReader.cpp +++ b/clang/lib/APINotes/APINotesReader.cpp @@ -30,23 +30,20 @@ namespace { llvm::VersionTuple ReadVersionTuple(const uint8_t *) { uint8_t NumVersions = (*Data++) & 0x03; - unsigned Major = - endian::readNext(Data); + unsigned Major = endian::readNext(Data); if (NumVersions == 0) return llvm::VersionTuple(Major); - unsigned Minor = - endian::readNext(Data); + unsigned Minor = endian::readNext(Data); if (NumVersions == 1) return llvm::VersionTuple(Major, Minor); unsigned Subminor = - endian::readNext(Data); + endian::readNext(Data); if (NumVersions == 2) return llvm::VersionTuple(Major, Minor, Subminor); - unsigned Build = - endian::readNext(Data); + unsigned Build = endian::readNext(Data); return llvm::VersionTuple(Major, Minor, Subminor, Build); } @@ -71,16 +68,16 @@ class VersionedTableInfo { static std::pair ReadKeyDataLength(const uint8_t *) { unsigned KeyLength = -endian::readNext(Data); +endian::readNext(Data); unsigned DataLength = -endian::readNext(Data); +endian::readNext(Data); return {KeyLength, DataLength}; } static data_type ReadData(internal_key_type Key, const uint8_t *Data, unsigned Length) { unsigned NumElements = -endian::readNext(Data); +endian::readNext(Data); data_type Result; Result.reserve(NumElements); for (unsigned i = 0; i != NumElements; ++i) { @@ -105,14 +102,14 @@ void ReadCommonEntityInfo(const uint8_t *, CommonEntityInfo ) { Info.setSwiftPrivate(static_cast((UnavailableBits >> 3) & 0x01)); unsigned MsgLength = - endian::readNext(Data); + endian::readNext(Data); Info.UnavailableMsg = std::string(reinterpret_cast(Data), reinterpret_cast(Data) + MsgLength); Data += MsgLength; unsigned SwiftNameLength = - endian::readNext(Data); + endian::readNext(Data); Info.SwiftName = std::string(reinterpret_cast(Data), reinterpret_cast(Data) + SwiftNameLength); @@ -124,7 +121,7 @@ void ReadCommonTypeInfo(const uint8_t *, CommonTypeInfo ) { ReadCommonEntityInfo(Data, Info); unsigned SwiftBridgeLength = - endian::readNext(Data); + endian::readNext(Data); if (SwiftBridgeLength > 0) { Info.setSwiftBridge(std::string(reinterpret_cast(Data), SwiftBridgeLength - 1)); @@ -132,7 +129,7 @@ void ReadCommonTypeInfo(const uint8_t *, CommonTypeInfo ) { } unsigned ErrorDomainLength = - endian::readNext(Data); + endian::readNext(Data); if (ErrorDomainLength > 0) { Info.setNSErrorDomain(std::optional(std::string( reinterpret_cast(Data), ErrorDomainLength - 1))); @@ -163,9 +160,9 @@ class IdentifierTableInfo { static std::pair ReadKeyDataLength(const uint8_t *) { unsigned KeyLength = -endian::readNext(Data); +endian::readNext(Data); unsigned DataLength = -endian::readNext(Data); +endian::readNext(Data); return {KeyLength, DataLength}; } @@ -175,8 +172,7 @@ class IdentifierTableInfo { static data_type ReadData(internal_key_type key, const uint8_t *Data, unsigned Length) { -return endian::readNext( -Data); +return endian::readNext(Data); } }; @@ -203,26 +199,24 @@ class ObjCContextIDTableInfo { static std::pair ReadKeyDataLength(const uint8_t *) { unsigned KeyLength = -endian::readNext(Data); +endian::readNext(Data); unsigned DataLength = -endian::readNext(Data); +endian::readNext(Data); return {KeyLength, DataLength}; } static internal_key_type ReadKey(const uint8_t *Data, unsigned Length) { auto ParentCtxID = -endian::readNext(Data); +endian::readNext(Data); auto ContextKind = -endian::readNext(Data); -auto NameID = -endian::readNext(Data); +
[clang] 1189e87 - [CodeGen] Fix a warning
Author: Kazu Hirata Date: 2024-04-03T09:55:45-07:00 New Revision: 1189e87951e59a81ee097eae847c06008276fef1 URL: https://github.com/llvm/llvm-project/commit/1189e87951e59a81ee097eae847c06008276fef1 DIFF: https://github.com/llvm/llvm-project/commit/1189e87951e59a81ee097eae847c06008276fef1.diff LOG: [CodeGen] Fix a warning This patch fixes: clang/lib/CodeGen/CGExpr.cpp:5607:11: error: variable 'Result' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized] Added: Modified: clang/lib/CodeGen/CGExpr.cpp Removed: diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index f70324d11a7562..0c7f48fe00603d 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -5601,7 +5601,7 @@ LValue CodeGenFunction::EmitBinaryOperatorLValue(const BinaryOperator *E) { EmitNullabilityCheck(LV, RV.getScalarVal(), E->getExprLoc()); if (LV.isBitField()) { - llvm::Value *Result; + llvm::Value *Result = nullptr; // If bitfield sanitizers are enabled we want to use the result // to check whether a truncation or sign change has occurred. if (SanOpts.has(SanitizerKind::ImplicitBitfieldConversion)) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix buildbot failure. (PR #86741)
kazutakahirata wrote: > Now I wonder if the fix should be with the (void) or without. Have you tried > it locally to see if you get the same build error? Yes, I just tried your patch and confirmed that the unit test passes without a problem. No, you shouldn't keep `(void)` there. It's there just to silence the warning because the lambda is sitting unused outside the call to `PrintedDeclCXX98Matches`. Once you bring the lambda inside the call to `PrintedDeclCXX98Matches`, the lambda is used, so you shouldn't get a warning. https://github.com/llvm/llvm-project/pull/86741 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix buildbot failure. (PR #86741)
kazutakahirata wrote: > I thought the issue was fixed with the (void) addition! If not, I will merge > this PR immediately. Sorry, I misunderstood. The `void` fix (https://github.com/llvm/llvm-project/commit/577e0ef94fb0b4ba9f97a6f58a1961f7ba247d21) fixes the build error. Meanwhile, I am guessing that you have added lambda functions to control the behavior of `PrintedDeclCXX98Matches`. If that's the case, you should merge this PR. But then again, there is no urgency as the build has been restored. https://github.com/llvm/llvm-project/pull/86741 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix buildbot failure. (PR #86741)
kazutakahirata wrote: Would you mind merging this PR into the LLVM source tree if nothing is blocking you? If something is blocking you, I am happy to revert your original patch on your behalf (along with the `(void)` fix). https://github.com/llvm/llvm-project/pull/86741 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix buildbot failure. (PR #86741)
https://github.com/kazutakahirata approved this pull request. LGTM. Thanks! https://github.com/llvm/llvm-project/pull/86741 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix printing of templated records. (PR #86339)
kazutakahirata wrote: Looking at other examples, should the lambda expression be the last argument to `ASSERT_TRUE`? https://github.com/llvm/llvm-project/pull/86339 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix printing of templated records. (PR #86339)
kazutakahirata wrote: > Creating a PR with `[](PrintingPolicy [[maybe_unused]] & Policy) { > Policy.SuppressTagKeyword = true; };` on those tests. I get this error while running `ninja check-clang-unit`. My build tree is configured with `-DCMAKE_CXX_COMPILER=/usr/bin/clang++` and `-DLLVM_ENABLE_WERROR=On`. By the way: ``` [](PrintingPolicy [[maybe_unused]] ) { Policy.SuppressTagKeyword = false; }; ``` would result in: ``` clang/unittests/AST/DeclPrinterTest.cpp:1394:23: error: 'maybe_unused' attribute cannot be applied to types ``` ``` [[maybe_unused]] [](PrintingPolicy ) { Policy.SuppressTagKeyword = false; }; ``` would result in: ``` clang/unittests/AST/DeclPrinterTest.cpp:1394:5: error: 'maybe_unused' attribute cannot be applied to a statement ``` I don't know where to put `[[maybe_unused]]`. https://github.com/llvm/llvm-project/pull/86339 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix printing of templated records. (PR #86339)
kazutakahirata wrote: I'm getting errors like: ``` llvm-project/clang/unittests/AST/DeclPrinterTest.cpp:1394:3: error: expression result unused [-Werror,-Wunused-value] [](PrintingPolicy ) { Policy.SuppressTagKeyword = false; }; ``` This file being a clang test, I am wondering if this is actually part of the test. Shall we put `[[maybe_unused]]` here? https://github.com/llvm/llvm-project/pull/86339 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AST] Fix a warning (PR #86690)
https://github.com/kazutakahirata closed https://github.com/llvm/llvm-project/pull/86690 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AST] Fix a warning (PR #86690)
kazutakahirata wrote: > I have already merged #86661 Thanks! I'll close this one then. https://github.com/llvm/llvm-project/pull/86690 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [AST] Fix a warning (PR #86690)
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/86690 This patch fixes: clang/lib/AST/TypePrinter.cpp:2307:9: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation] >From f9b781e803e79dd3395dbb796f327923449fa3b8 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Tue, 26 Mar 2024 09:15:45 -0700 Subject: [PATCH] [AST] Fix a warning This patch fixes: clang/lib/AST/TypePrinter.cpp:2307:9: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation] --- clang/lib/AST/TypePrinter.cpp | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp index d9504f9dcb3899..d0ba6066fa0180 100644 --- a/clang/lib/AST/TypePrinter.cpp +++ b/clang/lib/AST/TypePrinter.cpp @@ -2303,10 +2303,10 @@ printTo(raw_ostream , ArrayRef Args, const PrintingPolicy , } else { if (!FirstArg) OS << Comma; -// Tries to print the argument with location info if exists. -printArgument(Arg, Policy, ArgOS, - TemplateParameterList::shouldIncludeTypeForArgument( - Policy, TPL, ParmIndex)); + // Tries to print the argument with location info if exists. + printArgument(Arg, Policy, ArgOS, +TemplateParameterList::shouldIncludeTypeForArgument( +Policy, TPL, ParmIndex)); } StringRef ArgString = ArgOS.str(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 294a6c3 - [clang] Fix a warning
Author: Kazu Hirata Date: 2024-03-20T13:38:26-07:00 New Revision: 294a6c3b650d2411e50487b287b24b7d85847162 URL: https://github.com/llvm/llvm-project/commit/294a6c3b650d2411e50487b287b24b7d85847162 DIFF: https://github.com/llvm/llvm-project/commit/294a6c3b650d2411e50487b287b24b7d85847162.diff LOG: [clang] Fix a warning This patch fixes: clang/lib/CodeGen/CGExprComplex.cpp:1037:14: error: unused variable 'ComplexElementTy' [-Werror,-Wunused-variable] Added: Modified: clang/lib/CodeGen/CGExprComplex.cpp Removed: diff --git a/clang/lib/CodeGen/CGExprComplex.cpp b/clang/lib/CodeGen/CGExprComplex.cpp index 27ddaacc28f522..b873bc6737bb0a 100644 --- a/clang/lib/CodeGen/CGExprComplex.cpp +++ b/clang/lib/CodeGen/CGExprComplex.cpp @@ -1034,7 +1034,6 @@ ComplexPairTy ComplexExprEmitter::EmitBinDiv(const BinOpInfo ) { llvm::Value *OrigLHSi = LHSi; if (!LHSi) LHSi = llvm::Constant::getNullValue(RHSi->getType()); -QualType ComplexElementTy = Op.Ty->castAs()->getElementType(); if (Op.FPFeatures.getComplexRange() == LangOptions::CX_Improved || (Op.FPFeatures.getComplexRange() == LangOptions::CX_Promoted && FPHasBeenPromoted)) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] 92d5f64 - [clang-tidy] Use StringRef::contains (NFC)
Author: Kazu Hirata Date: 2024-02-04T14:57:30-08:00 New Revision: 92d5f644281cba56baa9b42dfc298db7f2c30003 URL: https://github.com/llvm/llvm-project/commit/92d5f644281cba56baa9b42dfc298db7f2c30003 DIFF: https://github.com/llvm/llvm-project/commit/92d5f644281cba56baa9b42dfc298db7f2c30003.diff LOG: [clang-tidy] Use StringRef::contains (NFC) Added: Modified: clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp Removed: diff --git a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp index e6f44dd51b459..5db9e99ab2370 100644 --- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp @@ -658,7 +658,7 @@ std::string IdentifierNamingCheck::HungarianNotation::getEnumPrefix( const auto *ED = cast(ECD->getDeclContext()); std::string Name = ED->getName().str(); - if (std::string::npos != Name.find("enum")) { + if (StringRef(Name).contains("enum")) { Name = Name.substr(strlen("enum"), Name.length() - strlen("enum")); Name = Name.erase(0, Name.find_first_not_of(' ')); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] ffaedc2 - [Basic] Simplify uses of StringRef::consume_front (NFC)
Author: Kazu Hirata Date: 2024-02-04T14:57:26-08:00 New Revision: ffaedc2735cfcf2595fe65a75ed910a9c661391b URL: https://github.com/llvm/llvm-project/commit/ffaedc2735cfcf2595fe65a75ed910a9c661391b DIFF: https://github.com/llvm/llvm-project/commit/ffaedc2735cfcf2595fe65a75ed910a9c661391b.diff LOG: [Basic] Simplify uses of StringRef::consume_front (NFC) Added: Modified: clang/lib/Basic/Targets/AMDGPU.h Removed: diff --git a/clang/lib/Basic/Targets/AMDGPU.h b/clang/lib/Basic/Targets/AMDGPU.h index 90a1516ecdd20..e80589dde0ecb 100644 --- a/clang/lib/Basic/Targets/AMDGPU.h +++ b/clang/lib/Basic/Targets/AMDGPU.h @@ -168,9 +168,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo { return true; } -bool HasLeftParen = false; -if (S.consume_front("{")) - HasLeftParen = true; +bool HasLeftParen = S.consume_front("{"); if (S.empty()) return false; if (S.front() != 'v' && S.front() != 's' && S.front() != 'a') { @@ -196,9 +194,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo { Name = S.data() - 1; return true; } -bool HasLeftBracket = false; -if (S.consume_front("[")) - HasLeftBracket = true; +bool HasLeftBracket = S.consume_front("["); unsigned long long N; if (S.empty() || consumeUnsignedInteger(S, 10, N)) return false; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 34fba4f - [Basic] Use StringRef::contains (NFC)
Author: Kazu Hirata Date: 2024-02-03T21:43:06-08:00 New Revision: 34fba4fb1e32f06237e5024373cc0163cecc3fd5 URL: https://github.com/llvm/llvm-project/commit/34fba4fb1e32f06237e5024373cc0163cecc3fd5 DIFF: https://github.com/llvm/llvm-project/commit/34fba4fb1e32f06237e5024373cc0163cecc3fd5.diff LOG: [Basic] Use StringRef::contains (NFC) Added: Modified: clang/lib/Basic/Sarif.cpp Removed: diff --git a/clang/lib/Basic/Sarif.cpp b/clang/lib/Basic/Sarif.cpp index 1cae7b937bc6e..8c144df341673 100644 --- a/clang/lib/Basic/Sarif.cpp +++ b/clang/lib/Basic/Sarif.cpp @@ -57,8 +57,7 @@ static std::string percentEncodeURICharacter(char C) { // should be written out directly. Otherwise, percent // encode the character and write that out instead of the // reserved character. - if (llvm::isAlnum(C) || - StringRef::npos != StringRef("-._~:@!$&'()*+,;=").find(C)) + if (llvm::isAlnum(C) || StringRef("-._~:@!$&'()*+,;=").contains(C)) return std::string(, 1); return "%" + llvm::toHex(StringRef(, 1)); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 3c93c03 - [Basic] Use StringRef::ends_with (NFC)
Author: Kazu Hirata Date: 2024-02-03T21:43:05-08:00 New Revision: 3c93c037c9ede2eaa0bdea6924c92d646ca0cfe5 URL: https://github.com/llvm/llvm-project/commit/3c93c037c9ede2eaa0bdea6924c92d646ca0cfe5 DIFF: https://github.com/llvm/llvm-project/commit/3c93c037c9ede2eaa0bdea6924c92d646ca0cfe5.diff LOG: [Basic] Use StringRef::ends_with (NFC) Added: Modified: clang/lib/Basic/Targets/X86.cpp Removed: diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp index c6fc17fcc1b70..1966af17904d6 100644 --- a/clang/lib/Basic/Targets/X86.cpp +++ b/clang/lib/Basic/Targets/X86.cpp @@ -139,7 +139,7 @@ bool X86TargetInfo::initFeatureMap( if (Feature.substr(1, 6) == "avx10.") { if (Feature[0] == '+') { HasAVX10 = true; -if (Feature.substr(Feature.size() - 3, 3) == "512") +if (StringRef(Feature).ends_with("512")) HasAVX10_512 = true; LastAVX10 = Feature; } else if (HasAVX10 && Feature == "-avx10.1-256") { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] b67ce7e - [clang] Use StringRef::starts_with (NFC)
Author: Kazu Hirata Date: 2024-01-31T23:54:09-08:00 New Revision: b67ce7e34948d4d954d3cfedb29ffc94861ca0b2 URL: https://github.com/llvm/llvm-project/commit/b67ce7e34948d4d954d3cfedb29ffc94861ca0b2 DIFF: https://github.com/llvm/llvm-project/commit/b67ce7e34948d4d954d3cfedb29ffc94861ca0b2.diff LOG: [clang] Use StringRef::starts_with (NFC) Added: Modified: clang/lib/AST/TypePrinter.cpp clang/lib/Basic/Targets/X86.cpp clang/lib/CodeGen/CGObjCMac.cpp clang/lib/Format/FormatTokenLexer.cpp clang/lib/Frontend/FrontendActions.cpp Removed: diff --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp index 63e56a8296db3..4363280757714 100644 --- a/clang/lib/AST/TypePrinter.cpp +++ b/clang/lib/AST/TypePrinter.cpp @@ -2264,7 +2264,7 @@ printTo(raw_ostream , ArrayRef Args, const PrintingPolicy , // If this is the first argument and its string representation // begins with the global scope specifier ('::foo'), add a space // to avoid printing the diagraph '<:'. -if (FirstArg && !ArgString.empty() && ArgString[0] == ':') +if (FirstArg && ArgString.starts_with(":")) OS << ' '; OS << ArgString; diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp index a68b662d9401a..c6fc17fcc1b70 100644 --- a/clang/lib/Basic/Targets/X86.cpp +++ b/clang/lib/Basic/Targets/X86.cpp @@ -151,7 +151,7 @@ bool X86TargetInfo::initFeatureMap( // Postpone AVX10 features handling after AVX512 settled. UpdatedAVX10FeaturesVec.push_back(Feature); continue; -} else if (!HasAVX512F && Feature.substr(0, 7) == "+avx512") { +} else if (!HasAVX512F && StringRef(Feature).starts_with("+avx512")) { HasAVX512F = true; LastAVX512 = Feature; } else if (HasAVX512F && Feature == "-avx512f") { diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp index 517f7cddebc1a..27d77e9a8a551 100644 --- a/clang/lib/CodeGen/CGObjCMac.cpp +++ b/clang/lib/CodeGen/CGObjCMac.cpp @@ -5038,12 +5038,10 @@ std::string CGObjCCommonMac::GetSectionName(StringRef Section, return ("__DATA," + Section + "," + MachOAttributes).str(); } case llvm::Triple::ELF: -assert(Section.substr(0, 2) == "__" && - "expected the name to begin with __"); +assert(Section.starts_with("__") && "expected the name to begin with __"); return Section.substr(2).str(); case llvm::Triple::COFF: -assert(Section.substr(0, 2) == "__" && - "expected the name to begin with __"); +assert(Section.starts_with("__") && "expected the name to begin with __"); return ("." + Section.substr(2) + "$B").str(); case llvm::Triple::Wasm: case llvm::Triple::GOFF: diff --git a/clang/lib/Format/FormatTokenLexer.cpp b/clang/lib/Format/FormatTokenLexer.cpp index d7de09ef0e12a..a87d0ba3dbbf9 100644 --- a/clang/lib/Format/FormatTokenLexer.cpp +++ b/clang/lib/Format/FormatTokenLexer.cpp @@ -1420,7 +1420,7 @@ void FormatTokenLexer::readRawToken(FormatToken ) { // For formatting, treat unterminated string literals like normal string // literals. if (Tok.is(tok::unknown)) { -if (!Tok.TokenText.empty() && Tok.TokenText[0] == '"') { +if (Tok.TokenText.starts_with("\"")) { Tok.Tok.setKind(tok::string_literal); Tok.IsUnterminatedLiteral = true; } else if (Style.isJavaScript() && Tok.TokenText == "''") { diff --git a/clang/lib/Frontend/FrontendActions.cpp b/clang/lib/Frontend/FrontendActions.cpp index c1d6e71455365..b9ed5dedfa422 100644 --- a/clang/lib/Frontend/FrontendActions.cpp +++ b/clang/lib/Frontend/FrontendActions.cpp @@ -826,8 +826,7 @@ void DumpModuleInfoAction::ExecuteAction() { auto = CI.getFileManager(); auto Buffer = FileMgr.getBufferForFile(getCurrentFile()); StringRef Magic = (*Buffer)->getMemBufferRef().getBuffer(); - bool IsRaw = (Magic.size() >= 4 && Magic[0] == 'C' && Magic[1] == 'P' && -Magic[2] == 'C' && Magic[3] == 'H'); + bool IsRaw = Magic.starts_with("CPCH"); Out << " Module format: " << (IsRaw ? "raw" : "obj") << "\n"; Preprocessor = CI.getPreprocessor(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] 2699c1d - [clang-tidy] Use StringRef::starts_with (NFC)
Author: Kazu Hirata Date: 2024-01-30T22:12:08-08:00 New Revision: 2699c1d7007ea8001bfaae50de01ff33791ce958 URL: https://github.com/llvm/llvm-project/commit/2699c1d7007ea8001bfaae50de01ff33791ce958 DIFF: https://github.com/llvm/llvm-project/commit/2699c1d7007ea8001bfaae50de01ff33791ce958.diff LOG: [clang-tidy] Use StringRef::starts_with (NFC) Added: Modified: clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp Removed: diff --git a/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp index 7a06df454be99..f6714d056518d 100644 --- a/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp @@ -104,7 +104,7 @@ static std::optional getUnderscoreCapitalFixup(StringRef Name) { static bool startsWithUnderscoreInGlobalNamespace(StringRef Name, bool IsInGlobalNamespace, bool IsMacro) { - return !IsMacro && IsInGlobalNamespace && !Name.empty() && Name[0] == '_'; + return !IsMacro && IsInGlobalNamespace && Name.starts_with("_"); } static std::optional ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] a112df2 - [diagtool] Use StringRef::consume_front (NFC)
Author: Kazu Hirata Date: 2024-01-29T18:46:11-08:00 New Revision: a112df28edc449e3e47101ffa7d4b6f0bc040c63 URL: https://github.com/llvm/llvm-project/commit/a112df28edc449e3e47101ffa7d4b6f0bc040c63 DIFF: https://github.com/llvm/llvm-project/commit/a112df28edc449e3e47101ffa7d4b6f0bc040c63.diff LOG: [diagtool] Use StringRef::consume_front (NFC) Added: Modified: clang/tools/diagtool/TreeView.cpp Removed: diff --git a/clang/tools/diagtool/TreeView.cpp b/clang/tools/diagtool/TreeView.cpp index eae16243d3d59..00d1097b5fbfd 100644 --- a/clang/tools/diagtool/TreeView.cpp +++ b/clang/tools/diagtool/TreeView.cpp @@ -160,8 +160,7 @@ int TreeView::run(unsigned int argc, char **argv, llvm::raw_ostream ) { break; case 1: RootGroup = argv[0]; -if (RootGroup.starts_with("-W")) - RootGroup = RootGroup.substr(2); +RootGroup.consume_front("-W"); if (RootGroup == "everything") ShowAll = true; // FIXME: Handle other special warning flags, like -pedantic. ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] a3f379e - [Frontend] Use StringRef::consume_back (NFC)
Author: Kazu Hirata Date: 2024-01-28T18:03:33-08:00 New Revision: a3f379e4e9db9d88265e6dfc464fc3a5be3ae315 URL: https://github.com/llvm/llvm-project/commit/a3f379e4e9db9d88265e6dfc464fc3a5be3ae315 DIFF: https://github.com/llvm/llvm-project/commit/a3f379e4e9db9d88265e6dfc464fc3a5be3ae315.diff LOG: [Frontend] Use StringRef::consume_back (NFC) Added: Modified: clang/lib/Frontend/VerifyDiagnosticConsumer.cpp Removed: diff --git a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp index f508408ba7062c3..304935a0a90b8e9 100644 --- a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp +++ b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp @@ -445,10 +445,9 @@ static bool ParseDirective(StringRef S, ExpectedData *ED, SourceManager , // others. // Regex in initial directive token: -re -if (DToken.ends_with("-re")) { +if (DToken.consume_back("-re")) { D.RegexKind = true; KindStr = "regex"; - DToken = DToken.substr(0, DToken.size()-3); } // Type in initial directive token: -{error|warning|note|no-diagnostics} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 26648da - [ExtractAPI] Use StringRef::starts_with (NFC)
Author: Kazu Hirata Date: 2024-01-28T10:47:05-08:00 New Revision: 26648daeb2ea1e9443d214e3923583efba346603 URL: https://github.com/llvm/llvm-project/commit/26648daeb2ea1e9443d214e3923583efba346603 DIFF: https://github.com/llvm/llvm-project/commit/26648daeb2ea1e9443d214e3923583efba346603.diff LOG: [ExtractAPI] Use StringRef::starts_with (NFC) Added: Modified: clang/include/clang/ExtractAPI/DeclarationFragments.h clang/lib/ExtractAPI/DeclarationFragments.cpp Removed: diff --git a/clang/include/clang/ExtractAPI/DeclarationFragments.h b/clang/include/clang/ExtractAPI/DeclarationFragments.h index 1b78c8b5931e410..b85a5d21d61217e 100644 --- a/clang/include/clang/ExtractAPI/DeclarationFragments.h +++ b/clang/include/clang/ExtractAPI/DeclarationFragments.h @@ -429,8 +429,7 @@ DeclarationFragmentsBuilder::getFunctionSignature(const FunctionT *Function) { Function->getASTContext(), After); if (isa(Function) && dyn_cast(Function)->getDescribedFunctionTemplate() && - ReturnType.begin()->Spelling.substr(0, 14).compare("type-parameter") == - 0) { + StringRef(ReturnType.begin()->Spelling).starts_with("type-parameter")) { std::string ProperArgName = getNameForTemplateArgument(dyn_cast(Function) ->getDescribedFunctionTemplate() diff --git a/clang/lib/ExtractAPI/DeclarationFragments.cpp b/clang/lib/ExtractAPI/DeclarationFragments.cpp index 56c1f5bf5eab068..80a0a498dc40016 100644 --- a/clang/lib/ExtractAPI/DeclarationFragments.cpp +++ b/clang/lib/ExtractAPI/DeclarationFragments.cpp @@ -533,8 +533,8 @@ DeclarationFragmentsBuilder::getFragmentsForVarTemplate(const VarDecl *Var) { DeclarationFragments After; DeclarationFragments ArgumentFragment = getFragmentsForType(T, Var->getASTContext(), After); - if (ArgumentFragment.begin()->Spelling.substr(0, 14).compare( - "type-parameter") == 0) { + if (StringRef(ArgumentFragment.begin()->Spelling) + .starts_with("type-parameter")) { std::string ProperArgName = getNameForTemplateArgument( Var->getDescribedVarTemplate()->getTemplateParameters()->asArray(), ArgumentFragment.begin()->Spelling); @@ -568,8 +568,8 @@ DeclarationFragmentsBuilder::getFragmentsForParam(const ParmVarDecl *Param) { else TypeFragments.append(getFragmentsForType(T, Param->getASTContext(), After)); - if (TypeFragments.begin()->Spelling.substr(0, 14).compare("type-parameter") == - 0) { + if (StringRef(TypeFragments.begin()->Spelling) + .starts_with("type-parameter")) { std::string ProperArgName = getNameForTemplateArgument( dyn_cast(Param->getDeclContext()) ->getDescribedFunctionTemplate() @@ -666,8 +666,8 @@ DeclarationFragmentsBuilder::getFragmentsForFunction(const FunctionDecl *Func) { DeclarationFragments After; auto ReturnValueFragment = getFragmentsForType(Func->getReturnType(), Func->getASTContext(), After); - if (ReturnValueFragment.begin()->Spelling.substr(0, 14).compare( - "type-parameter") == 0) { + if (StringRef(ReturnValueFragment.begin()->Spelling) + .starts_with("type-parameter")) { std::string ProperArgName = getNameForTemplateArgument(Func->getDescribedFunctionTemplate() ->getTemplateParameters() @@ -1001,8 +1001,8 @@ DeclarationFragmentsBuilder::getFragmentsForTemplateArguments( DeclarationFragments ArgumentFragment = getFragmentsForType(TemplateArguments[i].getAsType(), Context, After); -if (ArgumentFragment.begin()->Spelling.substr(0, 14).compare( -"type-parameter") == 0) { +if (StringRef(ArgumentFragment.begin()->Spelling) +.starts_with("type-parameter")) { std::string ProperArgName = getNameForTemplateArgument( TemplateParameters.value(), ArgumentFragment.begin()->Spelling); ArgumentFragment.begin()->Spelling.swap(ProperArgName); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] d1427fb - [Edit] Use StringRef::consume_back (NFC)
Author: Kazu Hirata Date: 2024-01-28T10:47:03-08:00 New Revision: d1427fb6d0e1dbe3b7dbf46c26e43ce96b9b56d5 URL: https://github.com/llvm/llvm-project/commit/d1427fb6d0e1dbe3b7dbf46c26e43ce96b9b56d5 DIFF: https://github.com/llvm/llvm-project/commit/d1427fb6d0e1dbe3b7dbf46c26e43ce96b9b56d5.diff LOG: [Edit] Use StringRef::consume_back (NFC) Added: Modified: clang/lib/Edit/RewriteObjCFoundationAPI.cpp Removed: diff --git a/clang/lib/Edit/RewriteObjCFoundationAPI.cpp b/clang/lib/Edit/RewriteObjCFoundationAPI.cpp index d5bf553e241240d..2e123e89b00365a 100644 --- a/clang/lib/Edit/RewriteObjCFoundationAPI.cpp +++ b/clang/lib/Edit/RewriteObjCFoundationAPI.cpp @@ -697,11 +697,7 @@ static bool getLiteralInfo(SourceRange literalRange, struct Suff { static bool has(StringRef suff, StringRef ) { - if (text.ends_with(suff)) { -text = text.substr(0, text.size()-suff.size()); -return true; - } - return false; + return text.consume_back(suff); } }; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] d6ad67d - [clang-tidy] Use StringRef::consume_back (NFC)
Author: Kazu Hirata Date: 2024-01-27T22:20:24-08:00 New Revision: d6ad67df6bdd1e49f4f57ae8dfa1b05daf081c6e URL: https://github.com/llvm/llvm-project/commit/d6ad67df6bdd1e49f4f57ae8dfa1b05daf081c6e DIFF: https://github.com/llvm/llvm-project/commit/d6ad67df6bdd1e49f4f57ae8dfa1b05daf081c6e.diff LOG: [clang-tidy] Use StringRef::consume_back (NFC) Added: Modified: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp Removed: diff --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp index 0a80c996de5..de2a3b51422a5c3 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp @@ -62,8 +62,7 @@ class ClangTidyDiagnosticRenderer : public DiagnosticRenderer { // appending the check name to the message in ClangTidyContext::diag and // using getCustomDiagID. std::string CheckNameInMessage = " [" + Error.DiagnosticName + "]"; -if (Message.ends_with(CheckNameInMessage)) - Message = Message.substr(0, Message.size() - CheckNameInMessage.size()); +Message.consume_back(CheckNameInMessage); auto TidyMessage = Loc.isValid() ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] fe35d72 - [Driver] Use StringRef::consume_back (NFC)
Author: Kazu Hirata Date: 2024-01-26T23:46:29-08:00 New Revision: fe35d72d8e248f1d29f9c5e503463bb1c4d6f8c6 URL: https://github.com/llvm/llvm-project/commit/fe35d72d8e248f1d29f9c5e503463bb1c4d6f8c6 DIFF: https://github.com/llvm/llvm-project/commit/fe35d72d8e248f1d29f9c5e503463bb1c4d6f8c6.diff LOG: [Driver] Use StringRef::consume_back (NFC) Added: Modified: clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Driver/ToolChains/Flang.cpp clang/lib/Driver/ToolChains/Hexagon.cpp Removed: diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 8092fc050b0ee6d..8d8965fdf76fb8a 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -1747,9 +1747,7 @@ void Clang::AddAArch64TargetArgs(const ArgList , Val.equals("256+") || Val.equals("512+") || Val.equals("1024+") || Val.equals("2048+")) { unsigned Bits = 0; - if (Val.ends_with("+")) -Val = Val.substr(0, Val.size() - 1); - else { + if (!Val.consume_back("+")) { bool Invalid = Val.getAsInteger(10, Bits); (void)Invalid; assert(!Invalid && "Failed to parse value"); CmdArgs.push_back( diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp index 03d68c3df7fb374..b659521df88ff98 100644 --- a/clang/lib/Driver/ToolChains/Flang.cpp +++ b/clang/lib/Driver/ToolChains/Flang.cpp @@ -185,9 +185,7 @@ void Flang::AddAArch64TargetArgs(const ArgList , Val.equals("256+") || Val.equals("512+") || Val.equals("1024+") || Val.equals("2048+")) { unsigned Bits = 0; - if (Val.ends_with("+")) -Val = Val.substr(0, Val.size() - 1); - else { + if (!Val.consume_back("+")) { [[maybe_unused]] bool Invalid = Val.getAsInteger(10, Bits); assert(!Invalid && "Failed to parse value"); CmdArgs.push_back( diff --git a/clang/lib/Driver/ToolChains/Hexagon.cpp b/clang/lib/Driver/ToolChains/Hexagon.cpp index 8a5f8f148993192..fa47c98901e1453 100644 --- a/clang/lib/Driver/ToolChains/Hexagon.cpp +++ b/clang/lib/Driver/ToolChains/Hexagon.cpp @@ -54,8 +54,7 @@ static void handleHVXTargetFeatures(const Driver , const ArgList , auto makeFeature = [](Twine T, bool Enable) -> StringRef { const std::string = T.str(); StringRef Opt(S); -if (Opt.ends_with("=")) - Opt = Opt.drop_back(1); +Opt.consume_back("="); if (Opt.starts_with("mno-")) Opt = Opt.drop_front(4); else if (Opt.starts_with("m")) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] 2b00d44 - [clang-tools-extra] Use SmallString::operator std::string (NFC)
Author: Kazu Hirata Date: 2024-01-26T23:46:24-08:00 New Revision: 2b00d449d2ed09cd0364038115f90a3eb4fd15b5 URL: https://github.com/llvm/llvm-project/commit/2b00d449d2ed09cd0364038115f90a3eb4fd15b5 DIFF: https://github.com/llvm/llvm-project/commit/2b00d449d2ed09cd0364038115f90a3eb4fd15b5.diff LOG: [clang-tools-extra] Use SmallString::operator std::string (NFC) Added: Modified: clang-tools-extra/clang-doc/HTMLGenerator.cpp clang-tools-extra/clang-doc/Representation.cpp clang-tools-extra/clang-doc/tool/ClangDocMain.cpp clang-tools-extra/clang-include-fixer/find-all-symbols/PathConfig.cpp clang-tools-extra/clang-move/Move.cpp clang-tools-extra/clang-move/tool/ClangMove.cpp clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp clang-tools-extra/modularize/ModularizeUtilities.cpp Removed: diff --git a/clang-tools-extra/clang-doc/HTMLGenerator.cpp b/clang-tools-extra/clang-doc/HTMLGenerator.cpp index f6355ccf4f844e..c0faf5f7e8fd9b 100644 --- a/clang-tools-extra/clang-doc/HTMLGenerator.cpp +++ b/clang-tools-extra/clang-doc/HTMLGenerator.cpp @@ -280,7 +280,7 @@ genStylesheetsHTML(StringRef InfoPath, const ClangDocContext ) { llvm::sys::path::filename(FilePath)); // Paths in HTML must be in posix-style llvm::sys::path::native(StylesheetPath, llvm::sys::path::Style::posix); -LinkNode->Attributes.emplace_back("href", std::string(StylesheetPath.str())); +LinkNode->Attributes.emplace_back("href", std::string(StylesheetPath)); Out.emplace_back(std::move(LinkNode)); } return Out; @@ -295,7 +295,7 @@ genJsScriptsHTML(StringRef InfoPath, const ClangDocContext ) { llvm::sys::path::append(ScriptPath, llvm::sys::path::filename(FilePath)); // Paths in HTML must be in posix-style llvm::sys::path::native(ScriptPath, llvm::sys::path::Style::posix); -ScriptNode->Attributes.emplace_back("src", std::string(ScriptPath.str())); +ScriptNode->Attributes.emplace_back("src", std::string(ScriptPath)); Out.emplace_back(std::move(ScriptNode)); } return Out; diff --git a/clang-tools-extra/clang-doc/Representation.cpp b/clang-tools-extra/clang-doc/Representation.cpp index 7dcf646322e6f6..84233c36e15d98 100644 --- a/clang-tools-extra/clang-doc/Representation.cpp +++ b/clang-tools-extra/clang-doc/Representation.cpp @@ -377,7 +377,7 @@ ClangDocContext::ClangDocContext(tooling::ExecutionContext *ECtx, if (SourceRoot.empty()) // If no SourceRoot was provided the current path is used as the default llvm::sys::fs::current_path(SourceRootDir); - this->SourceRoot = std::string(SourceRootDir.str()); + this->SourceRoot = std::string(SourceRootDir); if (!RepositoryUrl.empty()) { this->RepositoryUrl = std::string(RepositoryUrl); if (!RepositoryUrl.empty() && RepositoryUrl.find("http://;) != 0 && diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp index 2ece3e4c071dc0..22bdb5de22d871 100644 --- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp +++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp @@ -197,7 +197,7 @@ Example usage for a project using a compile commands database: llvm::sys::path::native(AssetsPath, IndexJS); llvm::sys::path::append(IndexJS, "index.js"); CDCtx.UserStylesheets.insert(CDCtx.UserStylesheets.begin(), - std::string(DefaultStylesheet.str())); + std::string(DefaultStylesheet)); CDCtx.FilesToCopy.emplace_back(IndexJS.str()); } diff --git a/clang-tools-extra/clang-include-fixer/find-all-symbols/PathConfig.cpp b/clang-tools-extra/clang-include-fixer/find-all-symbols/PathConfig.cpp index 6d52963370ddd7..c3f8000f3a1f2a 100644 --- a/clang-tools-extra/clang-include-fixer/find-all-symbols/PathConfig.cpp +++ b/clang-tools-extra/clang-include-fixer/find-all-symbols/PathConfig.cpp @@ -35,7 +35,7 @@ std::string getIncludePath(const SourceManager , SourceLocation Loc, SmallString<256> CleanedFilePath = FilePath; llvm::sys::path::remove_dots(CleanedFilePath, /*remove_dot_dot=*/false); - return std::string(CleanedFilePath.str()); + return std::string(CleanedFilePath); } } // namespace find_all_symbols diff --git a/clang-tools-extra/clang-move/Move.cpp b/clang-tools-extra/clang-move/Move.cpp index 404acf55e3aa53..1d10348430c281 100644 --- a/clang-tools-extra/clang-move/Move.cpp +++ b/clang-tools-extra/clang-move/Move.cpp @@ -65,7 +65,7 @@ std::string CleanPath(StringRef PathRef) { llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true); // FIXME: figure out why this is necessary. llvm::sys::path::native(Path); - return std::string(Path.str()); + return std::string(Path); } // Make the Path absolute using the CurrentDir if the Path is not an absolute diff --git
[clang] e6bafbe - [TableGen] Use StringRef::consume_{front, back} (NFC)
Author: Kazu Hirata Date: 2024-01-25T18:17:24-08:00 New Revision: e6bafbe72623b3f6fd974bd7f59f38c59f1e9df3 URL: https://github.com/llvm/llvm-project/commit/e6bafbe72623b3f6fd974bd7f59f38c59f1e9df3 DIFF: https://github.com/llvm/llvm-project/commit/e6bafbe72623b3f6fd974bd7f59f38c59f1e9df3.diff LOG: [TableGen] Use StringRef::consume_{front,back} (NFC) Added: Modified: clang/utils/TableGen/ClangDiagnosticsEmitter.cpp clang/utils/TableGen/NeonEmitter.cpp Removed: diff --git a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp index 480c7c83f5f8ef6..4512acfd19a1b9d 100644 --- a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp +++ b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp @@ -873,16 +873,12 @@ struct DiagTextDocPrinter : DiagTextVisitor { auto = RST.back(); StringRef T = P->Text; -while (!T.empty() && T.front() == ' ') { +while (T.consume_front(" ")) RST.back() += " |nbsp| "; - T = T.drop_front(); -} std::string Suffix; -while (!T.empty() && T.back() == ' ') { +while (T.consume_back(" ")) Suffix += " |nbsp| "; - T = T.drop_back(); -} if (!T.empty()) { S += ':'; @@ -1121,9 +1117,8 @@ Piece *DiagnosticTextBuilder::DiagText::parseDiagText(StringRef , if (!isdigit(Text[0])) break; Sub->Modifiers.push_back(parseModifier(Text)); - if (Text.empty() || Text[0] != ',') + if (!Text.consume_front(",")) break; - Text = Text.drop_front(); // ',' assert(!Text.empty() && isdigit(Text[0]) && "expected another modifier"); } diff --git a/clang/utils/TableGen/NeonEmitter.cpp b/clang/utils/TableGen/NeonEmitter.cpp index 53334016c180a12..04e1acc27050044 100644 --- a/clang/utils/TableGen/NeonEmitter.cpp +++ b/clang/utils/TableGen/NeonEmitter.cpp @@ -735,20 +735,15 @@ Type Type::fromTypedefName(StringRef Name) { Type T; T.Kind = SInt; - if (Name.front() == 'u') { + if (Name.consume_front("u")) T.Kind = UInt; -Name = Name.drop_front(); - } - if (Name.starts_with("float")) { + if (Name.consume_front("float")) { T.Kind = Float; -Name = Name.drop_front(5); - } else if (Name.starts_with("poly")) { + } else if (Name.consume_front("poly")) { T.Kind = Poly; -Name = Name.drop_front(4); - } else if (Name.starts_with("bfloat")) { + } else if (Name.consume_front("bfloat")) { T.Kind = BFloat16; -Name = Name.drop_front(6); } else { assert(Name.starts_with("int")); Name = Name.drop_front(3); @@ -765,8 +760,7 @@ Type Type::fromTypedefName(StringRef Name) { T.Bitwidth = T.ElementBitwidth; T.NumVectors = 1; - if (Name.front() == 'x') { -Name = Name.drop_front(); + if (Name.consume_front("x")) { unsigned I = 0; for (I = 0; I < Name.size(); ++I) { if (!isdigit(Name[I])) @@ -780,8 +774,7 @@ Type Type::fromTypedefName(StringRef Name) { // Was scalar. T.NumVectors = 0; } - if (Name.front() == 'x') { -Name = Name.drop_front(); + if (Name.consume_front("x")) { unsigned I = 0; for (I = 0; I < Name.size(); ++I) { if (!isdigit(Name[I])) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] 5b2772e - [clangd] Use SmallString::operator std::string (NFC)
Author: Kazu Hirata Date: 2024-01-24T22:11:54-08:00 New Revision: 5b2772e1fad3fc8b44400b91de4d5bd0724bba75 URL: https://github.com/llvm/llvm-project/commit/5b2772e1fad3fc8b44400b91de4d5bd0724bba75 DIFF: https://github.com/llvm/llvm-project/commit/5b2772e1fad3fc8b44400b91de4d5bd0724bba75.diff LOG: [clangd] Use SmallString::operator std::string (NFC) Added: Modified: clang-tools-extra/clangd/CompileCommands.cpp clang-tools-extra/clangd/Diagnostics.cpp clang-tools-extra/clangd/ExpectedTypes.cpp clang-tools-extra/clangd/FS.cpp clang-tools-extra/clangd/XRefs.cpp clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp Removed: diff --git a/clang-tools-extra/clangd/CompileCommands.cpp b/clang-tools-extra/clangd/CompileCommands.cpp index 166f17e9b3f7125..5b8128fca62668c 100644 --- a/clang-tools-extra/clangd/CompileCommands.cpp +++ b/clang-tools-extra/clangd/CompileCommands.cpp @@ -82,7 +82,7 @@ std::string resolve(std::string Path) { log("Failed to resolve possible symlink {0}", Path); return Path; } - return std::string(Resolved.str()); + return std::string(Resolved); } // Get a plausible full `clang` path. @@ -114,7 +114,7 @@ std::string detectClangPath() { SmallString<128> ClangPath; ClangPath = llvm::sys::path::parent_path(ClangdExecutable); llvm::sys::path::append(ClangPath, "clang"); - return std::string(ClangPath.str()); + return std::string(ClangPath); } // On mac, /usr/bin/clang sets SDKROOT and then invokes the real clang. diff --git a/clang-tools-extra/clangd/Diagnostics.cpp b/clang-tools-extra/clangd/Diagnostics.cpp index 704e61b1e4dd792..d5eca083eb65120 100644 --- a/clang-tools-extra/clangd/Diagnostics.cpp +++ b/clang-tools-extra/clangd/Diagnostics.cpp @@ -663,7 +663,7 @@ static void fillNonLocationData(DiagnosticsEngine::Level DiagLevel, llvm::SmallString<64> Message; Info.FormatDiagnostic(Message); - D.Message = std::string(Message.str()); + D.Message = std::string(Message); D.Severity = DiagLevel; D.Category = DiagnosticIDs::getCategoryNameFromID( DiagnosticIDs::getCategoryNumberForDiag(Info.getID())) @@ -798,7 +798,7 @@ void StoreDiags::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, if (Message.empty()) // either !SyntheticMessage, or we failed to make one. Info.FormatDiagnostic(Message); LastDiag->Fixes.push_back( -Fix{std::string(Message.str()), std::move(Edits), {}}); +Fix{std::string(Message), std::move(Edits), {}}); return true; }; diff --git a/clang-tools-extra/clangd/ExpectedTypes.cpp b/clang-tools-extra/clangd/ExpectedTypes.cpp index deea8a50111e6dc..eaa87096d0d0ef7 100644 --- a/clang-tools-extra/clangd/ExpectedTypes.cpp +++ b/clang-tools-extra/clangd/ExpectedTypes.cpp @@ -71,7 +71,7 @@ std::optional OpaqueType::encode(ASTContext , QualType T) { llvm::SmallString<128> Encoded; if (index::generateUSRForType(QualType(C, 0), Ctx, Encoded)) return std::nullopt; - return OpaqueType(std::string(Encoded.str())); + return OpaqueType(std::string(Encoded)); } OpaqueType::OpaqueType(std::string Data) : Data(std::move(Data)) {} diff --git a/clang-tools-extra/clangd/FS.cpp b/clang-tools-extra/clangd/FS.cpp index c67636dbf2d4ad6..5729b9341d9d4b9 100644 --- a/clang-tools-extra/clangd/FS.cpp +++ b/clang-tools-extra/clangd/FS.cpp @@ -20,7 +20,7 @@ PreambleFileStatusCache::PreambleFileStatusCache(llvm::StringRef MainFilePath){ assert(llvm::sys::path::is_absolute(MainFilePath)); llvm::SmallString<256> MainFileCanonical(MainFilePath); llvm::sys::path::remove_dots(MainFileCanonical, /*remove_dot_dot=*/true); - this->MainFilePath = std::string(MainFileCanonical.str()); + this->MainFilePath = std::string(MainFileCanonical); } void PreambleFileStatusCache::update(const llvm::vfs::FileSystem , diff --git a/clang-tools-extra/clangd/XRefs.cpp b/clang-tools-extra/clangd/XRefs.cpp index 250d571eea191c7..cd909266489a850 100644 --- a/clang-tools-extra/clangd/XRefs.cpp +++ b/clang-tools-extra/clangd/XRefs.cpp @@ -1619,7 +1619,7 @@ std::vector getSymbolInfo(ParsedAST , Position Pos) { } llvm::SmallString<32> USR; if (!index::generateUSRForDecl(D, USR)) { - NewSymbol.USR = std::string(USR.str()); + NewSymbol.USR = std::string(USR); NewSymbol.ID = SymbolID(NewSymbol.USR); } if (const NamedDecl *Def = getDefinition(D)) @@ -1642,7 +1642,7 @@ std::vector getSymbolInfo(ParsedAST , Position Pos) { llvm::SmallString<32> USR; if (!index::generateUSRForMacro(NewMacro.name, M->Info->getDefinitionLoc(), SM, USR)) { - NewMacro.USR = std::string(USR.str()); + NewMacro.USR = std::string(USR); NewMacro.ID = SymbolID(NewMacro.USR); } Results.push_back(std::move(NewMacro)); diff --git
[clang] 196a71e - [Sema] Use StringRef::consume_front (NFC)
Author: Kazu Hirata Date: 2024-01-24T22:11:53-08:00 New Revision: 196a71ec4bc9176ae9ac2d0475a074336e1b736b URL: https://github.com/llvm/llvm-project/commit/196a71ec4bc9176ae9ac2d0475a074336e1b736b DIFF: https://github.com/llvm/llvm-project/commit/196a71ec4bc9176ae9ac2d0475a074336e1b736b.diff LOG: [Sema] Use StringRef::consume_front (NFC) Added: Modified: clang/lib/Sema/SemaDeclAttr.cpp Removed: diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 6f462de4be78ba2..069571fcf786413 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -6690,13 +6690,10 @@ validateSwiftFunctionName(Sema , const ParsedAttr , SourceLocation Loc, // Check whether this will be mapped to a getter or setter of a property. bool IsGetter = false, IsSetter = false; - if (Name.starts_with("getter:")) { + if (Name.consume_front("getter:")) IsGetter = true; -Name = Name.substr(7); - } else if (Name.starts_with("setter:")) { + else if (Name.consume_front("setter:")) IsSetter = true; -Name = Name.substr(7); - } if (Name.back() != ')') { S.Diag(Loc, diag::warn_attr_swift_name_function) << AL; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 5404a37 - [Driver] Use StringRef::consume_front (NFC)
Author: Kazu Hirata Date: 2024-01-24T00:27:33-08:00 New Revision: 5404a3792ed58b94b938bbf5cfe6eeb23c664efc URL: https://github.com/llvm/llvm-project/commit/5404a3792ed58b94b938bbf5cfe6eeb23c664efc DIFF: https://github.com/llvm/llvm-project/commit/5404a3792ed58b94b938bbf5cfe6eeb23c664efc.diff LOG: [Driver] Use StringRef::consume_front (NFC) Added: Modified: clang/lib/Driver/Driver.cpp clang/lib/Driver/ToolChains/CommonArgs.cpp clang/lib/Driver/ToolChains/Hexagon.cpp Removed: diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 7109faa1072de5f..190a73bfd40b68e 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -6482,18 +6482,15 @@ bool Driver::GetReleaseVersion(StringRef Str, unsigned , unsigned , return false; if (Str.empty()) return true; - if (Str[0] != '.') + if (!Str.consume_front(".")) return false; - Str = Str.drop_front(1); - if (Str.consumeInteger(10, Minor)) return false; if (Str.empty()) return true; - if (Str[0] != '.') + if (!Str.consume_front(".")) return false; - Str = Str.drop_front(1); if (Str.consumeInteger(10, Micro)) return false; @@ -6521,9 +6518,8 @@ bool Driver::GetReleaseVersion(StringRef Str, Digits[CurDigit] = Digit; if (Str.empty()) return true; -if (Str[0] != '.') +if (!Str.consume_front(".")) return false; -Str = Str.drop_front(1); CurDigit++; } diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index fadaf3e60c6616a..48534bc1669e44d 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -317,9 +317,7 @@ void tools::handleTargetFeaturesGroup(const Driver , continue; } -bool IsNegative = Name.starts_with("no-"); -if (IsNegative) - Name = Name.substr(3); +bool IsNegative = Name.consume_front("no-"); Features.push_back(Args.MakeArgString((IsNegative ? "-" : "+") + Name)); } diff --git a/clang/lib/Driver/ToolChains/Hexagon.cpp b/clang/lib/Driver/ToolChains/Hexagon.cpp index d1eed931be5f1ee..8a5f8f148993192 100644 --- a/clang/lib/Driver/ToolChains/Hexagon.cpp +++ b/clang/lib/Driver/ToolChains/Hexagon.cpp @@ -801,7 +801,6 @@ StringRef HexagonToolChain::GetTargetCPUVersion(const ArgList ) { CpuArg = A; StringRef CPU = CpuArg ? CpuArg->getValue() : GetDefaultCPU(); - if (CPU.starts_with("hexagon")) -return CPU.substr(sizeof("hexagon") - 1); + CPU.consume_front("hexagon"); return CPU; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 73ff017 - [Sema] Fix a warning
Author: Kazu Hirata Date: 2024-01-22T11:17:21-08:00 New Revision: 73ff017c9b39d8a1ecc350f0572e3274dd4c9146 URL: https://github.com/llvm/llvm-project/commit/73ff017c9b39d8a1ecc350f0572e3274dd4c9146 DIFF: https://github.com/llvm/llvm-project/commit/73ff017c9b39d8a1ecc350f0572e3274dd4c9146.diff LOG: [Sema] Fix a warning This patch fixes: clang/lib/Sema/AnalysisBasedWarnings.cpp:2269:21: error: unused variable 'subExpr' [-Werror,-Wunused-variable] Added: Modified: clang/lib/Sema/AnalysisBasedWarnings.cpp Removed: diff --git a/clang/lib/Sema/AnalysisBasedWarnings.cpp b/clang/lib/Sema/AnalysisBasedWarnings.cpp index 649c3f533b8206..9e9294572df915 100644 --- a/clang/lib/Sema/AnalysisBasedWarnings.cpp +++ b/clang/lib/Sema/AnalysisBasedWarnings.cpp @@ -2266,8 +2266,6 @@ class UnsafeBufferUsageReporter : public UnsafeBufferUsageHandler { if (!isa(destType)) return; -const Expr *subExpr = ECE->getSubExpr(); - const uint64_t dSize = Ctx.getTypeSize(destType.getTypePtr()->getPointeeType()); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Add MainIncludeChar option. (PR #78752)
https://github.com/kazutakahirata updated https://github.com/llvm/llvm-project/pull/78752 >From b6284b7498a283d28bfd5025897041dee23354c8 Mon Sep 17 00:00:00 2001 From: Julien Jorge Date: Fri, 19 Jan 2024 18:44:58 +0100 Subject: [PATCH] [clang-format] Add MainIncludeChar option. Resolves #27008, #39735, #53013, #63619. --- clang/docs/ClangFormatStyleOptions.rst| 19 clang/include/clang/Format/Format.h | 1 + .../clang/Tooling/Inclusions/IncludeStyle.h | 23 clang/lib/Format/Format.cpp | 2 + .../lib/Tooling/Inclusions/HeaderIncludes.cpp | 14 ++- clang/lib/Tooling/Inclusions/IncludeStyle.cpp | 7 ++ clang/unittests/Format/SortIncludesTest.cpp | 106 ++ 7 files changed, 170 insertions(+), 2 deletions(-) diff --git a/clang/docs/ClangFormatStyleOptions.rst b/clang/docs/ClangFormatStyleOptions.rst index 4dc0de3a90f265..ac74db2c2bdf58 100644 --- a/clang/docs/ClangFormatStyleOptions.rst +++ b/clang/docs/ClangFormatStyleOptions.rst @@ -4116,6 +4116,25 @@ the configuration (without a prefix: ``Auto``). A(z); -> z; A(a, b); // will not be expanded. +.. _MainIncludeChar: + +**MainIncludeChar** (``MainIncludeCharDiscriminator``) :versionbadge:`clang-format 18` :ref:`¶ ` + When guessing whether a #include is the "main" include, only the include + directives that use the specified character are considered. + + Possible values: + + * ``MICD_Quote`` (in configuration: ``Quote``) +Main include uses quotes: ``#include "foo.hpp"`` (the default). + + * ``MICD_AngleBracket`` (in configuration: ``AngleBracket``) +Main include uses angle brackets: ``#include ``. + + * ``MICD_Any`` (in configuration: ``Any``) +Main include uses either quotes or angle brackets. + + + .. _MaxEmptyLinesToKeep: **MaxEmptyLinesToKeep** (``Unsigned``) :versionbadge:`clang-format 3.7` :ref:`¶ ` diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h index bc9eecd42f9ebf..a37d5f28c53e9b 100644 --- a/clang/include/clang/Format/Format.h +++ b/clang/include/clang/Format/Format.h @@ -4842,6 +4842,7 @@ struct FormatStyle { R.IncludeStyle.IncludeIsMainRegex && IncludeStyle.IncludeIsMainSourceRegex == R.IncludeStyle.IncludeIsMainSourceRegex && + IncludeStyle.MainIncludeChar == R.IncludeStyle.MainIncludeChar && IndentAccessModifiers == R.IndentAccessModifiers && IndentCaseBlocks == R.IndentCaseBlocks && IndentCaseLabels == R.IndentCaseLabels && diff --git a/clang/include/clang/Tooling/Inclusions/IncludeStyle.h b/clang/include/clang/Tooling/Inclusions/IncludeStyle.h index d6b2b0192477dc..c91e4a6b0ac54a 100644 --- a/clang/include/clang/Tooling/Inclusions/IncludeStyle.h +++ b/clang/include/clang/Tooling/Inclusions/IncludeStyle.h @@ -151,6 +151,21 @@ struct IncludeStyle { /// before any other include. /// \version 10 std::string IncludeIsMainSourceRegex; + + /// Character to consider in the include directives for the main header. + enum MainIncludeCharDiscriminator : int8_t { +/// Main include uses quotes: ``#include "foo.hpp"`` (the default). +MICD_Quote, +/// Main include uses angle brackets: ``#include ``. +MICD_AngleBracket, +/// Main include uses either quotes or angle brackets. +MICD_Any + }; + + /// When guessing whether a #include is the "main" include, only the include + /// directives that use the specified character are considered. + /// \version 18 + MainIncludeCharDiscriminator MainIncludeChar; }; } // namespace tooling @@ -174,6 +189,14 @@ struct ScalarEnumerationTraits< enumeration(IO , clang::tooling::IncludeStyle::IncludeBlocksStyle ); }; +template <> +struct ScalarEnumerationTraits< +clang::tooling::IncludeStyle::MainIncludeCharDiscriminator> { + static void enumeration( + IO , + clang::tooling::IncludeStyle::MainIncludeCharDiscriminator ); +}; + } // namespace yaml } // namespace llvm diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index ff326dc784783b..3d0eaf74e14dba 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -1032,6 +1032,7 @@ template <> struct MappingTraits { IO.mapOptional("MacroBlockBegin", Style.MacroBlockBegin); IO.mapOptional("MacroBlockEnd", Style.MacroBlockEnd); IO.mapOptional("Macros", Style.Macros); +IO.mapOptional("MainIncludeChar", Style.IncludeStyle.MainIncludeChar); IO.mapOptional("MaxEmptyLinesToKeep", Style.MaxEmptyLinesToKeep); IO.mapOptional("NamespaceIndentation", Style.NamespaceIndentation); IO.mapOptional("NamespaceMacros", Style.NamespaceMacros); @@ -1515,6 +1516,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) { {".*", 1, 0, false}}; LLVMStyle.IncludeStyle.IncludeIsMainRegex = "(Test)?$"; LLVMStyle.IncludeStyle.IncludeBlocks = tooling::IncludeStyle::IBS_Preserve; +
[clang-tools-extra] a54463a - [clang-tidy] Use llvm::any_of (NFC)
Author: Kazu Hirata Date: 2024-01-22T00:13:29-08:00 New Revision: a54463a4c6c32810b064e02b39e2c8f0de974006 URL: https://github.com/llvm/llvm-project/commit/a54463a4c6c32810b064e02b39e2c8f0de974006 DIFF: https://github.com/llvm/llvm-project/commit/a54463a4c6c32810b064e02b39e2c8f0de974006.diff LOG: [clang-tidy] Use llvm::any_of (NFC) Added: Modified: clang-tools-extra/clang-tidy/bugprone/EmptyCatchCheck.cpp Removed: diff --git a/clang-tools-extra/clang-tidy/bugprone/EmptyCatchCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/EmptyCatchCheck.cpp index 865c88391b0b4b..ff5b885aa95f81 100644 --- a/clang-tools-extra/clang-tidy/bugprone/EmptyCatchCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/EmptyCatchCheck.cpp @@ -46,7 +46,7 @@ AST_MATCHER_P(CompoundStmt, hasAnyTextFromList, std::vector, StringRef Text = Lexer::getSourceText( CharSourceRange::getTokenRange(Node.getSourceRange()), SM, Context.getLangOpts()); - return std::any_of(List.begin(), List.end(), [&](const StringRef ) { + return llvm::any_of(List, [&](const StringRef ) { return Text.contains_insensitive(Str); }); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 234da20 - [Analysis] Use StringRef::ends_with_insensitive (NFC)
Author: Kazu Hirata Date: 2024-01-22T00:13:27-08:00 New Revision: 234da203779be31c83541d99ee28e01ee422c506 URL: https://github.com/llvm/llvm-project/commit/234da203779be31c83541d99ee28e01ee422c506 DIFF: https://github.com/llvm/llvm-project/commit/234da203779be31c83541d99ee28e01ee422c506.diff LOG: [Analysis] Use StringRef::ends_with_insensitive (NFC) Added: Modified: clang/lib/Analysis/RetainSummaryManager.cpp Removed: diff --git a/clang/lib/Analysis/RetainSummaryManager.cpp b/clang/lib/Analysis/RetainSummaryManager.cpp index 6f50d95b179f41..8d279d969b613e 100644 --- a/clang/lib/Analysis/RetainSummaryManager.cpp +++ b/clang/lib/Analysis/RetainSummaryManager.cpp @@ -1098,7 +1098,7 @@ RetainSummaryManager::getStandardMethodSummary(const ObjCMethodDecl *MD, if (S.isKeywordSelector()) { for (unsigned i = 0, e = S.getNumArgs(); i != e; ++i) { StringRef Slot = S.getNameForSlot(i); - if (Slot.substr(Slot.size() - 8).equals_insensitive("delegate")) { + if (Slot.ends_with_insensitive("delegate")) { if (ResultEff == ObjCInitRetE) ResultEff = RetEffect::MakeNoRetHard(); else ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] f523a55 - [Sema] Use llvm::all_of (NFC)
Author: Kazu Hirata Date: 2024-01-20T18:57:35-08:00 New Revision: f523a5522be221e4657daa111431106083e1c053 URL: https://github.com/llvm/llvm-project/commit/f523a5522be221e4657daa111431106083e1c053 DIFF: https://github.com/llvm/llvm-project/commit/f523a5522be221e4657daa111431106083e1c053.diff LOG: [Sema] Use llvm::all_of (NFC) Added: Modified: clang/lib/Sema/Sema.cpp Removed: diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index 70832d1a14552d..2d4e6d1d058cd7 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -2758,7 +2758,7 @@ bool Sema::isDeclaratorFunctionLike(Declarator ) { return false; LookupQualifiedName(LR, DC); - bool Result = std::all_of(LR.begin(), LR.end(), [](Decl *Dcl) { + bool Result = llvm::all_of(LR, [](Decl *Dcl) { if (NamedDecl *ND = dyn_cast(Dcl)) { ND = ND->getUnderlyingDecl(); return isa(ND) || isa(ND) || ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 9b2c25c - [clang] Use SmallString::operator std::string (NFC)
Author: Kazu Hirata Date: 2024-01-20T18:57:30-08:00 New Revision: 9b2c25c70466d6f081a2915e661840f965b6056a URL: https://github.com/llvm/llvm-project/commit/9b2c25c70466d6f081a2915e661840f965b6056a DIFF: https://github.com/llvm/llvm-project/commit/9b2c25c70466d6f081a2915e661840f965b6056a.diff LOG: [clang] Use SmallString::operator std::string (NFC) Added: Modified: clang/lib/ARCMigrate/FileRemapper.cpp clang/lib/ARCMigrate/ObjCMT.cpp clang/lib/AST/Expr.cpp clang/lib/AST/Mangle.cpp clang/lib/Basic/FileManager.cpp clang/lib/CodeGen/CGCUDANV.cpp clang/lib/CrossTU/CrossTranslationUnit.cpp clang/lib/Lex/ModuleMap.cpp clang/lib/Tooling/ASTDiff/ASTDiff.cpp clang/lib/Tooling/CompilationDatabase.cpp clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp clang/lib/Tooling/Tooling.cpp clang/utils/TableGen/ClangAttrEmitter.cpp clang/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp clang/utils/TableGen/ClangDiagnosticsEmitter.cpp clang/utils/TableGen/MveEmitter.cpp Removed: diff --git a/clang/lib/ARCMigrate/FileRemapper.cpp b/clang/lib/ARCMigrate/FileRemapper.cpp index 7abc862ceecc237..84024c3bafdca01 100644 --- a/clang/lib/ARCMigrate/FileRemapper.cpp +++ b/clang/lib/ARCMigrate/FileRemapper.cpp @@ -43,7 +43,7 @@ std::string FileRemapper::getRemapInfoFile(StringRef outputDir) { assert(!outputDir.empty()); SmallString<128> InfoFile = outputDir; llvm::sys::path::append(InfoFile, "remap"); - return std::string(InfoFile.str()); + return std::string(InfoFile); } bool FileRemapper::initFromDisk(StringRef outputDir, DiagnosticsEngine , diff --git a/clang/lib/ARCMigrate/ObjCMT.cpp b/clang/lib/ARCMigrate/ObjCMT.cpp index ed363a46a200443..0786c81516b2d14 100644 --- a/clang/lib/ARCMigrate/ObjCMT.cpp +++ b/clang/lib/ARCMigrate/ObjCMT.cpp @@ -2201,7 +2201,7 @@ static std::string applyEditsToTemp(FileEntryRef FE, TmpOut.write(NewText.data(), NewText.size()); TmpOut.close(); - return std::string(TempPath.str()); + return std::string(TempPath); } bool arcmt::getFileRemappingsFromFileList( diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index ade403da65dd959..f1efa98e175edf5 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -690,7 +690,7 @@ std::string PredefinedExpr::ComputeName(PredefinedIdentKind IK, if (!Buffer.empty() && Buffer.front() == '\01') return std::string(Buffer.substr(1)); -return std::string(Buffer.str()); +return std::string(Buffer); } return std::string(ND->getIdentifier()->getName()); } @@ -986,7 +986,7 @@ std::string FixedPointLiteral::getValueAsString(unsigned Radix) const { SmallString<64> S; FixedPointValueToString( S, llvm::APSInt::getUnsigned(getValue().getZExtValue()), Scale); - return std::string(S.str()); + return std::string(S); } void CharacterLiteral::print(unsigned Val, CharacterLiteralKind Kind, diff --git a/clang/lib/AST/Mangle.cpp b/clang/lib/AST/Mangle.cpp index d3a6b61fd2bec9c..30cff1ba2e6f379 100644 --- a/clang/lib/AST/Mangle.cpp +++ b/clang/lib/AST/Mangle.cpp @@ -464,7 +464,7 @@ class ASTNameGenerator::Implementation { SmallString<40> Mangled; auto Prefix = getClassSymbolPrefix(Kind, OCD->getASTContext()); llvm::Mangler::getNameWithPrefix(Mangled, Prefix + ClassName, DL); - return std::string(Mangled.str()); + return std::string(Mangled); }; return { diff --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp index d16626b10652136..974c8c22598f630 100644 --- a/clang/lib/Basic/FileManager.cpp +++ b/clang/lib/Basic/FileManager.cpp @@ -532,7 +532,7 @@ void FileManager::fillRealPathName(FileEntry *UFE, llvm::StringRef FileName) { // misleading. We need to clean up the interface here. makeAbsolutePath(AbsPath); llvm::sys::path::remove_dots(AbsPath, /*remove_dot_dot=*/true); - UFE->RealPathName = std::string(AbsPath.str()); + UFE->RealPathName = std::string(AbsPath); } llvm::ErrorOr> diff --git a/clang/lib/CodeGen/CGCUDANV.cpp b/clang/lib/CodeGen/CGCUDANV.cpp index 353370f1d761b92..5b43272bfa62f40 100644 --- a/clang/lib/CodeGen/CGCUDANV.cpp +++ b/clang/lib/CodeGen/CGCUDANV.cpp @@ -893,7 +893,7 @@ llvm::Function *CGNVCUDARuntime::makeModuleCtorFunction() { llvm::raw_svector_ostream OS(ModuleID); OS << ModuleIDPrefix << llvm::format("%" PRIx64, FatbinWrapper->getGUID()); llvm::Constant *ModuleIDConstant = makeConstantArray( -std::string(ModuleID.str()), "", ModuleIDSectionName, 32, /*AddNull=*/true); +std::string(ModuleID), "", ModuleIDSectionName, 32, /*AddNull=*/true); // Create an alias for the FatbinWrapper that nvcc will look for. llvm::GlobalAlias::create(llvm::GlobalValue::ExternalLinkage, diff --git
[clang] 8511436 - [Frontend] Use SmallString::operator std::string (NFC)
Author: Kazu Hirata Date: 2024-01-20T14:30:36-08:00 New Revision: 851143608e2394487d849f56ea1d4b3d3d8f2ead URL: https://github.com/llvm/llvm-project/commit/851143608e2394487d849f56ea1d4b3d3d8f2ead DIFF: https://github.com/llvm/llvm-project/commit/851143608e2394487d849f56ea1d4b3d3d8f2ead.diff LOG: [Frontend] Use SmallString::operator std::string (NFC) Added: Modified: clang/lib/Frontend/CompilerInstance.cpp clang/lib/Frontend/CompilerInvocation.cpp clang/lib/Frontend/LogDiagnosticPrinter.cpp clang/lib/Frontend/Rewrite/FrontendActions.cpp clang/lib/Frontend/TextDiagnosticBuffer.cpp Removed: diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index 6df5521b25cc08..c258870072613c 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -543,7 +543,7 @@ std::string CompilerInstance::getSpecificModuleCachePath(StringRef ModuleHash) { SmallString<256> SpecificModuleCache(getHeaderSearchOpts().ModuleCachePath); if (!SpecificModuleCache.empty() && !getHeaderSearchOpts().DisableModuleHash) llvm::sys::path::append(SpecificModuleCache, ModuleHash); - return std::string(SpecificModuleCache.str()); + return std::string(SpecificModuleCache); } // ASTContext diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index b5e192d54465b1..ed9cd1299eae28 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -3176,7 +3176,7 @@ static bool ParseHeaderSearchArgs(HeaderSearchOptions , ArgList , llvm::sys::fs::make_absolute(WorkingDir, P); } llvm::sys::path::remove_dots(P); - Opts.ModuleCachePath = std::string(P.str()); + Opts.ModuleCachePath = std::string(P); // Only the -fmodule-file== form. for (const auto *A : Args.filtered(OPT_fmodule_file)) { @@ -3217,7 +3217,7 @@ static bool ParseHeaderSearchArgs(HeaderSearchOptions , ArgList , SmallString<32> Buffer; llvm::sys::path::append(Buffer, Opts.Sysroot, llvm::StringRef(A->getValue()).substr(1)); - Path = std::string(Buffer.str()); + Path = std::string(Buffer); } Opts.AddPath(Path, Group, IsFramework, diff --git a/clang/lib/Frontend/LogDiagnosticPrinter.cpp b/clang/lib/Frontend/LogDiagnosticPrinter.cpp index 32fc6cb2acd875..469d1c22633aa3 100644 --- a/clang/lib/Frontend/LogDiagnosticPrinter.cpp +++ b/clang/lib/Frontend/LogDiagnosticPrinter.cpp @@ -134,7 +134,7 @@ void LogDiagnosticPrinter::HandleDiagnostic(DiagnosticsEngine::Level Level, // Format the message. SmallString<100> MessageStr; Info.FormatDiagnostic(MessageStr); - DE.Message = std::string(MessageStr.str()); + DE.Message = std::string(MessageStr); // Set the location information. DE.Filename = ""; diff --git a/clang/lib/Frontend/Rewrite/FrontendActions.cpp b/clang/lib/Frontend/Rewrite/FrontendActions.cpp index 92921bf6f3d7bd..cf5a9437e89e6c 100644 --- a/clang/lib/Frontend/Rewrite/FrontendActions.cpp +++ b/clang/lib/Frontend/Rewrite/FrontendActions.cpp @@ -88,7 +88,7 @@ class FixItRewriteToTemp : public FixItOptions { llvm::sys::fs::createTemporaryFile(llvm::sys::path::filename(Filename), llvm::sys::path::extension(Filename).drop_front(), fd, Path); -return std::string(Path.str()); +return std::string(Path); } }; } // end anonymous namespace diff --git a/clang/lib/Frontend/TextDiagnosticBuffer.cpp b/clang/lib/Frontend/TextDiagnosticBuffer.cpp index 90f273e65f88f7..681bc25f46b832 100644 --- a/clang/lib/Frontend/TextDiagnosticBuffer.cpp +++ b/clang/lib/Frontend/TextDiagnosticBuffer.cpp @@ -32,20 +32,20 @@ void TextDiagnosticBuffer::HandleDiagnostic(DiagnosticsEngine::Level Level, "Diagnostic not handled during diagnostic buffering!"); case DiagnosticsEngine::Note: All.emplace_back(Level, Notes.size()); -Notes.emplace_back(Info.getLocation(), std::string(Buf.str())); +Notes.emplace_back(Info.getLocation(), std::string(Buf)); break; case DiagnosticsEngine::Warning: All.emplace_back(Level, Warnings.size()); -Warnings.emplace_back(Info.getLocation(), std::string(Buf.str())); +Warnings.emplace_back(Info.getLocation(), std::string(Buf)); break; case DiagnosticsEngine::Remark: All.emplace_back(Level, Remarks.size()); -Remarks.emplace_back(Info.getLocation(), std::string(Buf.str())); +Remarks.emplace_back(Info.getLocation(), std::string(Buf)); break; case DiagnosticsEngine::Error: case DiagnosticsEngine::Fatal: All.emplace_back(Level, Errors.size()); -Errors.emplace_back(Info.getLocation(), std::string(Buf.str())); +Errors.emplace_back(Info.getLocation(), std::string(Buf)); break;
[clang] 84cb8ea - [Sema] Use llvm::is_contained (NFC)
Author: Kazu Hirata Date: 2024-01-20T14:30:30-08:00 New Revision: 84cb8eaeeb108234be1c8498688a014b87fd431d URL: https://github.com/llvm/llvm-project/commit/84cb8eaeeb108234be1c8498688a014b87fd431d DIFF: https://github.com/llvm/llvm-project/commit/84cb8eaeeb108234be1c8498688a014b87fd431d.diff LOG: [Sema] Use llvm::is_contained (NFC) Added: Modified: clang/lib/Sema/SemaDeclAttr.cpp Removed: diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index a482919356e1bce..2a73567c2f0513c 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -9008,10 +9008,8 @@ static void handleArmNewAttr(Sema , Decl *D, const ParsedAttr ) { return; } -if (std::find(NewState.begin(), NewState.end(), StateName) == -NewState.end()) { // Avoid adding duplicates. +if (!llvm::is_contained(NewState, StateName)) // Avoid adding duplicates. NewState.push_back(StateName); -} } if (auto *FPT = dyn_cast(D->getFunctionType())) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 10886a8 - [Driver] Use SmallString::operator std::string (NFC)
Author: Kazu Hirata Date: 2024-01-19T22:24:09-08:00 New Revision: 10886a8f0a054d8d97708fcfbe03313d81fae35e URL: https://github.com/llvm/llvm-project/commit/10886a8f0a054d8d97708fcfbe03313d81fae35e DIFF: https://github.com/llvm/llvm-project/commit/10886a8f0a054d8d97708fcfbe03313d81fae35e.diff LOG: [Driver] Use SmallString::operator std::string (NFC) Added: Modified: clang/lib/Driver/Driver.cpp clang/lib/Driver/SanitizerArgs.cpp clang/lib/Driver/ToolChain.cpp clang/lib/Driver/ToolChains/AVR.cpp clang/lib/Driver/ToolChains/CSKYToolChain.cpp clang/lib/Driver/ToolChains/Cuda.cpp clang/lib/Driver/ToolChains/Fuchsia.cpp clang/lib/Driver/ToolChains/Hexagon.cpp clang/lib/Driver/ToolChains/MSP430.cpp clang/lib/Driver/ToolChains/MSVC.cpp clang/lib/Driver/ToolChains/MipsLinux.cpp clang/lib/Driver/ToolChains/OpenBSD.cpp clang/lib/Driver/ToolChains/PS4CPU.cpp clang/lib/Driver/ToolChains/RISCVToolchain.cpp Removed: diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 35d563b9a87fac4..10f7b99a59bd61a 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -186,7 +186,7 @@ std::string Driver::GetResourcesPath(StringRef BinaryPath, CLANG_VERSION_MAJOR_STRING); } - return std::string(P.str()); + return std::string(P); } Driver::Driver(StringRef ClangExecutable, StringRef TargetTriple, @@ -1831,7 +1831,7 @@ void Driver::generateCompilationDiagnostics( ScriptOS << "\n# Additional information: " << AdditionalInformation << "\n"; if (Report) - Report->TemporaryFiles.push_back(std::string(Script.str())); + Report->TemporaryFiles.push_back(std::string(Script)); Diag(clang::diag::note_drv_command_failed_diag_msg) << Script; } @@ -6073,17 +6073,17 @@ std::string Driver::GetFilePath(StringRef Name, const ToolChain ) const { SmallString<128> R(ResourceDir); llvm::sys::path::append(R, Name); if (llvm::sys::fs::exists(Twine(R))) -return std::string(R.str()); +return std::string(R); SmallString<128> P(TC.getCompilerRTPath()); llvm::sys::path::append(P, Name); if (llvm::sys::fs::exists(Twine(P))) -return std::string(P.str()); +return std::string(P); SmallString<128> D(Dir); llvm::sys::path::append(D, "..", Name); if (llvm::sys::fs::exists(Twine(D))) -return std::string(D.str()); +return std::string(D); if (auto P = SearchPaths(TC.getLibraryPaths())) return *P; @@ -6120,11 +6120,11 @@ std::string Driver::GetProgramPath(StringRef Name, const ToolChain ) const { if (llvm::sys::fs::is_directory(PrefixDir)) { SmallString<128> P(PrefixDir); if (ScanDirForExecutable(P, Name)) -return std::string(P.str()); +return std::string(P); } else { SmallString<128> P((PrefixDir + Name).str()); if (llvm::sys::fs::can_execute(Twine(P))) -return std::string(P.str()); +return std::string(P); } } @@ -6140,7 +6140,7 @@ std::string Driver::GetProgramPath(StringRef Name, const ToolChain ) const { for (const auto : List) { SmallString<128> P(Path); if (ScanDirForExecutable(P, TargetSpecificExecutable)) -return std::string(P.str()); +return std::string(P); } // Fall back to the path @@ -6160,7 +6160,7 @@ std::string Driver::GetTemporaryPath(StringRef Prefix, StringRef Suffix) const { return ""; } - return std::string(Path.str()); + return std::string(Path); } std::string Driver::GetTemporaryDirectory(StringRef Prefix) const { @@ -6171,7 +6171,7 @@ std::string Driver::GetTemporaryDirectory(StringRef Prefix) const { return ""; } - return std::string(Path.str()); + return std::string(Path); } std::string Driver::GetClPchPath(Compilation , StringRef BaseName) const { @@ -6193,7 +6193,7 @@ std::string Driver::GetClPchPath(Compilation , StringRef BaseName) const { Output = BaseName; llvm::sys::path::replace_extension(Output, ".pch"); } - return std::string(Output.str()); + return std::string(Output); } const ToolChain ::getToolChain(const ArgList , diff --git a/clang/lib/Driver/SanitizerArgs.cpp b/clang/lib/Driver/SanitizerArgs.cpp index 9d6ea371f9f6dd5..56d497eb4c32b86 100644 --- a/clang/lib/Driver/SanitizerArgs.cpp +++ b/clang/lib/Driver/SanitizerArgs.cpp @@ -190,7 +190,7 @@ static void addDefaultIgnorelists(const Driver , SanitizerMask Kinds, clang::SmallString<64> Path(D.ResourceDir); llvm::sys::path::append(Path, "share", BL.File); if (D.getVFS().exists(Path)) - IgnorelistFiles.push_back(std::string(Path.str())); + IgnorelistFiles.push_back(std::string(Path)); else if (BL.Mask == SanitizerKind::CFI && DiagnoseErrors) // If cfi_ignorelist.txt cannot be found in the resource dir, driver
Re: [clang] cf3421d - [Format] Fix a warning
Good point! Thanks! On Wed, Jan 17, 2024 at 3:34 PM David Blaikie wrote: > In general, if the lambda is only used within its scope, I'd suggest > switching to a default ref capture "[&]" to reduce maintenance burden of > keeping the capture list up to date. > > On Thu, Jan 11, 2024 at 12:09 PM Kazu Hirata via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> >> Author: Kazu Hirata >> Date: 2024-01-11T12:09:01-08:00 >> New Revision: cf3421de587d7c947e8f6b5c754393f85a395747 >> >> URL: >> https://github.com/llvm/llvm-project/commit/cf3421de587d7c947e8f6b5c754393f85a395747 >> DIFF: >> https://github.com/llvm/llvm-project/commit/cf3421de587d7c947e8f6b5c754393f85a395747.diff >> >> LOG: [Format] Fix a warning >> >> This patch fixes: >> >> clang/unittests/Format/TokenAnnotatorTest.cpp:2181:29: error: lambda >> capture 'Style' is not used [-Werror,-Wunused-lambda-capture] >> >> Added: >> >> >> Modified: >> clang/unittests/Format/TokenAnnotatorTest.cpp >> >> Removed: >> >> >> >> >> >> diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp >> b/clang/unittests/Format/TokenAnnotatorTest.cpp >> index 33a320f7bb06e6..1ee209444067d6 100644 >> --- a/clang/unittests/Format/TokenAnnotatorTest.cpp >> +++ b/clang/unittests/Format/TokenAnnotatorTest.cpp >> @@ -2178,7 +2178,7 @@ TEST_F(TokenAnnotatorTest, >> UnderstandTableGenTokens) { >> >>TestLexer Lexer(Allocator, Buffers, Style); >>AdditionalKeywords Keywords(Lexer.IdentTable); >> - auto Annotate = [, ](llvm::StringRef Code) { >> + auto Annotate = [](llvm::StringRef Code) { >> return Lexer.annotate(Code); >>}; >> >> >> >> >> ___ >> cfe-commits mailing list >> cfe-commits@lists.llvm.org >> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits >> > ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] 481fd41 - [modularize] Use SmallString::operator std::string (NFC)
Author: Kazu Hirata Date: 2024-01-15T21:25:51-08:00 New Revision: 481fd41aaa343e2ee2c86c2444fbc2e5ad1f3831 URL: https://github.com/llvm/llvm-project/commit/481fd41aaa343e2ee2c86c2444fbc2e5ad1f3831 DIFF: https://github.com/llvm/llvm-project/commit/481fd41aaa343e2ee2c86c2444fbc2e5ad1f3831.diff LOG: [modularize] Use SmallString::operator std::string (NFC) Added: Modified: clang-tools-extra/modularize/ModularizeUtilities.cpp Removed: diff --git a/clang-tools-extra/modularize/ModularizeUtilities.cpp b/clang-tools-extra/modularize/ModularizeUtilities.cpp index 25de9c9dd05ac9..d25bb09b8cad5b 100644 --- a/clang-tools-extra/modularize/ModularizeUtilities.cpp +++ b/clang-tools-extra/modularize/ModularizeUtilities.cpp @@ -195,7 +195,7 @@ std::error_code ModularizeUtilities::loadSingleHeaderListsAndDependencies( // Get canonical form. HeaderFileName = getCanonicalPath(HeaderFileName); // Save the resulting header file path and dependencies. -HeaderFileNames.push_back(std::string(HeaderFileName.str())); +HeaderFileNames.push_back(std::string(HeaderFileName)); Dependencies[HeaderFileName.str()] = Dependents; } return std::error_code(); @@ -248,7 +248,7 @@ std::error_code ModularizeUtilities::loadProblemHeaderList( // Get canonical form. HeaderFileName = getCanonicalPath(HeaderFileName); // Save the resulting header file path. -ProblemFileNames.push_back(std::string(HeaderFileName.str())); +ProblemFileNames.push_back(std::string(HeaderFileName)); } return std::error_code(); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] d34ac45 - [Basic] Use StringRef::consume_front (NFC)
Author: Kazu Hirata Date: 2024-01-15T21:25:48-08:00 New Revision: d34ac450a74657f03e15dd6776b406d1f31e054a URL: https://github.com/llvm/llvm-project/commit/d34ac450a74657f03e15dd6776b406d1f31e054a DIFF: https://github.com/llvm/llvm-project/commit/d34ac450a74657f03e15dd6776b406d1f31e054a.diff LOG: [Basic] Use StringRef::consume_front (NFC) Added: Modified: clang/lib/Basic/Targets/AMDGPU.h clang/lib/Basic/Warnings.cpp Removed: diff --git a/clang/lib/Basic/Targets/AMDGPU.h b/clang/lib/Basic/Targets/AMDGPU.h index 1819ba544ccf84..90a1516ecdd20d 100644 --- a/clang/lib/Basic/Targets/AMDGPU.h +++ b/clang/lib/Basic/Targets/AMDGPU.h @@ -169,10 +169,8 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo { } bool HasLeftParen = false; -if (S.front() == '{') { +if (S.consume_front("{")) HasLeftParen = true; - S = S.drop_front(); -} if (S.empty()) return false; if (S.front() != 'v' && S.front() != 's' && S.front() != 'a') { @@ -199,29 +197,24 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo { return true; } bool HasLeftBracket = false; -if (!S.empty() && S.front() == '[') { +if (S.consume_front("[")) HasLeftBracket = true; - S = S.drop_front(); -} unsigned long long N; if (S.empty() || consumeUnsignedInteger(S, 10, N)) return false; -if (!S.empty() && S.front() == ':') { +if (S.consume_front(":")) { if (!HasLeftBracket) return false; - S = S.drop_front(); unsigned long long M; if (consumeUnsignedInteger(S, 10, M) || N >= M) return false; } if (HasLeftBracket) { - if (S.empty() || S.front() != ']') + if (!S.consume_front("]")) return false; - S = S.drop_front(); } -if (S.empty() || S.front() != '}') +if (!S.consume_front("}")) return false; -S = S.drop_front(); if (!S.empty()) return false; // Found {vn}, {sn}, {an}, {v[n]}, {s[n]}, {a[n]}, {v[n:m]}, {s[n:m]} diff --git a/clang/lib/Basic/Warnings.cpp b/clang/lib/Basic/Warnings.cpp index 92954cab6fb040..5a5ac555633886 100644 --- a/clang/lib/Basic/Warnings.cpp +++ b/clang/lib/Basic/Warnings.cpp @@ -199,8 +199,7 @@ void clang::ProcessWarningOptions(DiagnosticsEngine , // Check to see if this warning starts with "no-", if so, this is a // negative form of the option. - bool IsPositive = !Opt.starts_with("no-"); - if (!IsPositive) Opt = Opt.substr(3); + bool IsPositive = !Opt.consume_front("no-"); auto Severity = IsPositive ? diag::Severity::Remark : diag::Severity::Ignored; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] 21edd38 - [clang-doc] Use SmallString::operator std::string (NFC)
Author: Kazu Hirata Date: 2024-01-14T12:17:56-08:00 New Revision: 21edd381e403079baa2d01754e3d3ae7b3469932 URL: https://github.com/llvm/llvm-project/commit/21edd381e403079baa2d01754e3d3ae7b3469932 DIFF: https://github.com/llvm/llvm-project/commit/21edd381e403079baa2d01754e3d3ae7b3469932.diff LOG: [clang-doc] Use SmallString::operator std::string (NFC) Added: Modified: clang-tools-extra/clang-doc/HTMLGenerator.cpp Removed: diff --git a/clang-tools-extra/clang-doc/HTMLGenerator.cpp b/clang-tools-extra/clang-doc/HTMLGenerator.cpp index d2466857e5110e..f6355ccf4f844e 100644 --- a/clang-tools-extra/clang-doc/HTMLGenerator.cpp +++ b/clang-tools-extra/clang-doc/HTMLGenerator.cpp @@ -457,7 +457,7 @@ writeFileDefinition(const Location , Node->Children.emplace_back(std::make_unique(" of file ")); auto LocFileNode = std::make_unique( HTMLTag::TAG_A, llvm::sys::path::filename(FileURL)); - LocFileNode->Attributes.emplace_back("href", std::string(FileURL.str())); + LocFileNode->Attributes.emplace_back("href", std::string(FileURL)); Node->Children.emplace_back(std::move(LocFileNode)); return Node; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] bc27f35 - [clang-tidy] Use StringRef::consume_front (NFC)
Author: Kazu Hirata Date: 2024-01-14T12:17:52-08:00 New Revision: bc27f3573d61012771aa3fee2427f0dd5b8a1288 URL: https://github.com/llvm/llvm-project/commit/bc27f3573d61012771aa3fee2427f0dd5b8a1288 DIFF: https://github.com/llvm/llvm-project/commit/bc27f3573d61012771aa3fee2427f0dd5b8a1288.diff LOG: [clang-tidy] Use StringRef::consume_front (NFC) Added: Modified: clang-tools-extra/clang-tidy/GlobList.cpp Removed: diff --git a/clang-tools-extra/clang-tidy/GlobList.cpp b/clang-tools-extra/clang-tidy/GlobList.cpp index 694db35106fd63..dfe3f7c505b174 100644 --- a/clang-tools-extra/clang-tidy/GlobList.cpp +++ b/clang-tools-extra/clang-tidy/GlobList.cpp @@ -16,11 +16,7 @@ namespace clang::tidy { // from the GlobList. static bool consumeNegativeIndicator(StringRef ) { GlobList = GlobList.trim(); - if (GlobList.starts_with("-")) { -GlobList = GlobList.substr(1); -return true; - } - return false; + return GlobList.consume_front("-"); } // Converts first glob from the comma-separated list of globs to Regex and ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 6bd488d - [CodeGen] Use DenseMap::contains (NFC)
Author: Kazu Hirata Date: 2024-01-12T22:08:28-08:00 New Revision: 6bd488dd24cc06daea0d9a9dea0e2843f4c8d38e URL: https://github.com/llvm/llvm-project/commit/6bd488dd24cc06daea0d9a9dea0e2843f4c8d38e DIFF: https://github.com/llvm/llvm-project/commit/6bd488dd24cc06daea0d9a9dea0e2843f4c8d38e.diff LOG: [CodeGen] Use DenseMap::contains (NFC) Added: Modified: clang/lib/CodeGen/CoverageMappingGen.cpp Removed: diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp index b245abd16c3f4a..916016601a9327 100644 --- a/clang/lib/CodeGen/CoverageMappingGen.cpp +++ b/clang/lib/CodeGen/CoverageMappingGen.cpp @@ -730,8 +730,8 @@ struct MCDCCoverageBuilder { return; // If binary expression is disqualified, don't do mapping. -if (NestLevel.empty() && MCDCBitmapMap.find(CodeGenFunction::stripCond( - E)) == MCDCBitmapMap.end()) +if (NestLevel.empty() && +!MCDCBitmapMap.contains(CodeGenFunction::stripCond(E))) NotMapped = true; // Push Stmt on 'NestLevel' stack to keep track of nest location. @@ -744,7 +744,7 @@ struct MCDCCoverageBuilder { // If the operator itself has an assigned ID, this means it represents a // larger subtree. In this case, pop its ID out of the RHS stack and // assign that ID to its LHS node. Its RHS will receive a new ID. -if (CondIDs.find(CodeGenFunction::stripCond(E)) != CondIDs.end()) { +if (CondIDs.contains(CodeGenFunction::stripCond(E))) { // If Stmt has an ID, assign its ID to LHS CondIDs[CodeGenFunction::stripCond(E->getLHS())] = CondIDs[E]; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] 771ab15 - [clang-tidy] Use StringRef::ltrim (NFC)
Author: Kazu Hirata Date: 2024-01-12T18:39:51-08:00 New Revision: 771ab15e4881b9c4adaabb694d901c3dbeb1fa47 URL: https://github.com/llvm/llvm-project/commit/771ab15e4881b9c4adaabb694d901c3dbeb1fa47 DIFF: https://github.com/llvm/llvm-project/commit/771ab15e4881b9c4adaabb694d901c3dbeb1fa47.diff LOG: [clang-tidy] Use StringRef::ltrim (NFC) Added: Modified: clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp Removed: diff --git a/clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp b/clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp index 80580bc9888a8c..3540c496515bed 100644 --- a/clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp +++ b/clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp @@ -281,7 +281,7 @@ void HeaderGuardCheck::registerPPCallbacks(const SourceManager , std::string HeaderGuardCheck::sanitizeHeaderGuard(StringRef Guard) { // Only reserved identifiers are allowed to start with an '_'. - return Guard.drop_while([](char C) { return C == '_'; }).str(); + return Guard.ltrim('_').str(); } bool HeaderGuardCheck::shouldSuggestEndifComment(StringRef FileName) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] eccd279 - [clang] Use SmallString::operator std::string() (NFC)
Author: Kazu Hirata Date: 2024-01-12T18:39:49-08:00 New Revision: eccd279979ac210248cdf7d583169df6a8e552bd URL: https://github.com/llvm/llvm-project/commit/eccd279979ac210248cdf7d583169df6a8e552bd DIFF: https://github.com/llvm/llvm-project/commit/eccd279979ac210248cdf7d583169df6a8e552bd.diff LOG: [clang] Use SmallString::operator std::string() (NFC) Added: Modified: clang/lib/Frontend/CompilerInstance.cpp clang/lib/Frontend/Rewrite/FrontendActions.cpp clang/tools/driver/driver.cpp Removed: diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index 56bbef9697b650..6df5521b25cc08 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -2204,7 +2204,7 @@ void CompilerInstance::createModuleFromSource(SourceLocation ImportLoc, // Build the module, inheriting any modules that we've built locally. if (compileModuleImpl(*this, ImportLoc, ModuleName, Input, StringRef(), ModuleFileName, PreBuildStep, PostBuildStep)) { -BuiltModules[std::string(ModuleName)] = std::string(ModuleFileName.str()); +BuiltModules[std::string(ModuleName)] = std::string(ModuleFileName); llvm::sys::RemoveFileOnSignal(ModuleFileName); } } diff --git a/clang/lib/Frontend/Rewrite/FrontendActions.cpp b/clang/lib/Frontend/Rewrite/FrontendActions.cpp index 14569013b92ce9..92921bf6f3d7bd 100644 --- a/clang/lib/Frontend/Rewrite/FrontendActions.cpp +++ b/clang/lib/Frontend/Rewrite/FrontendActions.cpp @@ -77,7 +77,7 @@ class FixItActionSuffixInserter : public FixItOptions { SmallString<128> Path(Filename); llvm::sys::path::replace_extension(Path, NewSuffix + llvm::sys::path::extension(Path)); -return std::string(Path.str()); +return std::string(Path); } }; diff --git a/clang/tools/driver/driver.cpp b/clang/tools/driver/driver.cpp index a46d5169719bc9..1407c7fcdab769 100644 --- a/clang/tools/driver/driver.cpp +++ b/clang/tools/driver/driver.cpp @@ -64,7 +64,7 @@ std::string GetExecutablePath(const char *Argv0, bool CanonicalPrefixes) { if (llvm::ErrorOr P = llvm::sys::findProgramByName(ExecutablePath)) ExecutablePath = *P; -return std::string(ExecutablePath.str()); +return std::string(ExecutablePath); } // This just needs to be some symbol in the binary; C++ doesn't ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] bfb026e - [StaticAnalyzer] Use StringRef::contains_insensitive (NFC)
Author: Kazu Hirata Date: 2024-01-11T22:48:19-08:00 New Revision: bfb026e17ce288cd446d19f5d6329d08b4f46e04 URL: https://github.com/llvm/llvm-project/commit/bfb026e17ce288cd446d19f5d6329d08b4f46e04 DIFF: https://github.com/llvm/llvm-project/commit/bfb026e17ce288cd446d19f5d6329d08b4f46e04.diff LOG: [StaticAnalyzer] Use StringRef::contains_insensitive (NFC) Added: Modified: clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp Removed: diff --git a/clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp index de9efe17d220b1..812d787e2e37c4 100644 --- a/clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp @@ -712,7 +712,7 @@ void NonLocalizedStringChecker::setNonLocalizedState(const SVal S, static bool isDebuggingName(std::string name) { - return StringRef(name).lower().find("debug") != StringRef::npos; + return StringRef(name).contains_insensitive("debug"); } /// Returns true when, heuristically, the analyzer may be analyzing debugging @@ -1248,8 +1248,8 @@ bool PluralMisuseChecker::MethodCrawler::isCheckingPlurality( BO = B; } } - if (VD->getName().lower().find("plural") != StringRef::npos || - VD->getName().lower().find("singular") != StringRef::npos) { + if (VD->getName().contains_insensitive("plural") || + VD->getName().contains_insensitive("singular")) { return true; } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] cf3421d - [Format] Fix a warning
Author: Kazu Hirata Date: 2024-01-11T12:09:01-08:00 New Revision: cf3421de587d7c947e8f6b5c754393f85a395747 URL: https://github.com/llvm/llvm-project/commit/cf3421de587d7c947e8f6b5c754393f85a395747 DIFF: https://github.com/llvm/llvm-project/commit/cf3421de587d7c947e8f6b5c754393f85a395747.diff LOG: [Format] Fix a warning This patch fixes: clang/unittests/Format/TokenAnnotatorTest.cpp:2181:29: error: lambda capture 'Style' is not used [-Werror,-Wunused-lambda-capture] Added: Modified: clang/unittests/Format/TokenAnnotatorTest.cpp Removed: diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp index 33a320f7bb06e6..1ee209444067d6 100644 --- a/clang/unittests/Format/TokenAnnotatorTest.cpp +++ b/clang/unittests/Format/TokenAnnotatorTest.cpp @@ -2178,7 +2178,7 @@ TEST_F(TokenAnnotatorTest, UnderstandTableGenTokens) { TestLexer Lexer(Allocator, Buffers, Style); AdditionalKeywords Keywords(Lexer.IdentTable); - auto Annotate = [, ](llvm::StringRef Code) { + auto Annotate = [](llvm::StringRef Code) { return Lexer.annotate(Code); }; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] 12bba0d - [clang-query] Use StringRef::ltrim (NFC)
Author: Kazu Hirata Date: 2024-01-10T20:31:41-08:00 New Revision: 12bba0d4f8c2df655958decb8eb788327543b3fe URL: https://github.com/llvm/llvm-project/commit/12bba0d4f8c2df655958decb8eb788327543b3fe DIFF: https://github.com/llvm/llvm-project/commit/12bba0d4f8c2df655958decb8eb788327543b3fe.diff LOG: [clang-query] Use StringRef::ltrim (NFC) Added: Modified: clang-tools-extra/clang-query/QueryParser.cpp Removed: diff --git a/clang-tools-extra/clang-query/QueryParser.cpp b/clang-tools-extra/clang-query/QueryParser.cpp index 41933625a4fa07..162acc1a598dd5 100644 --- a/clang-tools-extra/clang-query/QueryParser.cpp +++ b/clang-tools-extra/clang-query/QueryParser.cpp @@ -28,10 +28,8 @@ namespace query { // is found before End, return StringRef(). Begin is adjusted to exclude the // lexed region. StringRef QueryParser::lexWord() { - Line = Line.drop_while([](char c) { -// Don't trim newlines. -return StringRef(" \t\v\f\r").contains(c); - }); + // Don't trim newlines. + Line = Line.ltrim(" \t\v\f\r"); if (Line.empty()) // Even though the Line is empty, it contains a pointer and @@ -152,8 +150,7 @@ QueryRef QueryParser::parseSetTraversalKind(TraversalKind QuerySession::*Var) { QueryRef QueryParser::endQuery(QueryRef Q) { StringRef Extra = Line; - StringRef ExtraTrimmed = Extra.drop_while( - [](char c) { return StringRef(" \t\v\f\r").contains(c); }); + StringRef ExtraTrimmed = Extra.ltrim(" \t\v\f\r"); if ((!ExtraTrimmed.empty() && ExtraTrimmed[0] == '\n') || (ExtraTrimmed.size() >= 2 && ExtraTrimmed[0] == '\r' && ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 2b3baff - [Analysis] Use StringRef::rtrim (NFC)
Author: Kazu Hirata Date: 2024-01-08T17:24:47-08:00 New Revision: 2b3baffb4720d4ddc7ddd7080f5ea624230b9324 URL: https://github.com/llvm/llvm-project/commit/2b3baffb4720d4ddc7ddd7080f5ea624230b9324 DIFF: https://github.com/llvm/llvm-project/commit/2b3baffb4720d4ddc7ddd7080f5ea624230b9324.diff LOG: [Analysis] Use StringRef::rtrim (NFC) Added: Modified: clang/lib/Analysis/PathDiagnostic.cpp Removed: diff --git a/clang/lib/Analysis/PathDiagnostic.cpp b/clang/lib/Analysis/PathDiagnostic.cpp index 0cb03943c547c3..79f337a91ec8fa 100644 --- a/clang/lib/Analysis/PathDiagnostic.cpp +++ b/clang/lib/Analysis/PathDiagnostic.cpp @@ -50,12 +50,7 @@ using namespace clang; using namespace ento; -static StringRef StripTrailingDots(StringRef s) { - for (StringRef::size_type i = s.size(); i != 0; --i) -if (s[i - 1] != '.') - return s.substr(0, i); - return {}; -} +static StringRef StripTrailingDots(StringRef s) { return s.rtrim('.'); } PathDiagnosticPiece::PathDiagnosticPiece(StringRef s, Kind k, DisplayHint hint) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] c54a8ac - [Sema] Use StringRef::ltrim (NFC)
Author: Kazu Hirata Date: 2024-01-08T17:12:26-08:00 New Revision: c54a8ac35ab0fe3b7d204dc9867bf05fcb1775cd URL: https://github.com/llvm/llvm-project/commit/c54a8ac35ab0fe3b7d204dc9867bf05fcb1775cd DIFF: https://github.com/llvm/llvm-project/commit/c54a8ac35ab0fe3b7d204dc9867bf05fcb1775cd.diff LOG: [Sema] Use StringRef::ltrim (NFC) Added: Modified: clang/lib/Sema/SemaChecking.cpp Removed: diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index f13164dc063866..74f8f626fb1637 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -18376,7 +18376,7 @@ static bool isSetterLikeSelector(Selector sel) { if (sel.isUnarySelector()) return false; StringRef str = sel.getNameForSlot(0); - while (!str.empty() && str.front() == '_') str = str.substr(1); + str = str.ltrim('_'); if (str.starts_with("set")) str = str.substr(3); else if (str.starts_with("add")) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 5c37e71 - [Frontend] Use StringRef::drop_while (NFC)
Author: Kazu Hirata Date: 2023-12-28T10:06:20-08:00 New Revision: 5c37e711df6b81c2b669fb8a0d8b15f7a79e6e4a URL: https://github.com/llvm/llvm-project/commit/5c37e711df6b81c2b669fb8a0d8b15f7a79e6e4a DIFF: https://github.com/llvm/llvm-project/commit/5c37e711df6b81c2b669fb8a0d8b15f7a79e6e4a.diff LOG: [Frontend] Use StringRef::drop_while (NFC) Added: Modified: clang/lib/Frontend/LayoutOverrideSource.cpp Removed: diff --git a/clang/lib/Frontend/LayoutOverrideSource.cpp b/clang/lib/Frontend/LayoutOverrideSource.cpp index f474d4fe8fdcb8..a1866ec09c9d3d 100644 --- a/clang/lib/Frontend/LayoutOverrideSource.cpp +++ b/clang/lib/Frontend/LayoutOverrideSource.cpp @@ -147,8 +147,7 @@ LayoutOverrideSource::LayoutOverrideSource(StringRef Filename) { // Skip over this offset, the following comma, and any spaces. LineStr = LineStr.substr(1); -while (!LineStr.empty() && isWhitespace(LineStr[0])) - LineStr = LineStr.substr(1); +LineStr = LineStr.drop_while(isWhitespace); } } @@ -163,8 +162,7 @@ LayoutOverrideSource::LayoutOverrideSource(StringRef Filename) { // Skip over this offset, the following comma, and any spaces. LineStr = LineStr.substr(1); -while (!LineStr.empty() && isWhitespace(LineStr[0])) - LineStr = LineStr.substr(1); +LineStr = LineStr.drop_while(isWhitespace); } continue; } @@ -180,8 +178,7 @@ LayoutOverrideSource::LayoutOverrideSource(StringRef Filename) { // Skip over this offset, the following comma, and any spaces. LineStr = LineStr.substr(1); -while (!LineStr.empty() && isWhitespace(LineStr[0])) - LineStr = LineStr.substr(1); +LineStr = LineStr.drop_while(isWhitespace); } } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] a70dcc2 - [clang] Use StringRef::ltrim (NFC)
Author: Kazu Hirata Date: 2023-12-27T09:10:39-08:00 New Revision: a70dcc2cda6b60c2dbd4b96d229b4c1bf43c23d1 URL: https://github.com/llvm/llvm-project/commit/a70dcc2cda6b60c2dbd4b96d229b4c1bf43c23d1 DIFF: https://github.com/llvm/llvm-project/commit/a70dcc2cda6b60c2dbd4b96d229b4c1bf43c23d1.diff LOG: [clang] Use StringRef::ltrim (NFC) Added: Modified: clang/lib/ASTMatchers/Dynamic/Parser.cpp clang/lib/Basic/IdentifierTable.cpp clang/lib/Basic/Targets/AArch64.cpp clang/lib/Basic/Targets/ARM.cpp clang/lib/Basic/Targets/X86.cpp Removed: diff --git a/clang/lib/ASTMatchers/Dynamic/Parser.cpp b/clang/lib/ASTMatchers/Dynamic/Parser.cpp index 27096a83b8dd60..6a16c2184fcfb1 100644 --- a/clang/lib/ASTMatchers/Dynamic/Parser.cpp +++ b/clang/lib/ASTMatchers/Dynamic/Parser.cpp @@ -299,10 +299,8 @@ class Parser::CodeTokenizer { /// Consume all leading whitespace from \c Code. void consumeWhitespace() { -Code = Code.drop_while([](char c) { - // Don't trim newlines. - return StringRef(" \t\v\f\r").contains(c); -}); +// Don't trim newlines. +Code = Code.ltrim(" \t\v\f\r"); } SourceLocation currentLocation() { diff --git a/clang/lib/Basic/IdentifierTable.cpp b/clang/lib/Basic/IdentifierTable.cpp index 5902c6dc3ce0b4..d0d8316385b452 100644 --- a/clang/lib/Basic/IdentifierTable.cpp +++ b/clang/lib/Basic/IdentifierTable.cpp @@ -628,8 +628,7 @@ ObjCMethodFamily Selector::getMethodFamilyImpl(Selector sel) { return OMF_performSelector; // The other method families may begin with a prefix of underscores. - while (!name.empty() && name.front() == '_') -name = name.substr(1); + name = name.ltrim('_'); if (name.empty()) return OMF_None; switch (name.front()) { diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp index 3ee39133fcee72..2f8395cb8932f2 100644 --- a/clang/lib/Basic/Targets/AArch64.cpp +++ b/clang/lib/Basic/Targets/AArch64.cpp @@ -1365,8 +1365,7 @@ bool AArch64TargetInfo::validateConstraintModifier( StringRef Constraint, char Modifier, unsigned Size, std::string ) const { // Strip off constraint modifiers. - while (Constraint[0] == '=' || Constraint[0] == '+' || Constraint[0] == '&') -Constraint = Constraint.substr(1); + Constraint = Constraint.ltrim("=+&"); switch (Constraint[0]) { default: diff --git a/clang/lib/Basic/Targets/ARM.cpp b/clang/lib/Basic/Targets/ARM.cpp index 6e1842fc64e505..01f9e844da12a0 100644 --- a/clang/lib/Basic/Targets/ARM.cpp +++ b/clang/lib/Basic/Targets/ARM.cpp @@ -1230,8 +1230,7 @@ bool ARMTargetInfo::validateConstraintModifier( bool isInOut = (Constraint[0] == '+'); // Strip off constraint modifiers. - while (Constraint[0] == '=' || Constraint[0] == '+' || Constraint[0] == '&') -Constraint = Constraint.substr(1); + Constraint = Constraint.ltrim("=+&"); switch (Constraint[0]) { default: diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp index b97f88647fa49f..3deaa19f8d4fc4 100644 --- a/clang/lib/Basic/Targets/X86.cpp +++ b/clang/lib/Basic/Targets/X86.cpp @@ -1613,8 +1613,7 @@ bool X86TargetInfo::validateOutputSize(const llvm::StringMap , StringRef Constraint, unsigned Size) const { // Strip off constraint modifiers. - while (Constraint[0] == '=' || Constraint[0] == '+' || Constraint[0] == '&') -Constraint = Constraint.substr(1); + Constraint = Constraint.ltrim("=+&"); return validateOperandSize(FeatureMap, Constraint, Size); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 2df0fa4 - [clang] Use StringRef::consume_front (NFC)
Author: Kazu Hirata Date: 2023-12-27T00:19:12-08:00 New Revision: 2df0fa41a3aa416d84f9f22490f329bf851d447e URL: https://github.com/llvm/llvm-project/commit/2df0fa41a3aa416d84f9f22490f329bf851d447e DIFF: https://github.com/llvm/llvm-project/commit/2df0fa41a3aa416d84f9f22490f329bf851d447e.diff LOG: [clang] Use StringRef::consume_front (NFC) Added: Modified: clang/lib/Basic/Warnings.cpp clang/lib/Driver/ToolChains/Arch/X86.cpp Removed: diff --git a/clang/lib/Basic/Warnings.cpp b/clang/lib/Basic/Warnings.cpp index bab1af4f03b67b..92954cab6fb040 100644 --- a/clang/lib/Basic/Warnings.cpp +++ b/clang/lib/Basic/Warnings.cpp @@ -96,11 +96,7 @@ void clang::ProcessWarningOptions(DiagnosticsEngine , // Check to see if this warning starts with "no-", if so, this is a // negative form of the option. - bool isPositive = true; - if (Opt.starts_with("no-")) { -isPositive = false; -Opt = Opt.substr(3); - } + bool isPositive = !Opt.consume_front("no-"); // Figure out how this option affects the warning. If -Wfoo, map the // diagnostic to a warning, if -Wno-foo, map it to ignore. diff --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp b/clang/lib/Driver/ToolChains/Arch/X86.cpp index fef0522aaf45b8..53e26a9f8e229e 100644 --- a/clang/lib/Driver/ToolChains/Arch/X86.cpp +++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp @@ -237,9 +237,7 @@ void x86::getX86TargetFeatures(const Driver , const llvm::Triple , assert(Name.starts_with("m") && "Invalid feature name."); Name = Name.substr(1); -bool IsNegative = Name.starts_with("no-"); -if (IsNegative) - Name = Name.substr(3); +bool IsNegative = Name.consume_front("no-"); #ifndef NDEBUG assert(Name.starts_with("avx10.") && "Invalid AVX10 feature name."); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 68f832f - [clang] Use StringRef::consume_front (NFC)
Author: Kazu Hirata Date: 2023-12-25T12:54:35-08:00 New Revision: 68f832f56da1af0e5fc77003f640648ec7d901ad URL: https://github.com/llvm/llvm-project/commit/68f832f56da1af0e5fc77003f640648ec7d901ad DIFF: https://github.com/llvm/llvm-project/commit/68f832f56da1af0e5fc77003f640648ec7d901ad.diff LOG: [clang] Use StringRef::consume_front (NFC) Added: Modified: clang/lib/CodeGen/CodeGenAction.cpp clang/lib/Driver/ToolChains/CommonArgs.cpp clang/lib/Frontend/DependencyGraph.cpp clang/lib/Frontend/VerifyDiagnosticConsumer.cpp clang/lib/Sema/SemaChecking.cpp clang/lib/Sema/SemaDeclAttr.cpp clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp clang/lib/Tooling/Refactoring/Lookup.cpp clang/lib/Tooling/Tooling.cpp Removed: diff --git a/clang/lib/CodeGen/CodeGenAction.cpp b/clang/lib/CodeGen/CodeGenAction.cpp index 753a8fd74fa696..f8038497d90a7b 100644 --- a/clang/lib/CodeGen/CodeGenAction.cpp +++ b/clang/lib/CodeGen/CodeGenAction.cpp @@ -1139,8 +1139,7 @@ CodeGenAction::loadModule(MemoryBufferRef MBRef) { // Strip off a leading diagnostic code if there is one. StringRef Msg = Err.getMessage(); - if (Msg.starts_with("error: ")) -Msg = Msg.substr(7); + Msg.consume_front("error: "); unsigned DiagID = CI.getDiagnostics().getCustomDiagID(DiagnosticsEngine::Error, "%0"); diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 3b29e1bc75850f..2340191ca97d98 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -2388,8 +2388,7 @@ static void GetSDLFromOffloadArchive( FoundAOB = true; } } else { -if (Lib.starts_with("-l")) - Lib = Lib.drop_front(2); +Lib.consume_front("-l"); for (auto LPath : LibraryPaths) { ArchiveOfBundles.clear(); auto LibFile = (Lib.starts_with(":") ? Lib.drop_front() diff --git a/clang/lib/Frontend/DependencyGraph.cpp b/clang/lib/Frontend/DependencyGraph.cpp index e96669f856bb18..b471471f3528a7 100644 --- a/clang/lib/Frontend/DependencyGraph.cpp +++ b/clang/lib/Frontend/DependencyGraph.cpp @@ -110,8 +110,7 @@ void DependencyGraphCallback::OutputGraphFile() { writeNodeReference(OS, AllFiles[I]); OS << " [ shape=\"box\", label=\""; StringRef FileName = AllFiles[I].getName(); -if (FileName.starts_with(SysRoot)) - FileName = FileName.substr(SysRoot.size()); +FileName.consume_front(SysRoot); OS << DOT::EscapeString(std::string(FileName)) << "\"];\n"; } diff --git a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp index 09c1460d54e1d7..8a3d2286cd168c 100644 --- a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp +++ b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp @@ -1144,8 +1144,7 @@ std::unique_ptr Directive::create(bool RegexKind, std::string RegexStr; StringRef S = Text; while (!S.empty()) { -if (S.starts_with("{{")) { - S = S.drop_front(2); +if (S.consume_front("{{")) { size_t RegexMatchLength = S.find("}}"); assert(RegexMatchLength != StringRef::npos); // Append the regex, enclosed in parentheses. diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 2a69325f029514..66dac99b8d9922 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -1219,8 +1219,8 @@ void Sema::checkFortifiedBuiltinMemoryFunction(FunctionDecl *FD, if (IsChkVariant) { FunctionName = FunctionName.drop_front(std::strlen("__builtin___")); FunctionName = FunctionName.drop_back(std::strlen("_chk")); -} else if (FunctionName.starts_with("__builtin_")) { - FunctionName = FunctionName.drop_front(std::strlen("__builtin_")); +} else { + FunctionName.consume_front("__builtin_"); } return FunctionName; }; diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index af8b90ecfed973..4a385a396fa62b 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -5825,8 +5825,7 @@ struct IntrinToName { static bool ArmBuiltinAliasValid(unsigned BuiltinID, StringRef AliasName, ArrayRef Map, const char *IntrinNames) { - if (AliasName.starts_with("__arm_")) -AliasName = AliasName.substr(6); + AliasName.consume_front("__arm_"); const IntrinToName *It = llvm::lower_bound(Map, BuiltinID, [](const IntrinToName , unsigned Id) { return L.Id < Id; diff --git a/clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp b/clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp index afc5e6b48008d8..ce05d2d3c90585 100644 --- a/clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp +++
[clang] fe21b39 - [Basic] Use range-based for loops (NFC)
Author: Kazu Hirata Date: 2023-12-24T23:38:25-08:00 New Revision: fe21b3941df24420b72e789dcf67de2dc17c4417 URL: https://github.com/llvm/llvm-project/commit/fe21b3941df24420b72e789dcf67de2dc17c4417 DIFF: https://github.com/llvm/llvm-project/commit/fe21b3941df24420b72e789dcf67de2dc17c4417.diff LOG: [Basic] Use range-based for loops (NFC) Added: Modified: clang/include/clang/Basic/PlistSupport.h clang/lib/Basic/Warnings.cpp Removed: diff --git a/clang/include/clang/Basic/PlistSupport.h b/clang/include/clang/Basic/PlistSupport.h index 557462a5b90d01..d52d196019cf84 100644 --- a/clang/include/clang/Basic/PlistSupport.h +++ b/clang/include/clang/Basic/PlistSupport.h @@ -77,8 +77,7 @@ inline raw_ostream (raw_ostream , int64_t value) { inline raw_ostream (raw_ostream , StringRef s) { o << ""; - for (StringRef::const_iterator I = s.begin(), E = s.end(); I != E; ++I) { -char c = *I; + for (char c : s) { switch (c) { default: o << c; diff --git a/clang/lib/Basic/Warnings.cpp b/clang/lib/Basic/Warnings.cpp index cb23d844ef8f6f..bab1af4f03b67b 100644 --- a/clang/lib/Basic/Warnings.cpp +++ b/clang/lib/Basic/Warnings.cpp @@ -198,8 +198,7 @@ void clang::ProcessWarningOptions(DiagnosticsEngine , } } -for (unsigned i = 0, e = Opts.Remarks.size(); i != e; ++i) { - StringRef Opt = Opts.Remarks[i]; +for (StringRef Opt : Opts.Remarks) { const auto Flavor = diag::Flavor::Remark; // Check to see if this warning starts with "no-", if so, this is a ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] 0f1721c - [clang-tidy] Use StringRef::contains (NFC)
Author: Kazu Hirata Date: 2023-12-23T22:30:03-08:00 New Revision: 0f1721c480369bad1c8d3f9a664f8db6853f35fc URL: https://github.com/llvm/llvm-project/commit/0f1721c480369bad1c8d3f9a664f8db6853f35fc DIFF: https://github.com/llvm/llvm-project/commit/0f1721c480369bad1c8d3f9a664f8db6853f35fc.diff LOG: [clang-tidy] Use StringRef::contains (NFC) Added: Modified: clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.cpp Removed: diff --git a/clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.cpp b/clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.cpp index 3c8751dbdd733f..ad900fcec2dee1 100644 --- a/clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.cpp +++ b/clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.cpp @@ -97,7 +97,7 @@ void InefficientAlgorithmCheck::check(const MatchFinder::MatchResult ) { if (!AlgDecl) return; - if (Unordered && AlgDecl->getName().find("bound") != llvm::StringRef::npos) + if (Unordered && AlgDecl->getName().contains("bound")) return; const auto *AlgParam = Result.Nodes.getNodeAs("AlgParam"); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 0e039fc - [APINotes] Use DenseMap::contains (NFC)
Author: Kazu Hirata Date: 2023-12-22T14:23:25-08:00 New Revision: 0e039fc39e29320c9a0eeadb34a5e83ac51d48ba URL: https://github.com/llvm/llvm-project/commit/0e039fc39e29320c9a0eeadb34a5e83ac51d48ba DIFF: https://github.com/llvm/llvm-project/commit/0e039fc39e29320c9a0eeadb34a5e83ac51d48ba.diff LOG: [APINotes] Use DenseMap::contains (NFC) Added: Modified: clang/lib/APINotes/APINotesManager.cpp Removed: diff --git a/clang/lib/APINotes/APINotesManager.cpp b/clang/lib/APINotes/APINotesManager.cpp index a921c8b9fce3e0..d3aef09dac9105 100644 --- a/clang/lib/APINotes/APINotesManager.cpp +++ b/clang/lib/APINotes/APINotesManager.cpp @@ -125,7 +125,7 @@ APINotesManager::loadAPINotes(StringRef Buffer) { bool APINotesManager::loadAPINotes(const DirectoryEntry *HeaderDir, FileEntryRef APINotesFile) { - assert(Readers.find(HeaderDir) == Readers.end()); + assert(!Readers.contains(HeaderDir)); if (auto Reader = loadAPINotes(APINotesFile)) { Readers[HeaderDir] = Reader.release(); return false; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits