[clang] a33ef8f - Use llvm::all_equal (NFC)

2022-08-27 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-08-27T09:53:10-07:00
New Revision: a33ef8f2b7b28e4ae50a6e4fa206f82d3b230a68

URL: 
https://github.com/llvm/llvm-project/commit/a33ef8f2b7b28e4ae50a6e4fa206f82d3b230a68
DIFF: 
https://github.com/llvm/llvm-project/commit/a33ef8f2b7b28e4ae50a6e4fa206f82d3b230a68.diff

LOG: Use llvm::all_equal (NFC)

Added: 


Modified: 
clang/lib/Driver/Action.cpp
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/AMDGPU.cpp
llvm/lib/Target/AArch64/MCTargetDesc/AArch64AddressingModes.h
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/lib/Transforms/IPO/PartialInlining.cpp
llvm/lib/Transforms/Scalar/GVNSink.cpp
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
mlir/lib/Dialect/Shape/IR/ShapeCanonicalization.td

Removed: 




diff  --git a/clang/lib/Driver/Action.cpp b/clang/lib/Driver/Action.cpp
index cc7a59f9d956..1cb68276e11e 100644
--- a/clang/lib/Driver/Action.cpp
+++ b/clang/lib/Driver/Action.cpp
@@ -198,7 +198,7 @@ OffloadAction::OffloadAction(const DeviceDependences 
&DDeps, types::ID Ty)
   auto &OTCs = DDeps.getToolChains();
 
   // If all inputs agree on the same kind, use it also for this action.
-  if (llvm::all_of(OKinds, [&](OffloadKind K) { return K == OKinds.front(); }))
+  if (llvm::all_equal(OKinds))
 OffloadingDeviceKind = OKinds.front();
 
   // If we have a single dependency, inherit the architecture from it.

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index d23a8931a8a8..db6e4898ed55 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -991,9 +991,7 @@ bool Driver::loadConfigFile() {
 std::vector ConfigFiles =
 CLOptions->getAllArgValues(options::OPT_config);
 if (ConfigFiles.size() > 1) {
-  if (!llvm::all_of(ConfigFiles, [ConfigFiles](const std::string &s) {
-return s == ConfigFiles[0];
-  })) {
+  if (!llvm::all_equal(ConfigFiles)) {
 Diag(diag::err_drv_duplicate_config);
 return true;
   }

diff  --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp 
b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index 8718ab53ac1a..89f8e482ded6 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -804,10 +804,7 @@ llvm::Error AMDGPUToolChain::getSystemGPUArch(const 
ArgList &Args,
   }
   GPUArch = GPUArchs[0];
   if (GPUArchs.size() > 1) {
-bool AllSame = llvm::all_of(GPUArchs, [&](const StringRef &GPUArch) {
-  return GPUArch == GPUArchs.front();
-});
-if (!AllSame)
+if (!llvm::all_equal(GPUArchs))
   return llvm::createStringError(
   std::error_code(), "Multiple AMD GPUs found with 
diff erent archs");
   }

diff  --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AddressingModes.h 
b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AddressingModes.h
index 876526093591..71862e85b49c 100644
--- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AddressingModes.h
+++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AddressingModes.h
@@ -755,7 +755,7 @@ static inline uint64_t decodeAdvSIMDModImmType12(uint8_t 
Imm) {
 template 
 static inline bool isSVEMaskOfIdenticalElements(int64_t Imm) {
   auto Parts = bit_cast>(Imm);
-  return all_of(Parts, [&](T Elem) { return Elem == Parts[0]; });
+  return llvm::all_equal(Parts);
 }
 
 /// Returns true if Imm is valid for CPY/DUP.

diff  --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 59333bf1b843..369c7d3d6504 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -53986,7 +53986,7 @@ static SDValue combineConcatVectorOps(const SDLoc &DL, 
MVT VT,
 return getZeroVector(VT, Subtarget, DAG, DL);
 
   SDValue Op0 = Ops[0];
-  bool IsSplat = llvm::all_of(Ops, [&Op0](SDValue Op) { return Op == Op0; });
+  bool IsSplat = llvm::all_equal(Ops);
 
   // Repeated subvectors.
   if (IsSplat &&

diff  --git a/llvm/lib/Transforms/IPO/PartialInlining.cpp 
b/llvm/lib/Transforms/IPO/PartialInlining.cpp
index d2b37f6a5c0d..653addd726c5 100644
--- a/llvm/lib/Transforms/IPO/PartialInlining.cpp
+++ b/llvm/lib/Transforms/IPO/PartialInlining.cpp
@@ -1083,10 +1083,8 @@ void 
PartialInlinerImpl::FunctionCloner::normalizeReturnBlock() const {
 return;
 
   auto IsTrivialPhi = [](PHINode *PN) -> Value * {
-Value *CommonValue = PN->getIncomingValue(0);
-if (all_of(PN->incoming_values(),
-   [&](Value *V) { return V == CommonValue; }))
-  return CommonValue;
+if (llvm::all_equal(PN->incoming_values()))
+  return PN->getIncomingValue(0);
 return nullptr;
   };
 

diff  --git a/llvm/lib/Transforms/Scalar/GVNSink.cpp 
b/llvm/lib/Transforms/Scalar/GVNSink.cpp
index 6fc6a931a861..891f7d72529e 100644
--- a/llvm/lib/Transforms/Scalar/GVNSink.cpp
+++ b/llvm/lib/Transforms/Scalar/GVNSink.cpp
@@ -288,7 +288,7 @@ class ModelledPHI {
   ArrayRef getVa

[clang] 21de288 - Use llvm::is_contained (NFC)

2022-08-27 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-08-27T09:53:11-07:00
New Revision: 21de2888a4b3bf60c68b6e507ed629b977ef5a0e

URL: 
https://github.com/llvm/llvm-project/commit/21de2888a4b3bf60c68b6e507ed629b977ef5a0e
DIFF: 
https://github.com/llvm/llvm-project/commit/21de2888a4b3bf60c68b6e507ed629b977ef5a0e.diff

LOG: Use llvm::is_contained (NFC)

Added: 


Modified: 
clang/lib/AST/Expr.cpp
llvm/lib/CodeGen/WinEHPrepare.cpp
llvm/lib/IR/Instructions.cpp
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp
llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
llvm/lib/Transforms/Vectorize/VPlan.h
mlir/include/mlir/Analysis/Presburger/Utils.h
mlir/include/mlir/Dialect/Quant/QuantTypes.h

Removed: 




diff  --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index e7bdce1bffcc..5fd412930181 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -4831,7 +4831,7 @@ RecoveryExpr::RecoveryExpr(ASTContext &Ctx, QualType T, 
SourceLocation BeginLoc,
OK_Ordinary),
   BeginLoc(BeginLoc), EndLoc(EndLoc), NumExprs(SubExprs.size()) {
   assert(!T.isNull());
-  assert(llvm::all_of(SubExprs, [](Expr* E) { return E != nullptr; }));
+  assert(!llvm::is_contained(SubExprs, nullptr));
 
   llvm::copy(SubExprs, getTrailingObjects());
   setDependence(computeDependence(this));

diff  --git a/llvm/lib/CodeGen/WinEHPrepare.cpp 
b/llvm/lib/CodeGen/WinEHPrepare.cpp
index b835503ee9ed..a71f6572e76f 100644
--- a/llvm/lib/CodeGen/WinEHPrepare.cpp
+++ b/llvm/lib/CodeGen/WinEHPrepare.cpp
@@ -847,10 +847,7 @@ void WinEHPrepare::cloneCommonBlocks(Function &F) {
   ColorVector &IncomingColors = BlockColors[IncomingBlock];
   assert(!IncomingColors.empty() && "Block not colored!");
   assert((IncomingColors.size() == 1 ||
-  llvm::all_of(IncomingColors,
-   [&](BasicBlock *Color) {
- return Color != FuncletPadBB;
-   })) &&
+  !llvm::is_contained(IncomingColors, FuncletPadBB)) &&
  "Cloning should leave this funclet's blocks monochromatic");
   EdgeTargetsFunclet = (IncomingColors.front() == FuncletPadBB);
 }

diff  --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index 6a79d2b1e367..78c13e698d6c 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -2511,7 +2511,7 @@ static bool isReplicationMaskWithParams(ArrayRef 
Mask,
 bool ShuffleVectorInst::isReplicationMask(ArrayRef Mask,
   int &ReplicationFactor, int &VF) {
   // undef-less case is trivial.
-  if (none_of(Mask, [](int MaskElt) { return MaskElt == UndefMaskElem; })) {
+  if (!llvm::is_contained(Mask, UndefMaskElem)) {
 ReplicationFactor =
 Mask.take_while([](int MaskElt) { return MaskElt == 0; }).size();
 if (ReplicationFactor == 0 || Mask.size() % ReplicationFactor != 0)

diff  --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp 
b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
index 93269da8b814..73844ca8c088 100644
--- a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
@@ -4277,9 +4277,7 @@ bool SIInstrInfo::verifyInstruction(const MachineInstr 
&MI,
   if (usesConstantBus(MRI, MO, MI.getDesc().OpInfo[OpIdx])) {
 if (MO.isReg()) {
   SGPRUsed = MO.getReg();
-  if (llvm::all_of(SGPRsUsed, [SGPRUsed](unsigned SGPR) {
-return SGPRUsed != SGPR;
-  })) {
+  if (!llvm::is_contained(SGPRsUsed, SGPRUsed)) {
 ++ConstantBusCount;
 SGPRsUsed.push_back(SGPRUsed);
   }

diff  --git a/llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp 
b/llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp
index 70ea68587b8e..6c62e84077ac 100644
--- a/llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp
+++ b/llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp
@@ -157,7 +157,7 @@ bool TruncInstCombine::buildTruncExpressionGraph() {
   getRelevantOperands(I, Operands);
   // Add only operands not in Stack to prevent cycle
   for (auto *Op : Operands)
-if (all_of(Stack, [Op](Value *V) { return Op != V; }))
+if (!llvm::is_contained(Stack, Op))
   Worklist.push_back(Op);
   break;
 }

diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp 
b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
index d435a7d76d0d..1fd12b441272 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
@@ -859,8 +859,7 @@ Instruction 
*InstCombinerImpl::foldAggregateConstructionIntoAggregateReuse(
 
   // Do we know values fo

[clang] 86bc458 - Use std::clamp (NFC)

2022-08-27 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-08-27T09:53:13-07:00
New Revision: 86bc4587e1fdb7b1b90eadc138619f5e3f2dd6fd

URL: 
https://github.com/llvm/llvm-project/commit/86bc4587e1fdb7b1b90eadc138619f5e3f2dd6fd
DIFF: 
https://github.com/llvm/llvm-project/commit/86bc4587e1fdb7b1b90eadc138619f5e3f2dd6fd.diff

LOG: Use std::clamp (NFC)

This patch replaces clamp idioms with std::clamp where the range is
obviously valid from the source code (that is, low <= high) to avoid
introducing undefined behavior.

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/CodeGen/TargetInfo.cpp
llvm/tools/llvm-xray/xray-color-helper.cpp
llvm/tools/llvm-xray/xray-graph-diff.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 63e293f26376..f2d0b20c00c4 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -60,11 +60,6 @@ using namespace clang;
 using namespace CodeGen;
 using namespace llvm;
 
-static
-int64_t clamp(int64_t Value, int64_t Low, int64_t High) {
-  return std::min(High, std::max(Low, Value));
-}
-
 static void initializeAlloca(CodeGenFunction &CGF, AllocaInst *AI, Value *Size,
  Align AlignmentInBytes) {
   ConstantInt *Byte;
@@ -16024,7 +16019,7 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned 
BuiltinID,
 assert(ArgCI &&
"Third arg to xxinsertw intrinsic must be constant integer");
 const int64_t MaxIndex = 12;
-int64_t Index = clamp(ArgCI->getSExtValue(), 0, MaxIndex);
+int64_t Index = std::clamp(ArgCI->getSExtValue(), (int64_t)0, MaxIndex);
 
 // The builtin semantics don't exactly match the xxinsertw instructions
 // semantics (which ppc_vsx_xxinsertw follows). The builtin extracts the
@@ -16066,7 +16061,7 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned 
BuiltinID,
 assert(ArgCI &&
"Second Arg to xxextractuw intrinsic must be a constant integer!");
 const int64_t MaxIndex = 12;
-int64_t Index = clamp(ArgCI->getSExtValue(), 0, MaxIndex);
+int64_t Index = std::clamp(ArgCI->getSExtValue(), (int64_t)0, MaxIndex);
 
 if (getTarget().isLittleEndian()) {
   // Reverse the index.

diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index 42d5a856edf3..370614f65e5b 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -6674,7 +6674,7 @@ ABIArgInfo ARMABIInfo::classifyArgumentType(QualType Ty, 
bool isVariadic,
   if (getABIKind() == ARMABIInfo::AAPCS_VFP ||
   getABIKind() == ARMABIInfo::AAPCS) {
 TyAlign = getContext().getTypeUnadjustedAlignInChars(Ty).getQuantity();
-ABIAlign = std::min(std::max(TyAlign, (uint64_t)4), (uint64_t)8);
+ABIAlign = std::clamp(TyAlign, (uint64_t)4, (uint64_t)8);
   } else {
 TyAlign = getContext().getTypeAlignInChars(Ty).getQuantity();
   }

diff  --git a/llvm/tools/llvm-xray/xray-color-helper.cpp 
b/llvm/tools/llvm-xray/xray-color-helper.cpp
index b2ed63881bdc..3dd5143ca8d0 100644
--- a/llvm/tools/llvm-xray/xray-color-helper.cpp
+++ b/llvm/tools/llvm-xray/xray-color-helper.cpp
@@ -111,7 +111,7 @@ convertToHSV(const std::tuple 
&Color) {
 // Takes a double precision number, clips it between 0 and 1 and then converts
 // that to an integer between 0x00 and 0xFF with proxpper rounding.
 static uint8_t unitIntervalTo8BitChar(double B) {
-  double n = std::max(std::min(B, 1.0), 0.0);
+  double n = std::clamp(B, 0.0, 1.0);
   return static_cast(255 * n + 0.5);
 }
 

diff  --git a/llvm/tools/llvm-xray/xray-graph-
diff .cpp b/llvm/tools/llvm-xray/xray-graph-
diff .cpp
index bcadade86bb5..8ccfd304ffe5 100644
--- a/llvm/tools/llvm-xray/xray-graph-
diff .cpp
+++ b/llvm/tools/llvm-xray/xray-graph-
diff .cpp
@@ -264,7 +264,7 @@ static std::string getColor(const 
GraphDiffRenderer::GraphT::EdgeValueType &E,
   const auto &RightStat = EdgeAttr.CorrEdgePtr[1]->second.S;
 
   double RelDiff = statRelDiff(LeftStat, RightStat, T);
-  double CappedRelDiff = std::min(1.0, std::max(-1.0, RelDiff));
+  double CappedRelDiff = std::clamp(RelDiff, -1.0, 1.0);
 
   return H.getColorString(CappedRelDiff);
 }
@@ -285,7 +285,7 @@ static std::string getColor(const 
GraphDiffRenderer::GraphT::VertexValueType &V,
   const auto &RightStat = VertexAttr.CorrVertexPtr[1]->second.S;
 
   double RelDiff = statRelDiff(LeftStat, RightStat, T);
-  double CappedRelDiff = std::min(1.0, std::max(-1.0, RelDiff));
+  double CappedRelDiff = std::clamp(RelDiff, -1.0, 1.0);
 
   return H.getColorString(CappedRelDiff);
 }



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 33b9304 - Use llvm::is_contained (NFC)

2022-08-27 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-08-27T21:21:00-07:00
New Revision: 33b93044352fae09376b7d71ce6f2441a34f343d

URL: 
https://github.com/llvm/llvm-project/commit/33b93044352fae09376b7d71ce6f2441a34f343d
DIFF: 
https://github.com/llvm/llvm-project/commit/33b93044352fae09376b7d71ce6f2441a34f343d.diff

LOG: Use llvm::is_contained (NFC)

Added: 


Modified: 
clang-tools-extra/clang-tidy/zircon/TemporaryObjectsCheck.cpp
clang-tools-extra/clangd/QueryDriverDatabase.cpp
clang/lib/Frontend/FrontendAction.cpp
flang/lib/Optimizer/CodeGen/BoxedProcedure.cpp
llvm/lib/Target/AArch64/AArch64RegisterInfo.cpp
mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/zircon/TemporaryObjectsCheck.cpp 
b/clang-tools-extra/clang-tidy/zircon/TemporaryObjectsCheck.cpp
index 88fd926158093..b75ab9dbb2fe3 100644
--- a/clang-tools-extra/clang-tidy/zircon/TemporaryObjectsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/zircon/TemporaryObjectsCheck.cpp
@@ -22,8 +22,7 @@ namespace zircon {
 
 AST_MATCHER_P(CXXRecordDecl, matchesAnyName, ArrayRef, Names) {
   std::string QualifiedName = Node.getQualifiedNameAsString();
-  return llvm::any_of(Names,
-  [&](StringRef Name) { return QualifiedName == Name; });
+  return llvm::is_contained(Names, QualifiedName);
 }
 
 void TemporaryObjectsCheck::registerMatchers(MatchFinder *Finder) {

diff  --git a/clang-tools-extra/clangd/QueryDriverDatabase.cpp 
b/clang-tools-extra/clangd/QueryDriverDatabase.cpp
index e96912c6290c7..3fdacf397028e 100644
--- a/clang-tools-extra/clangd/QueryDriverDatabase.cpp
+++ b/clang-tools-extra/clangd/QueryDriverDatabase.cpp
@@ -189,8 +189,7 @@ extractSystemIncludesAndTarget(llvm::SmallString<128> 
Driver,
 
   for (size_t I = 0, E = CommandLine.size(); I < E; ++I) {
 llvm::StringRef Arg = CommandLine[I];
-if (llvm::any_of(FlagsToPreserve,
- [&Arg](llvm::StringRef S) { return S == Arg; })) {
+if (llvm::is_contained(FlagsToPreserve, Arg)) {
   Args.push_back(Arg);
 } else {
   const auto *Found =

diff  --git a/clang/lib/Frontend/FrontendAction.cpp 
b/clang/lib/Frontend/FrontendAction.cpp
index 4b639a7764954..78c8de78d7ab0 100644
--- a/clang/lib/Frontend/FrontendAction.cpp
+++ b/clang/lib/Frontend/FrontendAction.cpp
@@ -196,10 +196,8 @@ FrontendAction::CreateWrappedASTConsumer(CompilerInstance 
&CI,
 ActionType == PluginASTAction::CmdlineBeforeMainAction) {
   // This is O(|plugins| * |add_plugins|), but since both numbers are
   // way below 50 in practice, that's ok.
-  if (llvm::any_of(CI.getFrontendOpts().AddPluginActions,
-   [&](const std::string &PluginAction) {
- return PluginAction == Plugin.getName();
-   })) {
+  if (llvm::is_contained(CI.getFrontendOpts().AddPluginActions,
+ Plugin.getName())) {
 if (ActionType == PluginASTAction::CmdlineBeforeMainAction)
   ActionType = PluginASTAction::AddBeforeMainAction;
 else

diff  --git a/flang/lib/Optimizer/CodeGen/BoxedProcedure.cpp 
b/flang/lib/Optimizer/CodeGen/BoxedProcedure.cpp
index 188a9d251cdfd..61f19013787e1 100644
--- a/flang/lib/Optimizer/CodeGen/BoxedProcedure.cpp
+++ b/flang/lib/Optimizer/CodeGen/BoxedProcedure.cpp
@@ -62,8 +62,7 @@ class BoxprocTypeRewriter : public mlir::TypeConverter {
   return false;
 }
 if (auto recTy = ty.dyn_cast()) {
-  if (llvm::any_of(visitedTypes,
-   [&](mlir::Type rt) { return rt == recTy; }))
+  if (llvm::is_contained(visitedTypes, recTy))
 return false;
   bool result = false;
   visitedTypes.push_back(recTy);

diff  --git a/llvm/lib/Target/AArch64/AArch64RegisterInfo.cpp 
b/llvm/lib/Target/AArch64/AArch64RegisterInfo.cpp
index 007ec5b70899f..a761a1a37ee7f 100644
--- a/llvm/lib/Target/AArch64/AArch64RegisterInfo.cpp
+++ b/llvm/lib/Target/AArch64/AArch64RegisterInfo.cpp
@@ -424,8 +424,7 @@ bool AArch64RegisterInfo::isArgumentRegister(const 
MachineFunction &MF,
   bool IsVarArg = STI.isCallingConvWin64(MF.getFunction().getCallingConv());
 
   auto HasReg = [](ArrayRef RegList, MCRegister Reg) {
-return llvm::any_of(RegList,
-[Reg](const MCRegister R) { return R == Reg; });
+return llvm::is_contained(RegList, Reg);
   };
 
   switch (CC) {

diff  --git a/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp 
b/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp
index 1b1e0e74e24b6..ae9e95da4cd8d 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp
@@ -459,8 +459,7 @@ LogicalResult MmaOp::verify() {
 
   // Check that we matched an existing shape/dtype combination.
   if (expectedA.empty() || expectedB.empty() || expectedC.empty() ||
-  !llvm::any_of(allowedShapes,
-[&](const auto &allow

[clang-tools-extra] 20f0f15 - Use StringRef::contains (NFC)

2022-08-28 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-08-28T23:29:02-07:00
New Revision: 20f0f15a4055d66fae494fc79bd76f14dee3954f

URL: 
https://github.com/llvm/llvm-project/commit/20f0f15a4055d66fae494fc79bd76f14dee3954f
DIFF: 
https://github.com/llvm/llvm-project/commit/20f0f15a4055d66fae494fc79bd76f14dee3954f.diff

LOG: Use StringRef::contains (NFC)

Added: 


Modified: 
bolt/include/bolt/Profile/DataReader.h
bolt/lib/Profile/DataAggregator.cpp
clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.cpp
flang/lib/Lower/ConvertExpr.cpp
flang/lib/Lower/IO.cpp

Removed: 




diff  --git a/bolt/include/bolt/Profile/DataReader.h 
b/bolt/include/bolt/Profile/DataReader.h
index 4253fc1d66973..cf6d24c67f112 100644
--- a/bolt/include/bolt/Profile/DataReader.h
+++ b/bolt/include/bolt/Profile/DataReader.h
@@ -449,7 +449,7 @@ class DataReader : public ProfileReaderBase {
   bool usesEvent(StringRef Name) const {
 for (auto I = EventNames.begin(), E = EventNames.end(); I != E; ++I) {
   StringRef Event = I->getKey();
-  if (Event.find(Name) != StringRef::npos)
+  if (Event.contains(Name))
 return true;
 }
 return false;

diff  --git a/bolt/lib/Profile/DataAggregator.cpp 
b/bolt/lib/Profile/DataAggregator.cpp
index 678e69b97a7c1..6ac315e972431 100644
--- a/bolt/lib/Profile/DataAggregator.cpp
+++ b/bolt/lib/Profile/DataAggregator.cpp
@@ -1158,7 +1158,7 @@ ErrorOr 
DataAggregator::parseMemSample() {
   ErrorOr Event = parseString(FieldSeparator);
   if (std::error_code EC = Event.getError())
 return EC;
-  if (Event.get().find("mem-loads") == StringRef::npos) {
+  if (!Event.get().contains("mem-loads")) {
 consumeRestOfLine();
 return Res;
   }

diff  --git a/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp 
b/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
index 9e2c2cdbf8175..7f7af7069c418 100644
--- a/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
+++ b/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
@@ -206,7 +206,7 @@ std::string 
getShortestQualifiedNameInNamespace(llvm::StringRef DeclName,
 llvm::StringRef NsName) {
   DeclName = DeclName.ltrim(':');
   NsName = NsName.ltrim(':');
-  if (DeclName.find(':') == llvm::StringRef::npos)
+  if (!DeclName.contains(':'))
 return std::string(DeclName);
 
   auto NsNameSplitted = splitSymbolName(NsName);

diff  --git 
a/clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.cpp 
b/clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.cpp
index 05ef855de7e71..cd221f2d938b9 100644
--- a/clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.cpp
+++ b/clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.cpp
@@ -68,9 +68,8 @@ void InefficientAlgorithmCheck::check(const 
MatchFinder::MatchResult &Result) {
 PtrToContainer = true;
   }
   const llvm::StringRef IneffContName = IneffCont->getName();
-  const bool Unordered =
-  IneffContName.find("unordered") != llvm::StringRef::npos;
-  const bool Maplike = IneffContName.find("map") != llvm::StringRef::npos;
+  const bool Unordered = IneffContName.contains("unordered");
+  const bool Maplike = IneffContName.contains("map");
 
   // Store if the key type of the container is compatible with the value
   // that is searched for.
@@ -84,8 +83,7 @@ void InefficientAlgorithmCheck::check(const 
MatchFinder::MatchResult &Result) {
 const Expr *Arg = AlgCall->getArg(3);
 const QualType AlgCmp =
 Arg->getType().getUnqualifiedType().getCanonicalType();
-const unsigned CmpPosition =
-(IneffContName.find("map") == llvm::StringRef::npos) ? 1 : 2;
+const unsigned CmpPosition = IneffContName.contains("map") ? 2 : 1;
 const QualType ContainerCmp = IneffCont->getTemplateArgs()[CmpPosition]
   .getAsType()
   .getUnqualifiedType()

diff  --git a/flang/lib/Lower/ConvertExpr.cpp b/flang/lib/Lower/ConvertExpr.cpp
index b50670e1e4419..59156bb9332fe 100644
--- a/flang/lib/Lower/ConvertExpr.cpp
+++ b/flang/lib/Lower/ConvertExpr.cpp
@@ -1497,7 +1497,7 @@ class ScalarExprLowering {
   /// NaN strings as well. \p s is assumed to not contain any spaces.
   static llvm::APFloat consAPFloat(const llvm::fltSemantics &fsem,
llvm::StringRef s) {
-assert(s.find(' ') == llvm::StringRef::npos);
+assert(!s.contains(' '));
 if (s.compare_insensitive("-inf") == 0)
   return llvm::APFloat::getInf(fsem, /*negative=*/true);
 if (s.compare_insensitive("inf") == 0 || s.compare_insensitive("+inf") == 
0)

diff  --git a/flang/lib/Lower/IO.cpp b/flang/lib/Lower/IO.cpp
index 8c534f9b8ba33..00fa17e4508dc 100644
--- a/flang/lib/Lower/IO.cpp
+++ b/flang/lib

[clang] b7a7aee - [clang] Qualify auto in range-based for loops (NFC)

2022-09-03 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-09-03T23:27:27-07:00
New Revision: b7a7aeee90cffefd0f73b8d9f44ab4d1d5123d05

URL: 
https://github.com/llvm/llvm-project/commit/b7a7aeee90cffefd0f73b8d9f44ab4d1d5123d05
DIFF: 
https://github.com/llvm/llvm-project/commit/b7a7aeee90cffefd0f73b8d9f44ab4d1d5123d05.diff

LOG: [clang] Qualify auto in range-based for loops (NFC)

Added: 


Modified: 
clang/lib/ARCMigrate/ObjCMT.cpp
clang/lib/ARCMigrate/TransGCAttrs.cpp
clang/lib/AST/ASTContext.cpp
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/Decl.cpp
clang/lib/AST/DeclObjC.cpp
clang/lib/AST/ODRHash.cpp
clang/lib/AST/OpenMPClause.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/AST/Type.cpp
clang/lib/Analysis/CFG.cpp
clang/lib/Analysis/ThreadSafetyCommon.cpp
clang/lib/CodeGen/CGBlocks.cpp
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CGClass.cpp
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGDeclCXX.cpp
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CGObjCGNU.cpp
clang/lib/CodeGen/CGObjCMac.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
clang/lib/CodeGen/SwiftCallingConv.cpp
clang/lib/Driver/Compilation.cpp
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/ToolChains/Gnu.cpp
clang/lib/Driver/ToolChains/HIPAMD.cpp
clang/lib/Format/Format.cpp
clang/lib/Frontend/FrontendActions.cpp
clang/lib/Index/USRGeneration.cpp
clang/lib/Sema/IdentifierResolver.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaCodeComplete.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaDeclObjC.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaInit.cpp
clang/lib/Sema/SemaLambda.cpp
clang/lib/Sema/SemaLookup.cpp
clang/lib/Sema/SemaObjCProperty.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriterDecl.cpp
clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
clang/lib/StaticAnalyzer/Checkers/UndefinedAssignmentChecker.cpp
clang/lib/StaticAnalyzer/Checkers/WebKit/NoUncountedMembersChecker.cpp
clang/lib/StaticAnalyzer/Core/CallEvent.cpp
clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
clang/lib/StaticAnalyzer/Core/ExprEngineObjC.cpp
clang/lib/Tooling/Tooling.cpp

Removed: 




diff  --git a/clang/lib/ARCMigrate/ObjCMT.cpp b/clang/lib/ARCMigrate/ObjCMT.cpp
index 26f751b77f86a..fe0ce4c5cdc3a 100644
--- a/clang/lib/ARCMigrate/ObjCMT.cpp
+++ b/clang/lib/ARCMigrate/ObjCMT.cpp
@@ -792,7 +792,7 @@ static bool UseNSOptionsMacro(Preprocessor &PP, ASTContext 
&Ctx,
   bool PowerOfTwo = true;
   bool AllHexdecimalEnumerator = true;
   uint64_t MaxPowerOfTwoVal = 0;
-  for (auto Enumerator : EnumDcl->enumerators()) {
+  for (auto *Enumerator : EnumDcl->enumerators()) {
 const Expr *InitExpr = Enumerator->getInitExpr();
 if (!InitExpr) {
   PowerOfTwo = false;

diff  --git a/clang/lib/ARCMigrate/TransGCAttrs.cpp 
b/clang/lib/ARCMigrate/TransGCAttrs.cpp
index 99a61e0842a76..b94aee2de573e 100644
--- a/clang/lib/ARCMigrate/TransGCAttrs.cpp
+++ b/clang/lib/ARCMigrate/TransGCAttrs.cpp
@@ -158,7 +158,7 @@ class GCAttrsCollector : public 
RecursiveASTVisitor {
 if (!D)
   return false;
 
-for (auto I : D->redecls())
+for (auto *I : D->redecls())
   if (!isInMainFile(I->getLocation()))
 return false;
 

diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 52e7eeca665ab..20fcc8fea4b79 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -7568,7 +7568,7 @@ std::string ASTContext::getObjCEncodingForBlock(const 
BlockExpr *Expr) const {
   // FIXME: There might(should) be a better way of doing this computation!
   CharUnits PtrSize = getTypeSizeInChars(VoidPtrTy);
   CharUnits ParmOffset = PtrSize;
-  for (auto PI : Decl->parameters()) {
+  for (auto *PI : Decl->parameters()) {
 QualType PType = PI->getType();
 CharUnits sz = getObjCEncodingTypeSize(PType);
 if (sz.isZero())
@@ -7583,7 +7583,7 @@ std::string ASTContext::getObjCEncodingForBlock(const 
BlockExpr *Expr) const {
 
   // Argument types.
   ParmOffset = PtrSize;
-  for (auto PVDecl : Decl->parameters()) {
+  for (auto *PVDecl : Decl->parameters()) {
 QualType PType = PVDecl->getOriginalType();
 if (const auto *AT =
 dyn_cast(PType->getCanonicalTypeInternal())) {
@@ -7612,7 +7612,7 @@ ASTContext::ge

[clang] f7a759d - [StaticAnalyzer] Stop including llvm/ADT/ImmutableMap.h (NFC)

2023-11-11 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-11-11T13:36:08-08:00
New Revision: f7a759d1b7b8830c3c70802a1e0cc84ae6e12ef6

URL: 
https://github.com/llvm/llvm-project/commit/f7a759d1b7b8830c3c70802a1e0cc84ae6e12ef6
DIFF: 
https://github.com/llvm/llvm-project/commit/f7a759d1b7b8830c3c70802a1e0cc84ae6e12ef6.diff

LOG: [StaticAnalyzer] Stop including llvm/ADT/ImmutableMap.h (NFC)

Identified with clangd.

Added: 


Modified: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicType.h
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h

Removed: 




diff  --git 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicType.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicType.h
index adbfa47c0c3c304..52d1526b1acf44b 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicType.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicType.h
@@ -22,7 +22,6 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState_Fwd.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h"
-#include "llvm/ADT/ImmutableMap.h"
 
 namespace clang {
 namespace ento {

diff  --git 
a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h 
b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h
index 223e28c2c5b8686..d4d7c4c74c56bd4 100644
--- a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h
+++ b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h
@@ -36,7 +36,6 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/ImmutableList.h"
-#include "llvm/ADT/ImmutableMap.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringExtras.h"



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 78a05b9 - [DependencyScanning] Include DenseMap.h instead of DenseSet.h (NFC)

2023-11-11 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-11-11T21:40:59-08:00
New Revision: 78a05b92a87cfa22263499492cc80c8c9cadcecc

URL: 
https://github.com/llvm/llvm-project/commit/78a05b92a87cfa22263499492cc80c8c9cadcecc
DIFF: 
https://github.com/llvm/llvm-project/commit/78a05b92a87cfa22263499492cc80c8c9cadcecc.diff

LOG: [DependencyScanning] Include DenseMap.h instead of DenseSet.h (NFC)

DependencyScanningFilesystem.h uses DenseMap, not DenseSet.

Added: 


Modified: 

clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h

Removed: 




diff  --git 
a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h 
b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
index dbe219b6dd8d723..9a2aea5d6efa170 100644
--- 
a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
+++ 
b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
@@ -11,7 +11,7 @@
 
 #include "clang/Basic/LLVM.h"
 #include "clang/Lex/DependencyDirectivesScanner.h"
-#include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/ErrorOr.h"



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 651c502 - [clang] Stop including llvm/ADT/DenseSet.h (NFC)

2023-11-11 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-11-11T22:25:48-08:00
New Revision: 651c502fc8e6e1dfac4c3701e57da7bece6e637e

URL: 
https://github.com/llvm/llvm-project/commit/651c502fc8e6e1dfac4c3701e57da7bece6e637e
DIFF: 
https://github.com/llvm/llvm-project/commit/651c502fc8e6e1dfac4c3701e57da7bece6e637e.diff

LOG: [clang] Stop including llvm/ADT/DenseSet.h (NFC)

Identified with clangd.

Added: 


Modified: 
clang/include/clang/AST/CXXInheritance.h
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
clang/lib/Format/UnwrappedLineParser.h
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/StaticAnalyzer/Checkers/WebKit/NoUncountedMembersChecker.cpp
clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp
clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLocalVarsChecker.cpp

Removed: 




diff  --git a/clang/include/clang/AST/CXXInheritance.h 
b/clang/include/clang/AST/CXXInheritance.h
index d18e1ce7e0e9e4d..bbef01843e0b0a4 100644
--- a/clang/include/clang/AST/CXXInheritance.h
+++ b/clang/include/clang/AST/CXXInheritance.h
@@ -20,7 +20,6 @@
 #include "clang/AST/TypeOrdering.h"
 #include "clang/Basic/Specifiers.h"
 #include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/SmallVector.h"

diff  --git a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h 
b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
index 826370c2648c287..8956552e7bfc21e 100644
--- a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
+++ b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
@@ -26,7 +26,6 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h"
 #include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/ImmutableSet.h"
 #include "llvm/ADT/SmallSet.h"

diff  --git a/clang/lib/Format/UnwrappedLineParser.h 
b/clang/lib/Format/UnwrappedLineParser.h
index c31f25fdd8f83c9..39294d14e57e574 100644
--- a/clang/lib/Format/UnwrappedLineParser.h
+++ b/clang/lib/Format/UnwrappedLineParser.h
@@ -22,7 +22,6 @@
 #include "clang/Format/Format.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/BitVector.h"
-#include "llvm/ADT/DenseSet.h"
 #include "llvm/Support/Regex.h"
 #include 
 #include 

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 637c6a35af6532b..efcf073dc8d5622 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -48,7 +48,6 @@
 #include "llvm/ADT/APInt.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/CachedHashString.h"
-#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/FloatingPointMode.h"
 #include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/STLExtras.h"

diff  --git 
a/clang/lib/StaticAnalyzer/Checkers/WebKit/NoUncountedMembersChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/NoUncountedMembersChecker.cpp
index d10924776f107de..c753ed84a700cd6 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/NoUncountedMembersChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/NoUncountedMembersChecker.cpp
@@ -17,7 +17,6 @@
 #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
-#include "llvm/ADT/DenseSet.h"
 #include "llvm/Support/Casting.h"
 #include 
 

diff  --git 
a/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp
index 407b6ba7a76428c..31ccae8b097b897 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp
@@ -18,7 +18,6 @@
 #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
-#include "llvm/ADT/DenseSet.h"
 #include 
 
 using namespace clang;

diff  --git 
a/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLocalVarsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLocalVarsChecker.cpp
index fa74759349810fb..5a72f53b12edaaf 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLocalVarsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLocalVarsChecker.cpp
@@ -19,7 +19,6 @@
 #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
-#include "llvm/ADT/DenseSet.h"
 #include 
 
 using namespace clang;



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.

[clang] 46a5693 - [FlowSensitive] Fix warnings

2023-12-08 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-12-08T07:56:45-08:00
New Revision: 46a56931251eba767929f6a2110da5b1bcbc5eb9

URL: 
https://github.com/llvm/llvm-project/commit/46a56931251eba767929f6a2110da5b1bcbc5eb9
DIFF: 
https://github.com/llvm/llvm-project/commit/46a56931251eba767929f6a2110da5b1bcbc5eb9.diff

LOG: [FlowSensitive] Fix warnings

This patch fixes:

  clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp:376:22: error:
  comparison of integers of different signs: 'unsigned int' and
  'TokenInfo::(unnamed enum at
  clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp:356:7)'
  [-Werror,-Wsign-compare]

  clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp:385:23: error:
  comparison of integers of different signs: 'unsigned int' and
  'TokenInfo::(unnamed enum at
  clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp:356:7)'
  [-Werror,-Wsign-compare]

etc

Added: 


Modified: 
clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp

Removed: 




diff  --git a/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp 
b/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
index baa099d2f3fcf..2a7bfce535015 100644
--- a/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
+++ b/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
@@ -353,7 +353,7 @@ class HTMLLogger : public Logger {
 
 // TokenInfo stores the BB and set of elements that a token is part of.
 struct TokenInfo {
-  enum { Missing = -1 };
+  enum : unsigned { Missing = static_cast(-1) };
 
   // The basic block this is part of.
   // This is the BB of the stmt with the smallest containing range.



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[lldb] [llvm] [clang-tools-extra] [clang] [lld] [ADT] Rename SmallString::{starts,ends}with to {starts,ends}_with (PR #74916)

2023-12-08 Thread Kazu Hirata via cfe-commits

https://github.com/kazutakahirata created 
https://github.com/llvm/llvm-project/pull/74916

This patch renames {starts,ends}with to {starts,ends}_with for
consistency with std::{string,string_view}::{starts,ends}_with in
C++20.  Since there are only a handful of occurrences, this patch
skips the deprecation phase and simply renames them.


>From ab33bda7fd31fbfc28344bb6f81ce08394e7c3fd Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Thu, 7 Dec 2023 23:20:42 -0800
Subject: [PATCH] [ADT] Rename SmallString::{starts,ends}with to
 {starts,ends}_with

This patch renames {starts,ends}with to {starts,ends}_with for
consistency with std::{string,string_view}::{starts,ends}_with in
C++20.  Since there are only a handful of occurrences, this patch
skips the deprecation phase and simply renames them.
---
 clang-tools-extra/clang-doc/Mapper.cpp|  2 +-
 clang-tools-extra/modularize/ModuleAssistant.cpp  |  2 +-
 clang/lib/AST/MicrosoftMangle.cpp |  8 
 clang/lib/Basic/Module.cpp|  2 +-
 clang/lib/CrossTU/CrossTranslationUnit.cpp|  2 +-
 clang/lib/Driver/Driver.cpp   |  2 +-
 clang/lib/Driver/ToolChains/Darwin.cpp|  2 +-
 clang/lib/Lex/ModuleMap.cpp   |  2 +-
 clang/lib/Sema/SemaCodeComplete.cpp   |  2 +-
 lld/COFF/PDB.cpp  |  2 +-
 lld/MachO/InputFiles.cpp  |  2 +-
 lldb/source/Commands/CommandCompletions.cpp   |  2 +-
 llvm/include/llvm/ADT/SmallString.h   | 12 
 llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp |  2 +-
 llvm/tools/dsymutil/DebugMap.cpp  |  2 +-
 llvm/tools/llvm-cov/CodeCoverage.cpp  |  2 +-
 llvm/tools/llvm-cov/CoverageReport.cpp|  2 +-
 llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp|  2 +-
 llvm/tools/llvm-ml/llvm-ml.cpp|  2 +-
 llvm/unittests/Support/Path.cpp   |  4 ++--
 20 files changed, 27 insertions(+), 31 deletions(-)

diff --git a/clang-tools-extra/clang-doc/Mapper.cpp 
b/clang-tools-extra/clang-doc/Mapper.cpp
index 5264417748a12b..bb8b7952980ac6 100644
--- a/clang-tools-extra/clang-doc/Mapper.cpp
+++ b/clang-tools-extra/clang-doc/Mapper.cpp
@@ -103,7 +103,7 @@ llvm::SmallString<128> MapASTVisitor::getFile(const 
NamedDecl *D,
   .getPresumedLoc(D->getBeginLoc())
   .getFilename());
   IsFileInRootDir = false;
-  if (RootDir.empty() || !File.startswith(RootDir))
+  if (RootDir.empty() || !File.starts_with(RootDir))
 return File;
   IsFileInRootDir = true;
   llvm::SmallString<128> Prefix(RootDir);
diff --git a/clang-tools-extra/modularize/ModuleAssistant.cpp 
b/clang-tools-extra/modularize/ModuleAssistant.cpp
index 0d4c09987eb1cf..5c11ffdb8589d5 100644
--- a/clang-tools-extra/modularize/ModuleAssistant.cpp
+++ b/clang-tools-extra/modularize/ModuleAssistant.cpp
@@ -175,7 +175,7 @@ static bool addModuleDescription(Module *RootModule,
   llvm::SmallString<256> NativePath, NativePrefix;
   llvm::sys::path::native(HeaderFilePath, NativePath);
   llvm::sys::path::native(HeaderPrefix, NativePrefix);
-  if (NativePath.startswith(NativePrefix))
+  if (NativePath.starts_with(NativePrefix))
 FilePath = std::string(NativePath.substr(NativePrefix.size() + 1));
   else
 FilePath = std::string(HeaderFilePath);
diff --git a/clang/lib/AST/MicrosoftMangle.cpp 
b/clang/lib/AST/MicrosoftMangle.cpp
index 50ab6ea59be9d0..c59a66e103a6e3 100644
--- a/clang/lib/AST/MicrosoftMangle.cpp
+++ b/clang/lib/AST/MicrosoftMangle.cpp
@@ -3809,14 +3809,14 @@ void 
MicrosoftMangleContextImpl::mangleCXXRTTICompleteObjectLocator(
   llvm::raw_svector_ostream Stream(VFTableMangling);
   mangleCXXVFTable(Derived, BasePath, Stream);
 
-  if (VFTableMangling.startswith("??@")) {
-assert(VFTableMangling.endswith("@"));
+  if (VFTableMangling.starts_with("??@")) {
+assert(VFTableMangling.ends_with("@"));
 Out << VFTableMangling << "??_R4@";
 return;
   }
 
-  assert(VFTableMangling.startswith("??_7") ||
- VFTableMangling.startswith("??_S"));
+  assert(VFTableMangling.starts_with("??_7") ||
+ VFTableMangling.starts_with("??_S"));
 
   Out << "??_R4" << VFTableMangling.str().drop_front(4);
 }
diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp
index e4ac1abf12a7f8..7523e509a47108 100644
--- a/clang/lib/Basic/Module.cpp
+++ b/clang/lib/Basic/Module.cpp
@@ -89,7 +89,7 @@ static bool isPlatformEnvironment(const TargetInfo &Target, 
StringRef Feature) {
   // where both are valid examples of the same platform+environment but in the
   // variant (2) the simulator is hardcoded as part of the platform name. Both
   // forms above should match for "iossimulator" requirement.
-  if (Target.getTriple().isOSDarwin() && PlatformEnv.endswith("simulator"))
+  if (Target.getTriple().isOSDarwin() && PlatformEnv.ends_with("simulator"))
   

[llvm] [lldb] [clang-tools-extra] [clang] [lld] [ADT] Rename SmallString::{starts,ends}with to {starts,ends}_with (PR #74916)

2023-12-08 Thread Kazu Hirata via cfe-commits

https://github.com/kazutakahirata updated 
https://github.com/llvm/llvm-project/pull/74916

>From ab33bda7fd31fbfc28344bb6f81ce08394e7c3fd Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Thu, 7 Dec 2023 23:20:42 -0800
Subject: [PATCH 1/2] [ADT] Rename SmallString::{starts,ends}with to
 {starts,ends}_with

This patch renames {starts,ends}with to {starts,ends}_with for
consistency with std::{string,string_view}::{starts,ends}_with in
C++20.  Since there are only a handful of occurrences, this patch
skips the deprecation phase and simply renames them.
---
 clang-tools-extra/clang-doc/Mapper.cpp|  2 +-
 clang-tools-extra/modularize/ModuleAssistant.cpp  |  2 +-
 clang/lib/AST/MicrosoftMangle.cpp |  8 
 clang/lib/Basic/Module.cpp|  2 +-
 clang/lib/CrossTU/CrossTranslationUnit.cpp|  2 +-
 clang/lib/Driver/Driver.cpp   |  2 +-
 clang/lib/Driver/ToolChains/Darwin.cpp|  2 +-
 clang/lib/Lex/ModuleMap.cpp   |  2 +-
 clang/lib/Sema/SemaCodeComplete.cpp   |  2 +-
 lld/COFF/PDB.cpp  |  2 +-
 lld/MachO/InputFiles.cpp  |  2 +-
 lldb/source/Commands/CommandCompletions.cpp   |  2 +-
 llvm/include/llvm/ADT/SmallString.h   | 12 
 llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp |  2 +-
 llvm/tools/dsymutil/DebugMap.cpp  |  2 +-
 llvm/tools/llvm-cov/CodeCoverage.cpp  |  2 +-
 llvm/tools/llvm-cov/CoverageReport.cpp|  2 +-
 llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp|  2 +-
 llvm/tools/llvm-ml/llvm-ml.cpp|  2 +-
 llvm/unittests/Support/Path.cpp   |  4 ++--
 20 files changed, 27 insertions(+), 31 deletions(-)

diff --git a/clang-tools-extra/clang-doc/Mapper.cpp 
b/clang-tools-extra/clang-doc/Mapper.cpp
index 5264417748a12..bb8b7952980ac 100644
--- a/clang-tools-extra/clang-doc/Mapper.cpp
+++ b/clang-tools-extra/clang-doc/Mapper.cpp
@@ -103,7 +103,7 @@ llvm::SmallString<128> MapASTVisitor::getFile(const 
NamedDecl *D,
   .getPresumedLoc(D->getBeginLoc())
   .getFilename());
   IsFileInRootDir = false;
-  if (RootDir.empty() || !File.startswith(RootDir))
+  if (RootDir.empty() || !File.starts_with(RootDir))
 return File;
   IsFileInRootDir = true;
   llvm::SmallString<128> Prefix(RootDir);
diff --git a/clang-tools-extra/modularize/ModuleAssistant.cpp 
b/clang-tools-extra/modularize/ModuleAssistant.cpp
index 0d4c09987eb1c..5c11ffdb8589d 100644
--- a/clang-tools-extra/modularize/ModuleAssistant.cpp
+++ b/clang-tools-extra/modularize/ModuleAssistant.cpp
@@ -175,7 +175,7 @@ static bool addModuleDescription(Module *RootModule,
   llvm::SmallString<256> NativePath, NativePrefix;
   llvm::sys::path::native(HeaderFilePath, NativePath);
   llvm::sys::path::native(HeaderPrefix, NativePrefix);
-  if (NativePath.startswith(NativePrefix))
+  if (NativePath.starts_with(NativePrefix))
 FilePath = std::string(NativePath.substr(NativePrefix.size() + 1));
   else
 FilePath = std::string(HeaderFilePath);
diff --git a/clang/lib/AST/MicrosoftMangle.cpp 
b/clang/lib/AST/MicrosoftMangle.cpp
index 50ab6ea59be9d..c59a66e103a6e 100644
--- a/clang/lib/AST/MicrosoftMangle.cpp
+++ b/clang/lib/AST/MicrosoftMangle.cpp
@@ -3809,14 +3809,14 @@ void 
MicrosoftMangleContextImpl::mangleCXXRTTICompleteObjectLocator(
   llvm::raw_svector_ostream Stream(VFTableMangling);
   mangleCXXVFTable(Derived, BasePath, Stream);
 
-  if (VFTableMangling.startswith("??@")) {
-assert(VFTableMangling.endswith("@"));
+  if (VFTableMangling.starts_with("??@")) {
+assert(VFTableMangling.ends_with("@"));
 Out << VFTableMangling << "??_R4@";
 return;
   }
 
-  assert(VFTableMangling.startswith("??_7") ||
- VFTableMangling.startswith("??_S"));
+  assert(VFTableMangling.starts_with("??_7") ||
+ VFTableMangling.starts_with("??_S"));
 
   Out << "??_R4" << VFTableMangling.str().drop_front(4);
 }
diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp
index e4ac1abf12a7f..7523e509a4710 100644
--- a/clang/lib/Basic/Module.cpp
+++ b/clang/lib/Basic/Module.cpp
@@ -89,7 +89,7 @@ static bool isPlatformEnvironment(const TargetInfo &Target, 
StringRef Feature) {
   // where both are valid examples of the same platform+environment but in the
   // variant (2) the simulator is hardcoded as part of the platform name. Both
   // forms above should match for "iossimulator" requirement.
-  if (Target.getTriple().isOSDarwin() && PlatformEnv.endswith("simulator"))
+  if (Target.getTriple().isOSDarwin() && PlatformEnv.ends_with("simulator"))
 return PlatformEnv == Feature || CmpPlatformEnv(PlatformEnv, Feature);
 
   return PlatformEnv == Feature;
diff --git a/clang/lib/CrossTU/CrossTranslationUnit.cpp 
b/clang/lib/CrossTU/CrossTranslationUnit.cpp
index 540c22d078654..94c10e50d7d06 100644
-

[clang] [llvm] [lld] [lldb] [clang-tools-extra] [ADT] Rename SmallString::{starts,ends}with to {starts,ends}_with (PR #74916)

2023-12-08 Thread Kazu Hirata via cfe-commits

kazutakahirata wrote:

> flang and bolt are not changed?

Right.  Somehow, `SmallString::{startswith,endswith}` do not occur there.  
By the way, they are not to be confused with `StringRef::{startswith,endswith}, 
which is everywhere.

https://github.com/llvm/llvm-project/pull/74916
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [lld] [lldb] [clang-tools-extra] [ADT] Rename SmallString::{starts,ends}with to {starts,ends}_with (PR #74916)

2023-12-08 Thread Kazu Hirata via cfe-commits

https://github.com/kazutakahirata updated 
https://github.com/llvm/llvm-project/pull/74916

>From ab33bda7fd31fbfc28344bb6f81ce08394e7c3fd Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Thu, 7 Dec 2023 23:20:42 -0800
Subject: [PATCH 1/3] [ADT] Rename SmallString::{starts,ends}with to
 {starts,ends}_with

This patch renames {starts,ends}with to {starts,ends}_with for
consistency with std::{string,string_view}::{starts,ends}_with in
C++20.  Since there are only a handful of occurrences, this patch
skips the deprecation phase and simply renames them.
---
 clang-tools-extra/clang-doc/Mapper.cpp|  2 +-
 clang-tools-extra/modularize/ModuleAssistant.cpp  |  2 +-
 clang/lib/AST/MicrosoftMangle.cpp |  8 
 clang/lib/Basic/Module.cpp|  2 +-
 clang/lib/CrossTU/CrossTranslationUnit.cpp|  2 +-
 clang/lib/Driver/Driver.cpp   |  2 +-
 clang/lib/Driver/ToolChains/Darwin.cpp|  2 +-
 clang/lib/Lex/ModuleMap.cpp   |  2 +-
 clang/lib/Sema/SemaCodeComplete.cpp   |  2 +-
 lld/COFF/PDB.cpp  |  2 +-
 lld/MachO/InputFiles.cpp  |  2 +-
 lldb/source/Commands/CommandCompletions.cpp   |  2 +-
 llvm/include/llvm/ADT/SmallString.h   | 12 
 llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp |  2 +-
 llvm/tools/dsymutil/DebugMap.cpp  |  2 +-
 llvm/tools/llvm-cov/CodeCoverage.cpp  |  2 +-
 llvm/tools/llvm-cov/CoverageReport.cpp|  2 +-
 llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp|  2 +-
 llvm/tools/llvm-ml/llvm-ml.cpp|  2 +-
 llvm/unittests/Support/Path.cpp   |  4 ++--
 20 files changed, 27 insertions(+), 31 deletions(-)

diff --git a/clang-tools-extra/clang-doc/Mapper.cpp 
b/clang-tools-extra/clang-doc/Mapper.cpp
index 5264417748a12b..bb8b7952980ac6 100644
--- a/clang-tools-extra/clang-doc/Mapper.cpp
+++ b/clang-tools-extra/clang-doc/Mapper.cpp
@@ -103,7 +103,7 @@ llvm::SmallString<128> MapASTVisitor::getFile(const 
NamedDecl *D,
   .getPresumedLoc(D->getBeginLoc())
   .getFilename());
   IsFileInRootDir = false;
-  if (RootDir.empty() || !File.startswith(RootDir))
+  if (RootDir.empty() || !File.starts_with(RootDir))
 return File;
   IsFileInRootDir = true;
   llvm::SmallString<128> Prefix(RootDir);
diff --git a/clang-tools-extra/modularize/ModuleAssistant.cpp 
b/clang-tools-extra/modularize/ModuleAssistant.cpp
index 0d4c09987eb1cf..5c11ffdb8589d5 100644
--- a/clang-tools-extra/modularize/ModuleAssistant.cpp
+++ b/clang-tools-extra/modularize/ModuleAssistant.cpp
@@ -175,7 +175,7 @@ static bool addModuleDescription(Module *RootModule,
   llvm::SmallString<256> NativePath, NativePrefix;
   llvm::sys::path::native(HeaderFilePath, NativePath);
   llvm::sys::path::native(HeaderPrefix, NativePrefix);
-  if (NativePath.startswith(NativePrefix))
+  if (NativePath.starts_with(NativePrefix))
 FilePath = std::string(NativePath.substr(NativePrefix.size() + 1));
   else
 FilePath = std::string(HeaderFilePath);
diff --git a/clang/lib/AST/MicrosoftMangle.cpp 
b/clang/lib/AST/MicrosoftMangle.cpp
index 50ab6ea59be9d0..c59a66e103a6e3 100644
--- a/clang/lib/AST/MicrosoftMangle.cpp
+++ b/clang/lib/AST/MicrosoftMangle.cpp
@@ -3809,14 +3809,14 @@ void 
MicrosoftMangleContextImpl::mangleCXXRTTICompleteObjectLocator(
   llvm::raw_svector_ostream Stream(VFTableMangling);
   mangleCXXVFTable(Derived, BasePath, Stream);
 
-  if (VFTableMangling.startswith("??@")) {
-assert(VFTableMangling.endswith("@"));
+  if (VFTableMangling.starts_with("??@")) {
+assert(VFTableMangling.ends_with("@"));
 Out << VFTableMangling << "??_R4@";
 return;
   }
 
-  assert(VFTableMangling.startswith("??_7") ||
- VFTableMangling.startswith("??_S"));
+  assert(VFTableMangling.starts_with("??_7") ||
+ VFTableMangling.starts_with("??_S"));
 
   Out << "??_R4" << VFTableMangling.str().drop_front(4);
 }
diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp
index e4ac1abf12a7f8..7523e509a47108 100644
--- a/clang/lib/Basic/Module.cpp
+++ b/clang/lib/Basic/Module.cpp
@@ -89,7 +89,7 @@ static bool isPlatformEnvironment(const TargetInfo &Target, 
StringRef Feature) {
   // where both are valid examples of the same platform+environment but in the
   // variant (2) the simulator is hardcoded as part of the platform name. Both
   // forms above should match for "iossimulator" requirement.
-  if (Target.getTriple().isOSDarwin() && PlatformEnv.endswith("simulator"))
+  if (Target.getTriple().isOSDarwin() && PlatformEnv.ends_with("simulator"))
 return PlatformEnv == Feature || CmpPlatformEnv(PlatformEnv, Feature);
 
   return PlatformEnv == Feature;
diff --git a/clang/lib/CrossTU/CrossTranslationUnit.cpp 
b/clang/lib/CrossTU/CrossTranslationUnit.cpp
index 540c22d078654c..94c10e50d7d06

[clang] [clang-tools-extra] [llvm] [lld] [lldb] [ADT] Rename SmallString::{starts,ends}with to {starts,ends}_with (PR #74916)

2023-12-09 Thread Kazu Hirata via cfe-commits

https://github.com/kazutakahirata closed 
https://github.com/llvm/llvm-project/pull/74916
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 2ec95c1 - [clang] Use llvm::to_underlying (NFC)

2023-12-09 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-12-09T17:08:48-08:00
New Revision: 2ec95c19a267b5e58033701b12f55e0870bd3e6a

URL: 
https://github.com/llvm/llvm-project/commit/2ec95c19a267b5e58033701b12f55e0870bd3e6a
DIFF: 
https://github.com/llvm/llvm-project/commit/2ec95c19a267b5e58033701b12f55e0870bd3e6a.diff

LOG: [clang] Use llvm::to_underlying (NFC)

Added: 


Modified: 
clang/include/clang/AST/Type.h
clang/lib/CodeGen/CGCall.h

Removed: 




diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index b14184afe5840..b3ae66e6e769d 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -36,6 +36,7 @@
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/PointerIntPair.h"
 #include "llvm/ADT/PointerUnion.h"
+#include "llvm/ADT/STLForwardCompat.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/ADT/iterator_range.h"
@@ -7514,7 +7515,7 @@ inline const Type *Type::getPointeeOrArrayElementType() 
const {
 /// spaces into a diagnostic with <<.
 inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &PD,
  LangAS AS) {
-  PD.AddTaggedVal(static_cast>(AS),
+  PD.AddTaggedVal(llvm::to_underlying(AS),
   DiagnosticsEngine::ArgumentKind::ak_addrspace);
   return PD;
 }

diff  --git a/clang/lib/CodeGen/CGCall.h b/clang/lib/CodeGen/CGCall.h
index aee86a3242fd3..1c0d15dc932ad 100644
--- a/clang/lib/CodeGen/CGCall.h
+++ b/clang/lib/CodeGen/CGCall.h
@@ -20,6 +20,7 @@
 #include "clang/AST/CanonicalType.h"
 #include "clang/AST/GlobalDecl.h"
 #include "clang/AST/Type.h"
+#include "llvm/ADT/STLForwardCompat.h"
 #include "llvm/IR/Value.h"
 
 namespace llvm {
@@ -406,15 +407,13 @@ enum class FnInfoOpts {
 };
 
 inline FnInfoOpts operator|(FnInfoOpts A, FnInfoOpts B) {
-  return static_cast(
-  static_cast>(A) |
-  static_cast>(B));
+  return static_cast(llvm::to_underlying(A) |
+ llvm::to_underlying(B));
 }
 
 inline FnInfoOpts operator&(FnInfoOpts A, FnInfoOpts B) {
-  return static_cast(
-  static_cast>(A) &
-  static_cast>(B));
+  return static_cast(llvm::to_underlying(A) &
+ llvm::to_underlying(B));
 }
 
 inline FnInfoOpts operator|=(FnInfoOpts A, FnInfoOpts B) {



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] c60ac50 - [clang-tools-extra] Use llvm::to_underlying (NFC)

2023-12-09 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-12-09T17:34:10-08:00
New Revision: c60ac509399da5cba533b9b6cc5b983c59f7d7b3

URL: 
https://github.com/llvm/llvm-project/commit/c60ac509399da5cba533b9b6cc5b983c59f7d7b3
DIFF: 
https://github.com/llvm/llvm-project/commit/c60ac509399da5cba533b9b6cc5b983c59f7d7b3.diff

LOG: [clang-tools-extra] Use llvm::to_underlying (NFC)

Added: 


Modified: 

clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp
clang-tools-extra/pseudo/include/clang-pseudo/Token.h

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp
index 831614148c7c2..759cdd44fd658 100644
--- 
a/clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp
@@ -20,6 +20,7 @@
 #include "clang/Basic/DiagnosticIDs.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/SourceLocation.h"
+#include "llvm/ADT/STLForwardCompat.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -167,15 +168,13 @@ static const std::array Msgs = {{
 // Criteria is a bitset, thus a few helpers are needed.
 CognitiveComplexity::Criteria operator|(CognitiveComplexity::Criteria LHS,
 CognitiveComplexity::Criteria RHS) {
-  return static_cast(
-  static_cast>(LHS) |
-  static_cast>(RHS));
+  return static_cast(llvm::to_underlying(LHS) |
+llvm::to_underlying(RHS));
 }
 CognitiveComplexity::Criteria operator&(CognitiveComplexity::Criteria LHS,
 CognitiveComplexity::Criteria RHS) {
-  return static_cast(
-  static_cast>(LHS) &
-  static_cast>(RHS));
+  return static_cast(llvm::to_underlying(LHS) &
+llvm::to_underlying(RHS));
 }
 CognitiveComplexity::Criteria &operator|=(CognitiveComplexity::Criteria &LHS,
   CognitiveComplexity::Criteria RHS) {

diff  --git a/clang-tools-extra/pseudo/include/clang-pseudo/Token.h 
b/clang-tools-extra/pseudo/include/clang-pseudo/Token.h
index 22b72c71cbbab..859fd7d2b3dfe 100644
--- a/clang-tools-extra/pseudo/include/clang-pseudo/Token.h
+++ b/clang-tools-extra/pseudo/include/clang-pseudo/Token.h
@@ -32,6 +32,7 @@
 #include "clang/Basic/LangStandard.h"
 #include "clang/Basic/TokenKinds.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/STLForwardCompat.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
@@ -71,10 +72,10 @@ struct Token {
   Index OriginalIndex = Invalid;
   // Helpers to get/set Flags based on `enum class`.
   template  bool flag(T Mask) const {
-return Flags & uint8_t{static_cast>(Mask)};
+return Flags & uint8_t{llvm::to_underlying(Mask)};
   }
   template  void setFlag(T Mask) {
-Flags |= uint8_t{static_cast>(Mask)};
+Flags |= uint8_t{llvm::to_underlying(Mask)};
   }
 
   /// Returns the next token in the stream. this may not be a sentinel.



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [clang] [NFC][InstrProf] Refactor InstrProfiling lowering pass (PR #74970)

2023-12-10 Thread Kazu Hirata via cfe-commits

https://github.com/kazutakahirata approved this pull request.

LGTM module stylistic comments.

https://github.com/llvm/llvm-project/pull/74970
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [NFC][InstrProf] Refactor InstrProfiling lowering pass (PR #74970)

2023-12-10 Thread Kazu Hirata via cfe-commits


@@ -31,31 +31,45 @@ using LoadStorePair = std::pair;
 /// Instrumentation based profiling lowering pass. This pass lowers
 /// the profile instrumented code generated by FE or the IR based
 /// instrumentation pass.
-class InstrProfiling : public PassInfoMixin {
+class InstrProfilingLoweringPass
+: public PassInfoMixin {
+  const InstrProfOptions Options;
+  // Is this lowering for the context-sensitive instrumentation.
+  const bool IsCS;
+
 public:
-  InstrProfiling() : IsCS(false) {}
-  InstrProfiling(const InstrProfOptions &Options, bool IsCS = false)
+  InstrProfilingLoweringPass() : IsCS(false) {}
+  InstrProfilingLoweringPass(const InstrProfOptions &Options, bool IsCS = 
false)
   : Options(Options), IsCS(IsCS) {}
 
   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
-  bool run(Module &M,
-   std::function GetTLI);
+};
+class InstrProfiling final {

kazutakahirata wrote:

May I suggest an empty line just before `class InstrProfiling final {`?

https://github.com/llvm/llvm-project/pull/74970
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [NFC][InstrProf] Refactor InstrProfiling lowering pass (PR #74970)

2023-12-10 Thread Kazu Hirata via cfe-commits

https://github.com/kazutakahirata edited 
https://github.com/llvm/llvm-project/pull/74970
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [NFC][InstrProf] Refactor InstrProfiling lowering pass (PR #74970)

2023-12-10 Thread Kazu Hirata via cfe-commits


@@ -31,31 +31,45 @@ using LoadStorePair = std::pair;
 /// Instrumentation based profiling lowering pass. This pass lowers
 /// the profile instrumented code generated by FE or the IR based
 /// instrumentation pass.
-class InstrProfiling : public PassInfoMixin {
+class InstrProfilingLoweringPass
+: public PassInfoMixin {
+  const InstrProfOptions Options;
+  // Is this lowering for the context-sensitive instrumentation.
+  const bool IsCS;
+
 public:
-  InstrProfiling() : IsCS(false) {}
-  InstrProfiling(const InstrProfOptions &Options, bool IsCS = false)
+  InstrProfilingLoweringPass() : IsCS(false) {}

kazutakahirata wrote:

We could "move" `false` to the declaration above:

`InstrProfilingLoweringPass() = default;`


https://github.com/llvm/llvm-project/pull/74970
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [NFC][InstrProf] Refactor InstrProfiling lowering pass (PR #74970)

2023-12-10 Thread Kazu Hirata via cfe-commits


@@ -31,31 +31,45 @@ using LoadStorePair = std::pair;
 /// Instrumentation based profiling lowering pass. This pass lowers
 /// the profile instrumented code generated by FE or the IR based
 /// instrumentation pass.
-class InstrProfiling : public PassInfoMixin {
+class InstrProfilingLoweringPass
+: public PassInfoMixin {
+  const InstrProfOptions Options;
+  // Is this lowering for the context-sensitive instrumentation.
+  const bool IsCS;

kazutakahirata wrote:

Could we say `const bool IsCS = false;`here  to enable the defaulted default 
constructor below?

https://github.com/llvm/llvm-project/pull/74970
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 65a1841 - [DirectoryWatcher] Include limits.h instead of MathExtras.h (NFC)

2023-12-10 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-12-10T12:12:54-08:00
New Revision: 65a18412ab26f92df133ca1ef3ff7ff7dbf3c5f8

URL: 
https://github.com/llvm/llvm-project/commit/65a18412ab26f92df133ca1ef3ff7ff7dbf3c5f8
DIFF: 
https://github.com/llvm/llvm-project/commit/65a18412ab26f92df133ca1ef3ff7ff7dbf3c5f8.diff

LOG: [DirectoryWatcher] Include limits.h instead of MathExtras.h (NFC)

Added: 


Modified: 
clang/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp

Removed: 




diff  --git a/clang/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp 
b/clang/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp
index 9b3d2571f29f6..beca9586988b5 100644
--- a/clang/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp
+++ b/clang/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp
@@ -14,7 +14,6 @@
 #include "llvm/Support/AlignOf.h"
 #include "llvm/Support/Errno.h"
 #include "llvm/Support/Error.h"
-#include "llvm/Support/MathExtras.h"
 #include "llvm/Support/Path.h"
 #include 
 #include 
@@ -25,6 +24,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [mlir] [clang] [llvm] Improve implementation of StringRef::find_last_of and cie (PR #71865)

2023-11-14 Thread Kazu Hirata via cfe-commits

https://github.com/kazutakahirata commented:

This patch looks good to me.  I am not sure if we want to implement 
architecture-specific optimizations like `__SSE2__` at the source-code level.  
But then I don't want that to block the landing of this patch.  Is there any 
way you could separate these two patches?  Thanks!

https://github.com/llvm/llvm-project/pull/71865
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [mlir] [clang] [llvm] Improve implementation of StringRef::find_last_of and cie (PR #71865)

2023-11-14 Thread Kazu Hirata via cfe-commits

https://github.com/kazutakahirata edited 
https://github.com/llvm/llvm-project/pull/71865
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] f8e8530 - [StaticAnalyzer] Fix warnings about missing override

2023-11-16 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-11-16T11:06:01-08:00
New Revision: f8e8530f7377ab84b23c268454015fbcb95231c0

URL: 
https://github.com/llvm/llvm-project/commit/f8e8530f7377ab84b23c268454015fbcb95231c0
DIFF: 
https://github.com/llvm/llvm-project/commit/f8e8530f7377ab84b23c268454015fbcb95231c0.diff

LOG: [StaticAnalyzer] Fix warnings about missing override

This patch fixes:

  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:609:23:
  error: 'describe' overrides a member function but is not marked
  'override' [-Werror,-Winconsistent-missing-override]

  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:627:23:
  error: 'describe' overrides a member function but is not marked
  'override' [-Werror,-Winconsistent-missing-override]

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
index 2163689c6a05906..fffcaf7ed18fb7c 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -606,7 +606,7 @@ class StdLibraryFunctionsChecker
   return errno_modeling::setErrnoForStdSuccess(State, C);
 }
 
-const std::string describe(CheckerContext &C) const {
+const std::string describe(CheckerContext &C) const override {
   return "'errno' becomes undefined after the call";
 }
   };
@@ -624,7 +624,7 @@ class StdLibraryFunctionsChecker
   Call.getOriginExpr());
 }
 
-const std::string describe(CheckerContext &C) const {
+const std::string describe(CheckerContext &C) const override {
   return "reading 'errno' is required to find out if the call has failed";
 }
   };



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 2b76bdc - [clang-doc] Fix a warning

2023-11-03 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-11-03T11:03:15-07:00
New Revision: 2b76bdc33b555beb637c13b8bdbd8d3e935d9d56

URL: 
https://github.com/llvm/llvm-project/commit/2b76bdc33b555beb637c13b8bdbd8d3e935d9d56
DIFF: 
https://github.com/llvm/llvm-project/commit/2b76bdc33b555beb637c13b8bdbd8d3e935d9d56.diff

LOG: [clang-doc] Fix a warning

This patch fixes:

  clang-tools-extra/clang-doc/BitcodeReader.cpp:78:3: error: default
  label in switch which covers all enumeration values
  [-Werror,-Wcovered-switch-default]

Added: 


Modified: 
clang-tools-extra/clang-doc/BitcodeReader.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-doc/BitcodeReader.cpp 
b/clang-tools-extra/clang-doc/BitcodeReader.cpp
index 8c97186b299fc2e..bfb04e7407b3804 100644
--- a/clang-tools-extra/clang-doc/BitcodeReader.cpp
+++ b/clang-tools-extra/clang-doc/BitcodeReader.cpp
@@ -75,10 +75,9 @@ llvm::Error decodeRecord(const Record &R, TagTypeKind &Field,
   case TagTypeKind::Enum:
 Field = static_cast(R[0]);
 return llvm::Error::success();
-  default:
-return llvm::createStringError(llvm::inconvertibleErrorCode(),
-   "invalid value for TagTypeKind");
   }
+  return llvm::createStringError(llvm::inconvertibleErrorCode(),
+ "invalid value for TagTypeKind");
 }
 
 llvm::Error decodeRecord(const Record &R, std::optional &Field,



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 2414e5c - [Serialization] Fix warnings

2023-11-04 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-11-04T12:24:06-07:00
New Revision: 2414e5cb9efa289b841bb814d20c7eb6f355fa4d

URL: 
https://github.com/llvm/llvm-project/commit/2414e5cb9efa289b841bb814d20c7eb6f355fa4d
DIFF: 
https://github.com/llvm/llvm-project/commit/2414e5cb9efa289b841bb814d20c7eb6f355fa4d.diff

LOG: [Serialization] Fix warnings

This patch fixes:

  clang/lib/Serialization/ASTWriterStmt.cpp:576:3: error: default
  label in switch which covers all enumeration values
  [-Werror,-Wcovered-switch-default]

  clang/lib/Serialization/ASTReaderStmt.cpp:561:3: error: default
  label in switch which covers all enumeration values
  [-Werror,-Wcovered-switch-default]

Added: 


Modified: 
clang/lib/Serialization/ASTReaderStmt.cpp
clang/lib/Serialization/ASTWriterStmt.cpp

Removed: 




diff  --git a/clang/lib/Serialization/ASTReaderStmt.cpp 
b/clang/lib/Serialization/ASTReaderStmt.cpp
index ab62f8f17851517..21d33e1c57cc988 100644
--- a/clang/lib/Serialization/ASTReaderStmt.cpp
+++ b/clang/lib/Serialization/ASTReaderStmt.cpp
@@ -558,8 +558,6 @@ void ASTStmtReader::VisitConstantExpr(ConstantExpr *E) {
   Record.getContext().addDestruction(&E->APValueResult());
 }
 break;
-  default:
-llvm_unreachable("unexpected ResultKind!");
   }
 
   E->setSubExpr(Record.readSubExpr());

diff  --git a/clang/lib/Serialization/ASTWriterStmt.cpp 
b/clang/lib/Serialization/ASTWriterStmt.cpp
index 00b1e4261735990..edfa3fab6cd4576 100644
--- a/clang/lib/Serialization/ASTWriterStmt.cpp
+++ b/clang/lib/Serialization/ASTWriterStmt.cpp
@@ -573,8 +573,6 @@ void ASTStmtWriter::VisitConstantExpr(ConstantExpr *E) {
   case ConstantResultStorageKind::APValue:
 Record.AddAPValue(E->APValueResult());
 break;
-  default:
-llvm_unreachable("unexpected ResultKind!");
   }
 
   Record.AddStmt(E->getSubExpr());



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Use StringRef::{starts,ends}_with (NFC) (PR #75149)

2023-12-13 Thread Kazu Hirata via cfe-commits

https://github.com/kazutakahirata closed 
https://github.com/llvm/llvm-project/pull/75149
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 76bbbcb - [clang-tidy] Use StringRef::{starts,ends}_with (NFC)

2023-12-13 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-12-13T23:11:05-08:00
New Revision: 76bbbcb41bcf4a1d7a26bb11b78cf97b60ea7d4b

URL: 
https://github.com/llvm/llvm-project/commit/76bbbcb41bcf4a1d7a26bb11b78cf97b60ea7d4b
DIFF: 
https://github.com/llvm/llvm-project/commit/76bbbcb41bcf4a1d7a26bb11b78cf97b60ea7d4b.diff

LOG: [clang-tidy] Use StringRef::{starts,ends}_with (NFC)

This patch replaces uses of StringRef::{starts,ends}with with
StringRef::{starts,ends}_with for consistency with
std::{string,string_view}::{starts,ends}_with in C++20.

I'm planning to deprecate and eventually remove
StringRef::{starts,ends}with.

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidy.cpp
clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
clang-tools-extra/clang-tidy/GlobList.cpp
clang-tools-extra/clang-tidy/abseil/AbseilMatcher.h
clang-tools-extra/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp
clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp
clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp
clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp
clang-tools-extra/clang-tidy/google/UsingNamespaceDirectiveCheck.cpp
clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.cpp
clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
clang-tools-extra/clang-tidy/misc/ConfusableTable/BuildConfusableTable.cpp
clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
clang-tools-extra/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseNodiscardCheck.cpp
clang-tools-extra/clang-tidy/plugin/ClangTidyPlugin.cpp
clang-tools-extra/clang-tidy/portability/SIMDIntrinsicsCheck.cpp
clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
clang-tools-extra/clang-tidy/readability/IsolateDeclarationCheck.cpp
clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp

clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
clang-tools-extra/clang-tidy/utils/Matchers.h

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp 
b/clang-tools-extra/clang-tidy/ClangTidy.cpp
index 565f044778c946..40ac6918faf407 100644
--- a/clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -390,7 +390,7 @@ static CheckersList 
getAnalyzerCheckersAndPackages(ClangTidyContext &Context,
   for (StringRef CheckName : RegisteredCheckers) {
 std::string ClangTidyCheckName((AnalyzerCheckNamePrefix + 
CheckName).str());
 
-if (CheckName.startswith("core") ||
+if (CheckName.starts_with("core") ||
 Context.isCheckEnabled(ClangTidyCheckName)) {
   List.emplace_back(std::string(CheckName), true);
 }
@@ -541,7 +541,7 @@ runClangTidy(clang::tidy::ClangTidyContext &Context,
 CommandLineArguments AdjustedArgs = Args;
 if (Opts.ExtraArgsBefore) {
   auto I = AdjustedArgs.begin();
-  if (I != AdjustedArgs.end() && !StringRef(*I).startswith("-"))
+  if (I != AdjustedArgs.end() && !StringRef(*I).starts_with("-"))
 ++I; // Skip compiler binary name, if it is there.
   AdjustedArgs.insert(I, Opts.ExtraArgsBefore->begin(),
   Opts.ExtraArgsBefore->end());

diff  --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
index b19a84f5dc2157..0a80c996de 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -62,7 +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.endswith(CheckNameInMessage))
+if (Message.ends_with(CheckNameInMessage))
   Message = Message.substr(0, Message.size() - CheckNameInMessage.size());
 
 auto TidyMessage =
@@ -457,7 +457,7 @@ bool 
ClangTidyDiagnosticConsumer::passesLineFilter(StringRe

[clang-tools-extra] d5953e3 - [clangd] Use StringRef::{starts,ends}_with (NFC)

2023-12-13 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-12-13T23:26:09-08:00
New Revision: d5953e3e3092f7142a07aa012fc9665ede09e53b

URL: 
https://github.com/llvm/llvm-project/commit/d5953e3e3092f7142a07aa012fc9665ede09e53b
DIFF: 
https://github.com/llvm/llvm-project/commit/d5953e3e3092f7142a07aa012fc9665ede09e53b.diff

LOG: [clangd] Use StringRef::{starts,ends}_with (NFC)

This patch replaces uses of StringRef::{starts,ends}with with
StringRef::{starts,ends}_with for consistency with
std::{string,string_view}::{starts,ends}_with in C++20.

I'm planning to deprecate and eventually remove
StringRef::{starts,ends}with.

Added: 


Modified: 
clang-tools-extra/clangd/AST.cpp
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/CodeCompletionStrings.cpp
clang-tools-extra/clangd/CompileCommands.cpp
clang-tools-extra/clangd/ConfigCompile.cpp
clang-tools-extra/clangd/DumpAST.cpp
clang-tools-extra/clangd/FileDistance.cpp
clang-tools-extra/clangd/FindSymbols.cpp
clang-tools-extra/clangd/Format.cpp
clang-tools-extra/clangd/Headers.cpp
clang-tools-extra/clangd/Hover.cpp
clang-tools-extra/clangd/IncludeCleaner.cpp
clang-tools-extra/clangd/IncludeFixer.cpp
clang-tools-extra/clangd/InlayHints.cpp
clang-tools-extra/clangd/JSONTransport.cpp
clang-tools-extra/clangd/ParsedAST.cpp
clang-tools-extra/clangd/PathMapping.cpp
clang-tools-extra/clangd/Protocol.cpp
clang-tools-extra/clangd/SourceCode.cpp
clang-tools-extra/clangd/SystemIncludeExtractor.cpp
clang-tools-extra/clangd/URI.cpp
clang-tools-extra/clangd/index/Merge.cpp
clang-tools-extra/clangd/index/Serialization.cpp
clang-tools-extra/clangd/index/StdLib.cpp
clang-tools-extra/clangd/index/SymbolCollector.cpp
clang-tools-extra/clangd/index/dex/Dex.cpp
clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
clang-tools-extra/clangd/support/Markup.cpp
clang-tools-extra/clangd/support/ThreadsafeFS.cpp
clang-tools-extra/clangd/tool/ClangdMain.cpp
clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
clang-tools-extra/clangd/unittests/IndexActionTests.cpp
clang-tools-extra/clangd/unittests/InlayHintTests.cpp
clang-tools-extra/clangd/unittests/InsertionPointTests.cpp
clang-tools-extra/clangd/unittests/StdLibTests.cpp
clang-tools-extra/clangd/unittests/tweaks/TweakTesting.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/AST.cpp 
b/clang-tools-extra/clangd/AST.cpp
index 5b81ec213ff984..ae79eb21de9470 100644
--- a/clang-tools-extra/clangd/AST.cpp
+++ b/clang-tools-extra/clangd/AST.cpp
@@ -193,7 +193,7 @@ std::string printQualifiedName(const NamedDecl &ND) {
   Policy.AnonymousTagLocations = false;
   ND.printQualifiedName(OS, Policy);
   OS.flush();
-  assert(!StringRef(QName).startswith("::"));
+  assert(!StringRef(QName).starts_with("::"));
   return QName;
 }
 
@@ -696,7 +696,7 @@ std::string getQualification(ASTContext &Context,
  const NamedDecl *ND,
  llvm::ArrayRef VisibleNamespaces) {
   for (llvm::StringRef NS : VisibleNamespaces) {
-assert(NS.endswith("::"));
+assert(NS.ends_with("::"));
 (void)NS;
   }
   return getQualification(

diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index 13d788162817fb..6fb2641e8793db 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -437,7 +437,7 @@ void ClangdServer::codeComplete(PathRef File, Position Pos,
 ParseInputs ParseInput{IP->Command, &getHeaderFS(), IP->Contents.str()};
 // FIXME: Add traling new line if there is none at eof, workaround a crash,
 // see https://github.com/clangd/clangd/issues/332
-if (!IP->Contents.endswith("\n"))
+if (!IP->Contents.ends_with("\n"))
   ParseInput.Contents.append("\n");
 ParseInput.Index = Index;
 
@@ -488,7 +488,7 @@ void ClangdServer::signatureHelp(PathRef File, Position Pos,
 ParseInputs ParseInput{IP->Command, &getHeaderFS(), IP->Contents.str()};
 // FIXME: Add traling new line if there is none at eof, workaround a crash,
 // see https://github.com/clangd/clangd/issues/332
-if (!IP->Contents.endswith("\n"))
+if (!IP->Contents.ends_with("\n"))
   ParseInput.Contents.append("\n");
 ParseInput.Index = Index;
 CB(clangd::signatureHelp(File, Pos, *PreambleData, ParseInput,
@@ -661,7 +661,7 @@ void ClangdServer::codeAction(const CodeActionInputs 
&Params,
 return true;
  

[clang-tools-extra] 732bccb - Use StringRef::{starts, ends}_with (NFC)

2023-12-14 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-12-14T07:53:20-08:00
New Revision: 732bccb8c1b4ea724919db6ff02b1188e20850e7

URL: 
https://github.com/llvm/llvm-project/commit/732bccb8c1b4ea724919db6ff02b1188e20850e7
DIFF: 
https://github.com/llvm/llvm-project/commit/732bccb8c1b4ea724919db6ff02b1188e20850e7.diff

LOG: Use StringRef::{starts,ends}_with (NFC)

This patch replaces uses of StringRef::{starts,ends}with with
StringRef::{starts,ends}_with for consistency with
std::{string,string_view}::{starts,ends}_with in C++20.

I'm planning to deprecate and eventually remove
StringRef::{starts,ends}with.

Added: 


Modified: 
clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
clang-tools-extra/clang-include-fixer/IncludeFixerContext.cpp
clang-tools-extra/clang-include-fixer/SymbolIndexManager.cpp
clang-tools-extra/clang-include-fixer/find-all-symbols/PathConfig.cpp
clang-tools-extra/clang-include-fixer/plugin/IncludeFixerPlugin.cpp
clang-tools-extra/include-cleaner/lib/Analysis.cpp
clang-tools-extra/include-cleaner/lib/Record.cpp
clang-tools-extra/modularize/CoverageChecker.cpp
clang-tools-extra/modularize/ModularizeUtilities.cpp
clang-tools-extra/modularize/PreprocessorTracker.cpp
clang-tools-extra/pseudo/lib/cxx/CXX.cpp
clang-tools-extra/pseudo/lib/grammar/GrammarBNF.cpp
clang-tools-extra/unittests/clang-tidy/GoogleModuleTest.cpp
lld/ELF/Arch/ARM.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp 
b/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
index 7f7af7069c4188..879c0d26d472a8 100644
--- a/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
+++ b/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
@@ -827,10 +827,10 @@ void 
ChangeNamespaceTool::replaceQualifiedSymbolInDeclContext(
   // "IsVisibleInNewNs" matcher.
   if (AliasQualifiedName != AliasName) {
 // The alias is defined in some namespace.
-assert(StringRef(AliasQualifiedName).endswith("::" + AliasName));
+assert(StringRef(AliasQualifiedName).ends_with("::" + AliasName));
 llvm::StringRef AliasNs =
 StringRef(AliasQualifiedName).drop_back(AliasName.size() + 2);
-if (!llvm::StringRef(OldNs).startswith(AliasNs))
+if (!llvm::StringRef(OldNs).starts_with(AliasNs))
   continue;
   }
   std::string NameWithAliasNamespace =
@@ -862,7 +862,7 @@ void 
ChangeNamespaceTool::replaceQualifiedSymbolInDeclContext(
   // If the new nested name in the new namespace is the same as it was in the
   // old namespace, we don't create replacement unless there can be ambiguity.
   if ((NestedName == ReplaceName && !Conflict) ||
-  (NestedName.startswith("::") && NestedName.drop_front(2) == ReplaceName))
+  (NestedName.starts_with("::") && NestedName.drop_front(2) == 
ReplaceName))
 return;
   // If the reference need to be fully-qualified, add a leading "::" unless
   // NewNamespace is the global namespace.
@@ -891,7 +891,7 @@ void ChangeNamespaceTool::fixTypeLoc(
   // a typedef type, we need to use the typedef type instead.
   auto IsInMovedNs = [&](const NamedDecl *D) {
 if (!llvm::StringRef(D->getQualifiedNameAsString())
- .startswith(OldNamespace + "::"))
+ .starts_with(OldNamespace + "::"))
   return false;
 auto ExpansionLoc = 
Result.SourceManager->getExpansionLoc(D->getBeginLoc());
 if (ExpansionLoc.isInvalid())

diff  --git a/clang-tools-extra/clang-include-fixer/IncludeFixerContext.cpp 
b/clang-tools-extra/clang-include-fixer/IncludeFixerContext.cpp
index f6f8404204ba06..d7369b162dc10d 100644
--- a/clang-tools-extra/clang-include-fixer/IncludeFixerContext.cpp
+++ b/clang-tools-extra/clang-include-fixer/IncludeFixerContext.cpp
@@ -28,7 +28,7 @@ std::string createQualifiedNameForReplacement(
 const find_all_symbols::SymbolInfo &MatchedSymbol) {
   // No need to add missing qualifiers if SymbolIdentifier has a global scope
   // operator "::".
-  if (RawSymbolName.startswith("::"))
+  if (RawSymbolName.starts_with("::"))
 return std::string(RawSymbolName);
 
   std::string QualifiedName = MatchedSymbol.getQualifiedName();
@@ -42,7 +42,7 @@ std::string createQualifiedNameForReplacement(
   auto SymbolQualifiers = SplitQualifiers(RawSymbolName);
   std::string StrippedQualifiers;
   while (!SymbolQualifiers.empty() &&
- !llvm::StringRef(QualifiedName).endswith(SymbolQualifiers.back())) {
+ !llvm::StringRef(QualifiedName).ends_with(SymbolQualifiers.back())) {
 StrippedQualifiers =
 "::" + SymbolQualifiers.back().str() + StrippedQualifiers;
 SymbolQualifiers.pop_back();

diff  --git a/clang-tools-extra/clang-include-fixer/SymbolIndexManager.cpp 
b/clang-tools-extra/clang-include-fixer/SymbolIndexManager.cpp
index 952c5fdedc291e..027df3cfb2cc26 100644
--- a/clang-tools-extra/clang

[clang] 395f9ce - Use StringRef::{starts,ends}_with (NFC)

2023-12-16 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-12-16T10:14:44-08:00
New Revision: 395f9ce30e884cb6ce02f7a3bdd0dd1f72ea9033

URL: 
https://github.com/llvm/llvm-project/commit/395f9ce30e884cb6ce02f7a3bdd0dd1f72ea9033
DIFF: 
https://github.com/llvm/llvm-project/commit/395f9ce30e884cb6ce02f7a3bdd0dd1f72ea9033.diff

LOG: Use StringRef::{starts,ends}_with (NFC)

This patch replaces uses of StringRef::{starts,ends}with with
StringRef::{starts,ends}_with for consistency with
std::{string,string_view}::{starts,ends}_with in C++20.

I'm planning to deprecate and eventually remove
StringRef::{starts,ends}with.

Added: 


Modified: 
clang/lib/Lex/HeaderSearch.cpp
llvm/lib/IR/AutoUpgrade.cpp
llvm/lib/Target/DirectX/DXILResource.cpp
llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVBaseInfo.cpp
llvm/lib/Target/SPIRV/SPIRVBuiltins.cpp
llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp
llvm/lib/Target/SPIRV/SPIRVRegularizer.cpp
llvm/lib/Target/SPIRV/SPIRVUtils.cpp
llvm/lib/Target/Xtensa/AsmParser/XtensaAsmParser.cpp

Removed: 




diff  --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index a0ac0eaf2f9004..0f1090187734ff 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -1671,7 +1671,7 @@ static OptionalFileEntryRef 
getPrivateModuleMap(FileEntryRef File,
 if (Filename == "module.map")
   Diags.Report(diag::warn_deprecated_module_dot_map)
   << PrivateFilename << 1
-  << File.getDir().getName().endswith(".framework");
+  << File.getDir().getName().ends_with(".framework");
   }
   return PMMFile;
 }

diff  --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index 738ec301d14799..6b54047020a05d 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -5220,7 +5220,7 @@ std::string llvm::UpgradeDataLayoutString(StringRef DL, 
StringRef TT) {
   Res.append("-p7:160:256:256:32");
 if (!DL.contains("-p8") && !DL.starts_with("p8"))
   Res.append("-p8:128:128");
-if (!DL.contains("-p9") && !DL.startswith("p9"))
+if (!DL.contains("-p9") && !DL.starts_with("p9"))
   Res.append("-p9:192:256:256:32");
 
 return Res;

diff  --git a/llvm/lib/Target/DirectX/DXILResource.cpp 
b/llvm/lib/Target/DirectX/DXILResource.cpp
index 92306d907e0546..d3ff12a1f7b34d 100644
--- a/llvm/lib/Target/DirectX/DXILResource.cpp
+++ b/llvm/lib/Target/DirectX/DXILResource.cpp
@@ -261,7 +261,7 @@ void UAVResource::parseSourceType(StringRef S) {
   S = S.substr(S.find("<") + 1);
 
   constexpr size_t PrefixLen = StringRef("vector<").size();
-  if (S.startswith("vector<"))
+  if (S.starts_with("vector<"))
 S = S.substr(PrefixLen, S.find(",") - PrefixLen);
   else
 S = S.substr(0, S.find(">"));

diff  --git a/llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVBaseInfo.cpp 
b/llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVBaseInfo.cpp
index 1af7b7a5d7845f..b69031adb16730 100644
--- a/llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVBaseInfo.cpp
+++ b/llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVBaseInfo.cpp
@@ -177,7 +177,7 @@ std::string getLinkStringForBuiltIn(SPIRV::BuiltIn::BuiltIn 
BuiltInValue) {
 bool getSpirvBuiltInIdByName(llvm::StringRef Name,
  SPIRV::BuiltIn::BuiltIn &BI) {
   const std::string Prefix = "__spirv_BuiltIn";
-  if (!Name.startswith(Prefix))
+  if (!Name.starts_with(Prefix))
 return false;
 
   const SPIRV::SymbolicOperand *Lookup =

diff  --git a/llvm/lib/Target/SPIRV/SPIRVBuiltins.cpp 
b/llvm/lib/Target/SPIRV/SPIRVBuiltins.cpp
index ae9e801f8f50b8..5ac45079bd0026 100644
--- a/llvm/lib/Target/SPIRV/SPIRVBuiltins.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVBuiltins.cpp
@@ -872,8 +872,8 @@ static bool generateGroupInst(const SPIRV::IncomingCall 
*Call,
 std::tie(GroupResultRegister, GroupResultType) =
 buildBoolRegister(MIRBuilder, Call->ReturnType, GR);
 
-  auto Scope = Builtin->Name.startswith("sub_group") ? SPIRV::Scope::Subgroup
- : SPIRV::Scope::Workgroup;
+  auto Scope = Builtin->Name.starts_with("sub_group") ? SPIRV::Scope::Subgroup
+  : 
SPIRV::Scope::Workgroup;
   Register ScopeRegister = buildConstantIntReg(Scope, MIRBuilder, GR);
 
   // Build work/sub group instruction.
@@ -1999,13 +1999,13 @@ struct OpenCLType {
 
//===--===//
 
 static Type *parseTypeString(const StringRef Name, LLVMContext &Context) {
-  if (Name.startswith("void"))
+  if (Name.starts_with("void"))
 return Type::getVoidTy(Context);
-  else if (Name.startswith("int") || Name.startswith("uint"))
+  else if (Name.starts_with("int") || Name.starts_with("uint"))
 return Type::getInt32Ty(Context);
-  else if (Name.startswith("float"))
+  else if (Name.starts_with("float"))
 return Type::getFloatTy(Context);
-  else if (Name.starts

[clang-tools-extra] b8f89b8 - Use StringRef::{starts, ends}_with (NFC)

2023-12-16 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-12-16T15:02:17-08:00
New Revision: b8f89b84bc26c46a5a10d01eb5414fbde3c8700a

URL: 
https://github.com/llvm/llvm-project/commit/b8f89b84bc26c46a5a10d01eb5414fbde3c8700a
DIFF: 
https://github.com/llvm/llvm-project/commit/b8f89b84bc26c46a5a10d01eb5414fbde3c8700a.diff

LOG: Use StringRef::{starts,ends}_with (NFC)

This patch replaces uses of StringRef::{starts,ends}with with
StringRef::{starts,ends}_with for consistency with
std::{string,string_view}::{starts,ends}_with in C++20.

I'm planning to deprecate and eventually remove
StringRef::{starts,ends}with.

Added: 


Modified: 
clang-tools-extra/clangd/index/remote/server/Server.cpp
clang/test/Index/recursive-cxx-member-calls.cpp
libc/utils/HdrGen/Generator.cpp
mlir/examples/toy/Ch2/toyc.cpp
mlir/examples/toy/Ch3/toyc.cpp
mlir/examples/toy/Ch4/toyc.cpp
mlir/examples/toy/Ch5/toyc.cpp
mlir/examples/toy/Ch6/toyc.cpp
mlir/examples/toy/Ch7/toyc.cpp
openmp/libomptarget/plugins-nextgen/common/include/PluginInterface.h
openmp/libomptarget/plugins-nextgen/cuda/src/rtl.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/remote/server/Server.cpp 
b/clang-tools-extra/clangd/index/remote/server/Server.cpp
index e108d4d0b057ba..4ef3ab6f9af9c2 100644
--- a/clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ b/clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -451,7 +451,7 @@ std::unique_ptr makeLogger(llvm::StringRef 
LogPrefix,
   void log(Level L, const char *Fmt,
const llvm::formatv_object_base &Message) override {
 if (Context::current().get(CurrentRequest) == nullptr ||
-llvm::StringRef(Fmt).startswith("[public]"))
+llvm::StringRef(Fmt).starts_with("[public]"))
   return StreamLogger::log(L, Fmt, Message);
 if (L >= Error)
   return StreamLogger::log(L, Fmt,

diff  --git a/clang/test/Index/recursive-cxx-member-calls.cpp 
b/clang/test/Index/recursive-cxx-member-calls.cpp
index be908c506e7476..48fc8f14544c48 100644
--- a/clang/test/Index/recursive-cxx-member-calls.cpp
+++ b/clang/test/Index/recursive-cxx-member-calls.cpp
@@ -99,7 +99,7 @@ using namespace clang;
 
 AttributeList::Kind AttributeList::getKind(const IdentifierInfo * Name) {
   llvm::StringRef AttrName = Name->getName();
-  if (AttrName.startswith("__") && AttrName.endswith("__"))
+  if (AttrName.starts_with("__") && AttrName.ends_with("__"))
 AttrName = AttrName.substr(2, AttrName.size() - 4);
 
   return llvm::StringSwitch < AttributeList::Kind > (AttrName)

diff  --git a/libc/utils/HdrGen/Generator.cpp b/libc/utils/HdrGen/Generator.cpp
index 24d22680fe525b..3bcf005adda74f 100644
--- a/libc/utils/HdrGen/Generator.cpp
+++ b/libc/utils/HdrGen/Generator.cpp
@@ -57,7 +57,7 @@ void Generator::parseCommandArgs(llvm::StringRef ArgStr, 
ArgVector &Args) {
   ArgStr.split(Args, ",");
   for (llvm::StringRef &A : Args) {
 A = A.trim(' ');
-if (A.startswith(ParamNamePrefix) && A.endswith(ParamNameSuffix)) {
+if (A.starts_with(ParamNamePrefix) && A.ends_with(ParamNameSuffix)) {
   A = A.drop_front(ParamNamePrefixSize).drop_back(ParamNameSuffixSize);
   A = ArgMap[std::string(A)];
 }
@@ -80,7 +80,7 @@ void Generator::generate(llvm::raw_ostream &OS, 
llvm::RecordKeeper &Records) {
 Content = P.second;
 
 llvm::StringRef Line = P.first.trim(' ');
-if (Line.startswith(CommandPrefix)) {
+if (Line.starts_with(CommandPrefix)) {
   Line = Line.drop_front(CommandPrefixSize);
 
   P = Line.split("(");
@@ -107,7 +107,7 @@ void Generator::generate(llvm::raw_ostream &OS, 
llvm::RecordKeeper &Records) {
   Command::ErrorReporter Reporter(
   llvm::SMLoc::getFromPointer(CommandName.data()), SrcMgr);
   Cmd->run(OS, Args, StdHeader, Records, Reporter);
-} else if (!Line.startswith(CommentPrefix)) {
+} else if (!Line.starts_with(CommentPrefix)) {
   // There is no comment or command on this line so we just write it as is.
   OS << P.first << "\n";
 }

diff  --git a/mlir/examples/toy/Ch2/toyc.cpp b/mlir/examples/toy/Ch2/toyc.cpp
index fa431972e211ef..e33b49b41c5a1d 100644
--- a/mlir/examples/toy/Ch2/toyc.cpp
+++ b/mlir/examples/toy/Ch2/toyc.cpp
@@ -78,7 +78,7 @@ int dumpMLIR() {
 
   // Handle '.toy' input to the compiler.
   if (inputType != InputType::MLIR &&
-  !llvm::StringRef(inputFilename).endswith(".mlir")) {
+  !llvm::StringRef(inputFilename).ends_with(".mlir")) {
 auto moduleAST = parseInputFile(inputFilename);
 if (!moduleAST)
   return 6;

diff  --git a/mlir/examples/toy/Ch3/toyc.cpp b/mlir/examples/toy/Ch3/toyc.cpp
index 8c27a7af97a002..c2c5f1fe1ba17b 100644
--- a/mlir/examples/toy/Ch3/toyc.cpp
+++ b/mlir/examples/toy/Ch3/toyc.cpp
@@ -82,7 +82,7 @@ int loadMLIR(llvm::SourceMgr &sourceMgr, mlir::MLIRContext 
&context,
  mlir::OwningOpRef &modul

[clang] 2aaeef1 - [Index] Fix recursive-cxx-member-calls.cpp

2023-12-16 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-12-16T16:24:32-08:00
New Revision: 2aaeef1fad0c1b233f6d3ca67a6c05877dc9e998

URL: 
https://github.com/llvm/llvm-project/commit/2aaeef1fad0c1b233f6d3ca67a6c05877dc9e998
DIFF: 
https://github.com/llvm/llvm-project/commit/2aaeef1fad0c1b233f6d3ca67a6c05877dc9e998.diff

LOG: [Index] Fix recursive-cxx-member-calls.cpp

b8f89b84bc26c46a5a10d01eb5414fbde3c8700a inadvertently replaced
startswith/endswith with starts_with/ends_with even though the test
uses a custom StringRef.  This patch reverts the change.

Added: 


Modified: 
clang/test/Index/recursive-cxx-member-calls.cpp

Removed: 




diff  --git a/clang/test/Index/recursive-cxx-member-calls.cpp 
b/clang/test/Index/recursive-cxx-member-calls.cpp
index 48fc8f14544c48..be908c506e7476 100644
--- a/clang/test/Index/recursive-cxx-member-calls.cpp
+++ b/clang/test/Index/recursive-cxx-member-calls.cpp
@@ -99,7 +99,7 @@ using namespace clang;
 
 AttributeList::Kind AttributeList::getKind(const IdentifierInfo * Name) {
   llvm::StringRef AttrName = Name->getName();
-  if (AttrName.starts_with("__") && AttrName.ends_with("__"))
+  if (AttrName.startswith("__") && AttrName.endswith("__"))
 AttrName = AttrName.substr(2, AttrName.size() - 4);
 
   return llvm::StringSwitch < AttributeList::Kind > (AttrName)



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8c296d5 - [Interpreter] Fix warnings

2023-12-19 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-12-19T12:57:10-08:00
New Revision: 8c296d58c50902e367f64417948d6e2d43828f36

URL: 
https://github.com/llvm/llvm-project/commit/8c296d58c50902e367f64417948d6e2d43828f36
DIFF: 
https://github.com/llvm/llvm-project/commit/8c296d58c50902e367f64417948d6e2d43828f36.diff

LOG: [Interpreter] Fix warnings

This patch fixes:

  clang/lib/Interpreter/CodeCompletion.cpp:126:35: error: 'startswith'
  is deprecated: Use starts_with instead
  [-Werror,-Wdeprecated-declarations]

  clang/lib/Interpreter/CodeCompletion.cpp:189:42: error: 'startswith'
  is deprecated: Use starts_with instead
  [-Werror,-Wdeprecated-declarations]

Added: 


Modified: 
clang/lib/Interpreter/CodeCompletion.cpp

Removed: 




diff  --git a/clang/lib/Interpreter/CodeCompletion.cpp 
b/clang/lib/Interpreter/CodeCompletion.cpp
index a9789355b2c5f3..25183ae9eeb99e 100644
--- a/clang/lib/Interpreter/CodeCompletion.cpp
+++ b/clang/lib/Interpreter/CodeCompletion.cpp
@@ -123,7 +123,7 @@ class CompletionContextHandler {
 // situation.
 if (!CCC.getBaseType().isNull() || !CCC.getPreferredType().isNull())
   return;
-if (StringRef(Result.Keyword).startswith(Prefix))
+if (StringRef(Result.Keyword).starts_with(Prefix))
   Results.push_back(Result.Keyword);
   }
 
@@ -186,7 +186,7 @@ void ReplCompletionConsumer::ProcessCodeCompleteResults(
 break;
   }
   if (!Result.Declaration->getDeclName().isIdentifier() ||
-  !Result.Declaration->getName().startswith(Prefix)) {
+  !Result.Declaration->getName().starts_with(Prefix)) {
 break;
   }
   CCH->handleDeclaration(Result);



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8866558 - [clang] Fix typos in documentation

2023-12-21 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-12-21T08:18:49-08:00
New Revision: 886655869cef2e0f11da8981da30d70ad7892ff9

URL: 
https://github.com/llvm/llvm-project/commit/886655869cef2e0f11da8981da30d70ad7892ff9
DIFF: 
https://github.com/llvm/llvm-project/commit/886655869cef2e0f11da8981da30d70ad7892ff9.diff

LOG: [clang] Fix typos in documentation

Added: 


Modified: 
clang/docs/ControlFlowIntegrityDesign.rst
clang/docs/LanguageExtensions.rst
clang/docs/ReleaseNotes.rst
clang/docs/SanitizerCoverage.rst

Removed: 




diff  --git a/clang/docs/ControlFlowIntegrityDesign.rst 
b/clang/docs/ControlFlowIntegrityDesign.rst
index f3a3c8294f7c70..d66bd16155a9f1 100644
--- a/clang/docs/ControlFlowIntegrityDesign.rst
+++ b/clang/docs/ControlFlowIntegrityDesign.rst
@@ -349,7 +349,7 @@ address point. Note that libraries like libcxxabi do assume 
this property.
 
 (2) virtual function entry layout property
 
-For each virtual function the distance between an virtual table entry for this 
function and the corresponding
+For each virtual function the distance between a virtual table entry for this 
function and the corresponding
 address point is always the same. This property ensures that dynamic dispatch 
still works with the interleaving layout.
 
 Note that the interleaving scheme in the CFI implementation guarantees both 
properties above whereas the original scheme proposed

diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 13fb7c345aa4eb..23a7f4f5d5b926 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -2019,7 +2019,7 @@ would be +1.  ``ns_returns_autoreleased`` specifies that 
the returned object is
 autorelease pool.
 
 **Usage**: The ``ns_consumed`` and ``cf_consumed`` attributes can be placed on
-an parameter declaration; they specify that the argument is expected to have a
+a parameter declaration; they specify that the argument is expected to have a
 +1 retain count, which will be balanced in some way by the function or method.
 The ``ns_consumes_self`` attribute can only be placed on an Objective-C
 method; it specifies that the method expects its ``self`` parameter to have a
@@ -3601,7 +3601,7 @@ scalar calls of ``__builtin_isfpclass`` applied to the 
input elementwise.
 The result of ``__builtin_isfpclass`` is a boolean value, if the first argument
 is a scalar, or an integer vector with the same element count as the first
 argument. The element type in this vector has the same bit length as the
-element of the the first argument type.
+element of the first argument type.
 
 This function never raises floating-point exceptions and does not canonicalize
 its input. The floating-point argument is not promoted, its data class is
@@ -4959,7 +4959,7 @@ Clang supports the following match rules:
 - ``record(unless(is_union))``: Can be used to apply attributes only to
   ``struct`` and ``class`` declarations.
 
-- ``enum``: Can be be used to apply attributes to enumeration declarations.
+- ``enum``: Can be used to apply attributes to enumeration declarations.
 
 - ``enum_constant``: Can be used to apply attributes to enumerators.
 

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 39b9176865fc04..ee211c16a48ac8 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -253,7 +253,7 @@ New Compiler Flags
   the preprocessed text to the output. This can greatly reduce the size of the
   preprocessed output, which can be helpful when trying to reduce a test case.
 * ``-fassume-nothrow-exception-dtor`` is added to assume that the destructor of
-  an thrown exception object will not throw. The generated code for catch
+  a thrown exception object will not throw. The generated code for catch
   handlers will be smaller. A throw expression of a type with a
   potentially-throwing destructor will lead to an error.
 

diff  --git a/clang/docs/SanitizerCoverage.rst 
b/clang/docs/SanitizerCoverage.rst
index c7ced397c72239..45ad03cb43774c 100644
--- a/clang/docs/SanitizerCoverage.rst
+++ b/clang/docs/SanitizerCoverage.rst
@@ -496,7 +496,7 @@ offsets in the corresponding binary/DSO that were executed 
during the run.
 Sancov Tool
 ---
 
-An simple ``sancov`` tool is provided to process coverage files.
+A simple ``sancov`` tool is provided to process coverage files.
 The tool is part of LLVM project and is currently supported only on Linux.
 It can handle symbolization tasks autonomously without any extra support
 from the environment. You need to pass .sancov files (named



___
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)

2023-12-22 Thread Kazu Hirata via cfe-commits

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


[clang-tools-extra] 0f1721c - [clang-tidy] Use StringRef::contains (NFC)

2023-12-23 Thread Kazu Hirata via cfe-commits

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 &Result) {
   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] fe21b39 - [Basic] Use range-based for loops (NFC)

2023-12-24 Thread Kazu Hirata via cfe-commits

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 &EmitInteger(raw_ostream &o, int64_t 
value) {
 
 inline raw_ostream &EmitString(raw_ostream &o, 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 &Diags,
   }
 }
 
-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] 68f832f - [clang] Use StringRef::consume_front (NFC)

2023-12-25 Thread Kazu Hirata via cfe-commits

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 &L, 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
+++ b/clang/lib/StaticAnalyzer/Checkers/CheckSecurit

[clang] 2df0fa4 - [clang] Use StringRef::consume_front (NFC)

2023-12-27 Thread Kazu Hirata via cfe-commits

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 &Diags,
 
   // 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 &D, const 
llvm::Triple &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] a70dcc2 - [clang] Use StringRef::ltrim (NFC)

2023-12-27 Thread Kazu Hirata via cfe-commits

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 &SuggestedModifier) 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 &FeatureMap,
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] 5c37e71 - [Frontend] Use StringRef::drop_while (NFC)

2023-12-28 Thread Kazu Hirata via cfe-commits

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] c54a8ac - [Sema] Use StringRef::ltrim (NFC)

2024-01-08 Thread Kazu Hirata via cfe-commits

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] 2b3baff - [Analysis] Use StringRef::rtrim (NFC)

2024-01-08 Thread Kazu Hirata via cfe-commits

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-tools-extra] 12bba0d - [clang-query] Use StringRef::ltrim (NFC)

2024-01-10 Thread Kazu Hirata via cfe-commits

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] cf3421d - [Format] Fix a warning

2024-01-11 Thread Kazu Hirata via cfe-commits

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 = [&Lexer, &Style](llvm::StringRef Code) {
+  auto Annotate = [&Lexer](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] ca05cc2 - [clang] Don't use Optional::hasValue (NFC)

2022-06-26 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-06-26T18:51:54-07:00
New Revision: ca05cc206478245292cb769f826dbe12f59605be

URL: 
https://github.com/llvm/llvm-project/commit/ca05cc206478245292cb769f826dbe12f59605be
DIFF: 
https://github.com/llvm/llvm-project/commit/ca05cc206478245292cb769f826dbe12f59605be.diff

LOG: [clang] Don't use Optional::hasValue (NFC)

This patch replaces x.hasValue() with x where x is contextually
convertible to bool.

Added: 


Modified: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
clang/include/clang/Support/RISCVVIntrinsicUtils.h
clang/lib/Driver/Driver.cpp
clang/lib/Lex/MacroInfo.cpp
clang/lib/Parse/ParseOpenMP.cpp
clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp

Removed: 




diff  --git 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
index 11c60b6895627..4b6cbd516628a 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
@@ -53,14 +53,10 @@ class ConditionTruthVal {
   }
 
   /// Return true if the constraint is perfectly constrained to 'true'.
-  bool isConstrainedTrue() const {
-return Val.hasValue() && Val.getValue();
-  }
+  bool isConstrainedTrue() const { return Val && Val.getValue(); }
 
   /// Return true if the constraint is perfectly constrained to 'false'.
-  bool isConstrainedFalse() const {
-return Val.hasValue() && !Val.getValue();
-  }
+  bool isConstrainedFalse() const { return Val && !Val.getValue(); }
 
   /// Return true if the constrained is perfectly constrained.
   bool isConstrained() const {

diff  --git a/clang/include/clang/Support/RISCVVIntrinsicUtils.h 
b/clang/include/clang/Support/RISCVVIntrinsicUtils.h
index 0e9fe97ab735e..3b6f205f9f220 100644
--- a/clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ b/clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -209,8 +209,8 @@ class RVVType {
   }
 
   bool isValid() const { return Valid; }
-  bool isScalar() const { return Scale.hasValue() && Scale.getValue() == 0; }
-  bool isVector() const { return Scale.hasValue() && Scale.getValue() != 0; }
+  bool isScalar() const { return Scale && Scale.getValue() == 0; }
+  bool isVector() const { return Scale && Scale.getValue() != 0; }
   bool isVector(unsigned Width) const {
 return isVector() && ElementBitwidth == Width;
   }

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index d83142286e7d6..c34da3a67a2e0 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -3325,8 +3325,8 @@ class OffloadingActionBuilder final {
 A = C.getDriver().ConstructPhaseAction(C, Args, CurPhase, A,
AssociatedOffloadKind);
 
-  if (CompileDeviceOnly && CurPhase == FinalPhase &&
-  BundleOutput.hasValue() && BundleOutput.getValue()) {
+  if (CompileDeviceOnly && CurPhase == FinalPhase && BundleOutput &&
+  BundleOutput.getValue()) {
 for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I) {
   OffloadAction::DeviceDependences DDep;
   DDep.add(*CudaDeviceActions[I], *ToolChains.front(), GpuArchList[I],

diff  --git a/clang/lib/Lex/MacroInfo.cpp b/clang/lib/Lex/MacroInfo.cpp
index 19ab9bcb972dd..310b95f36771d 100644
--- a/clang/lib/Lex/MacroInfo.cpp
+++ b/clang/lib/Lex/MacroInfo.cpp
@@ -213,8 +213,7 @@ MacroDirective::DefInfo MacroDirective::getDefinition() {
   isPublic = VisMD->isPublic();
   }
 
-  return DefInfo(nullptr, UndefLoc,
- !isPublic.hasValue() || isPublic.getValue());
+  return DefInfo(nullptr, UndefLoc, !isPublic || isPublic.getValue());
 }
 
 const MacroDirective::DefInfo

diff  --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index dbb0ca66f4976..43a69a8e94e14 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -2313,9 +2313,9 @@ Parser::DeclGroupPtrTy 
Parser::ParseOpenMPDeclarativeDirectiveWithExtDecl(
 Sema::DeclareTargetContextInfo DTCI(DKind, DTLoc);
 if (HasClauses)
   ParseOMPDeclareTargetClauses(DTCI);
-bool HasImplicitMappings =
-DKind == OMPD_begin_declare_target || !HasClauses ||
-(DTCI.ExplicitlyMapped.empty() && DTCI.Indirect.hasValue());
+bool HasImplicitMappings = DKind == OMPD_begin_declare_target ||
+   !HasClauses ||
+   (DTCI.ExplicitlyMapped.empty() && 
DTCI.Indirect);
 
 // Skip the last annot_pragma_openmp_end.
 ConsumeAnyToken();

diff  --git a/clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp 
b/clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp
index 4c5efa7504048..7c50453abe509 100644
--- a/clang/unittests/Analysis/FlowSensitive/Te

[clang] a948117 - [clang] Use has_value instead of value (NFC)

2022-07-29 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-07-29T21:18:39-07:00
New Revision: a9481170888447176f3552c62ff7dca693c25b97

URL: 
https://github.com/llvm/llvm-project/commit/a9481170888447176f3552c62ff7dca693c25b97
DIFF: 
https://github.com/llvm/llvm-project/commit/a9481170888447176f3552c62ff7dca693c25b97.diff

LOG: [clang] Use has_value instead of value (NFC)

Added: 


Modified: 
clang/lib/Driver/OffloadBundler.cpp
clang/lib/Sema/Scope.cpp
clang/lib/Sema/SemaRISCVVectorLookup.cpp

Removed: 




diff  --git a/clang/lib/Driver/OffloadBundler.cpp 
b/clang/lib/Driver/OffloadBundler.cpp
index 5aa4cb8c2cac2..d590c2360fae8 100644
--- a/clang/lib/Driver/OffloadBundler.cpp
+++ b/clang/lib/Driver/OffloadBundler.cpp
@@ -1249,7 +1249,7 @@ Error OffloadBundler::UnbundleArchive() {
   if (!NextTripleOrErr)
 return NextTripleOrErr.takeError();
 
-  CodeObject = ((*NextTripleOrErr).hasValue()) ? **NextTripleOrErr : "";
+  CodeObject = ((*NextTripleOrErr).has_value()) ? **NextTripleOrErr : "";
 } // End of processing of all bundle entries of this child of input 
archive.
   }   // End of while over children of input archive.
 

diff  --git a/clang/lib/Sema/Scope.cpp b/clang/lib/Sema/Scope.cpp
index 98260226dfd36..69120cf644342 100644
--- a/clang/lib/Sema/Scope.cpp
+++ b/clang/lib/Sema/Scope.cpp
@@ -156,7 +156,7 @@ void Scope::updateNRVOCandidate(VarDecl *VD) {
 
 void Scope::applyNRVO() {
   // There is no NRVO candidate in the current scope.
-  if (!NRVO.hasValue())
+  if (!NRVO.has_value())
 return;
 
   if (*NRVO && isDeclScope(*NRVO))

diff  --git a/clang/lib/Sema/SemaRISCVVectorLookup.cpp 
b/clang/lib/Sema/SemaRISCVVectorLookup.cpp
index 50fd841c231bf..2d58008fcdacd 100644
--- a/clang/lib/Sema/SemaRISCVVectorLookup.cpp
+++ b/clang/lib/Sema/SemaRISCVVectorLookup.cpp
@@ -233,7 +233,7 @@ void RISCVIntrinsicManagerImpl::InitIntrinsicList() {
 RVVType::computeTypes(BaseType, Log2LMUL, Record.NF, ProtoSeq);
 
 // Ignored to create new intrinsic if there are any illegal types.
-if (!Types.hasValue())
+if (!Types.has_value())
   continue;
 
 std::string SuffixStr =



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] e5a1ccb - Use value instead of getValue (NFC)

2022-07-29 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-07-29T21:18:41-07:00
New Revision: e5a1ccbf254e2e44830fde3d83357c06b814f881

URL: 
https://github.com/llvm/llvm-project/commit/e5a1ccbf254e2e44830fde3d83357c06b814f881
DIFF: 
https://github.com/llvm/llvm-project/commit/e5a1ccbf254e2e44830fde3d83357c06b814f881.diff

LOG: Use value instead of getValue (NFC)

Added: 


Modified: 
clang/lib/Sema/Scope.cpp
clang/lib/Sema/SemaRISCVVectorLookup.cpp
mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp
mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp

Removed: 




diff  --git a/clang/lib/Sema/Scope.cpp b/clang/lib/Sema/Scope.cpp
index 69120cf644342..d27de34f3977f 100644
--- a/clang/lib/Sema/Scope.cpp
+++ b/clang/lib/Sema/Scope.cpp
@@ -160,7 +160,7 @@ void Scope::applyNRVO() {
 return;
 
   if (*NRVO && isDeclScope(*NRVO))
-NRVO.getValue()->setNRVOVariable(true);
+NRVO.value()->setNRVOVariable(true);
 
   // It's necessary to propagate NRVO candidate to the parent scope for cases
   // when the parent scope doesn't contain a return statement.

diff  --git a/clang/lib/Sema/SemaRISCVVectorLookup.cpp 
b/clang/lib/Sema/SemaRISCVVectorLookup.cpp
index 2d58008fcdacd..63194b7b2e366 100644
--- a/clang/lib/Sema/SemaRISCVVectorLookup.cpp
+++ b/clang/lib/Sema/SemaRISCVVectorLookup.cpp
@@ -115,7 +115,7 @@ static QualType RVVType2Qual(ASTContext &Context, const 
RVVType *Type) {
 llvm_unreachable("Unhandled type.");
   }
   if (Type->isVector())
-QT = Context.getScalableVectorType(QT, Type->getScale().getValue());
+QT = Context.getScalableVectorType(QT, Type->getScale().value());
 
   if (Type->isConstant())
 QT = Context.getConstType(QT);

diff  --git a/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp 
b/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp
index 56ce6b85ba879..4c5fbf98cdf00 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp
@@ -235,7 +235,7 @@ FailureOr 
mlir::linalg::promoteSubviewAsNewBuffer(
   getConstantUpperBoundForIndex(materializedSize);
   size = failed(upperBound)
  ? materializedSize
- : b.create(loc, 
upperBound.getValue());
+ : b.create(loc, upperBound.value());
 }
 LLVM_DEBUG(llvm::dbgs() << "Extracted tightest: " << size << "\n");
 fullSizes.push_back(size);

diff  --git 
a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp 
b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
index 5dcbd00201a99..34c532311fa4c 100644
--- a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
@@ -973,7 +973,7 @@ convertOmpSimdLoop(Operation &opInst, llvm::IRBuilderBase 
&builder,
 
   llvm::ConstantInt *simdlen = nullptr;
   if (llvm::Optional simdlenVar = loop.simdlen())
-simdlen = builder.getInt64(simdlenVar.getValue());
+simdlen = builder.getInt64(simdlenVar.value());
 
   ompBuilder->applySimd(loopInfo, simdlen);
 



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 873888c - Use is_sorted (NFC)

2022-07-29 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-07-29T21:18:42-07:00
New Revision: 873888c179744eb0a35d4b6d69424c6adf3d08d4

URL: 
https://github.com/llvm/llvm-project/commit/873888c179744eb0a35d4b6d69424c6adf3d08d4
DIFF: 
https://github.com/llvm/llvm-project/commit/873888c179744eb0a35d4b6d69424c6adf3d08d4.diff

LOG: Use is_sorted (NFC)

Added: 


Modified: 
clang-tools-extra/clangd/SemanticHighlighting.cpp
clang-tools-extra/clangd/refactor/Rename.cpp
clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
clang/lib/Format/BreakableToken.cpp
lld/COFF/DebugTypes.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp 
b/clang-tools-extra/clangd/SemanticHighlighting.cpp
index 63d01deb33704..7599c1eff0181 100644
--- a/clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -943,7 +943,7 @@ bool operator<(const HighlightingToken &L, const 
HighlightingToken &R) {
 std::vector
 toSemanticTokens(llvm::ArrayRef Tokens,
  llvm::StringRef Code) {
-  assert(std::is_sorted(Tokens.begin(), Tokens.end()));
+  assert(llvm::is_sorted(Tokens));
   std::vector Result;
   // In case we split a HighlightingToken into multiple tokens (e.g. because it
   // was spanning multiple lines), this tracks the last one. This prevents

diff  --git a/clang-tools-extra/clangd/refactor/Rename.cpp 
b/clang-tools-extra/clangd/refactor/Rename.cpp
index 83df990d35cd9..50b5481e4f89b 100644
--- a/clang-tools-extra/clangd/refactor/Rename.cpp
+++ b/clang-tools-extra/clangd/refactor/Rename.cpp
@@ -809,7 +809,7 @@ llvm::Expected buildRenameEdit(llvm::StringRef 
AbsFilePath,
   SPAN_ATTACH(Tracer, "rename_occurrences",
   static_cast(Occurrences.size()));
 
-  assert(std::is_sorted(Occurrences.begin(), Occurrences.end()));
+  assert(llvm::is_sorted(Occurrences));
   assert(std::unique(Occurrences.begin(), Occurrences.end()) ==
  Occurrences.end() &&
  "Occurrences must be unique");
@@ -872,7 +872,7 @@ adjustRenameRanges(llvm::StringRef DraftCode, 
llvm::StringRef Identifier,
std::vector Indexed, const LangOptions &LangOpts) {
   trace::Span Tracer("AdjustRenameRanges");
   assert(!Indexed.empty());
-  assert(std::is_sorted(Indexed.begin(), Indexed.end()));
+  assert(llvm::is_sorted(Indexed));
   std::vector Lexed =
   collectIdentifierRanges(Identifier, DraftCode, LangOpts);
   llvm::sort(Lexed);
@@ -883,8 +883,8 @@ llvm::Optional> 
getMappedRanges(ArrayRef Indexed,
ArrayRef Lexed) {
   trace::Span Tracer("GetMappedRanges");
   assert(!Indexed.empty());
-  assert(std::is_sorted(Indexed.begin(), Indexed.end()));
-  assert(std::is_sorted(Lexed.begin(), Lexed.end()));
+  assert(llvm::is_sorted(Indexed));
+  assert(llvm::is_sorted(Lexed));
 
   if (Indexed.size() > Lexed.size()) {
 vlog("The number of lexed occurrences is less than indexed occurrences");
@@ -950,8 +950,8 @@ llvm::Optional> 
getMappedRanges(ArrayRef Indexed,
 size_t renameRangeAdjustmentCost(ArrayRef Indexed, ArrayRef 
Lexed,
  ArrayRef MappedIndex) {
   assert(Indexed.size() == MappedIndex.size());
-  assert(std::is_sorted(Indexed.begin(), Indexed.end()));
-  assert(std::is_sorted(Lexed.begin(), Lexed.end()));
+  assert(llvm::is_sorted(Indexed));
+  assert(llvm::is_sorted(Lexed));
 
   int LastLine = -1;
   int LastDLine = 0, LastDColumn = 0;

diff  --git a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp 
b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
index 384840c93f660..128cd620d710e 100644
--- a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -34,9 +34,8 @@ using testing::SizeIs;
 ///   };
 std::string annotate(llvm::StringRef Input,
  llvm::ArrayRef Tokens) {
-  assert(std::is_sorted(
-  Tokens.begin(), Tokens.end(),
-  [](const HighlightingToken &L, const HighlightingToken &R) {
+  assert(llvm::is_sorted(
+  Tokens, [](const HighlightingToken &L, const HighlightingToken &R) {
 return L.R.start < R.R.start;
   }));
 

diff  --git a/clang/lib/Format/BreakableToken.cpp 
b/clang/lib/Format/BreakableToken.cpp
index db82018a4c83c..b3ef2a895d7f0 100644
--- a/clang/lib/Format/BreakableToken.cpp
+++ b/clang/lib/Format/BreakableToken.cpp
@@ -49,10 +49,10 @@ static StringRef getLineCommentIndentPrefix(StringRef 
Comment,
   if (Style.Language == FormatStyle::LK_TextProto)
 KnownPrefixes = KnownTextProtoPrefixes;
 
-  assert(std::is_sorted(KnownPrefixes.begin(), KnownPrefixes.end(),
-[](StringRef Lhs, StringRef Rhs) noexcept {
-  return Lhs.size() > Rhs.size();
-}));
+  assert(
+  llvm::is_sorted(KnownPrefixes, 

[clang] ed29930 - [Sema] Remove an unused forward declaration (NFC)

2022-07-31 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-07-31T15:17:00-07:00
New Revision: ed2993051994546771a1d8e8256baa960609ee11

URL: 
https://github.com/llvm/llvm-project/commit/ed2993051994546771a1d8e8256baa960609ee11
DIFF: 
https://github.com/llvm/llvm-project/commit/ed2993051994546771a1d8e8256baa960609ee11.diff

LOG: [Sema] Remove an unused forward declaration (NFC)

Added: 


Modified: 
clang/include/clang/Sema/RISCVIntrinsicManager.h

Removed: 




diff  --git a/clang/include/clang/Sema/RISCVIntrinsicManager.h 
b/clang/include/clang/Sema/RISCVIntrinsicManager.h
index 505100249d6f1..128858bb43019 100644
--- a/clang/include/clang/Sema/RISCVIntrinsicManager.h
+++ b/clang/include/clang/Sema/RISCVIntrinsicManager.h
@@ -15,7 +15,6 @@
 #define LLVM_CLANG_SEMA_RISCVINTRINSICMANAGER_H
 
 namespace clang {
-class Sema;
 class LookupResult;
 class IdentifierInfo;
 class Preprocessor;



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 7542e72 - Use llvm::is_contained (NFC)

2022-08-07 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-08-07T00:16:17-07:00
New Revision: 7542e72188cb05b22523cc58ea4223951399520d

URL: 
https://github.com/llvm/llvm-project/commit/7542e72188cb05b22523cc58ea4223951399520d
DIFF: 
https://github.com/llvm/llvm-project/commit/7542e72188cb05b22523cc58ea4223951399520d.diff

LOG: Use llvm::is_contained (NFC)

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
clang-tools-extra/clang-tidy/cert/ProperlySeededRandomGeneratorCheck.cpp
clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp
clang-tools-extra/clang-tidy/readability/DuplicateIncludeCheck.cpp
clang/lib/AST/ASTContext.cpp
clang/lib/Sema/SemaOpenMP.cpp
lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp
lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
index 399e393a36fdd..f1b78883aece7 100644
--- a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
@@ -1512,12 +1512,10 @@ static bool isIgnoredParameter(const TheCheck &Check, 
const ParmVarDecl *Node) {
   << "' is ignored.\n");
 
   if (!Node->getIdentifier())
-return llvm::find(Check.IgnoredParameterNames, "\"\"") !=
-   Check.IgnoredParameterNames.end();
+return llvm::is_contained(Check.IgnoredParameterNames, "\"\"");
 
   StringRef NodeName = Node->getName();
-  if (llvm::find(Check.IgnoredParameterNames, NodeName) !=
-  Check.IgnoredParameterNames.end()) {
+  if (llvm::is_contained(Check.IgnoredParameterNames, NodeName)) {
 LLVM_DEBUG(llvm::dbgs() << "\tName ignored.\n");
 return true;
   }
@@ -1584,7 +1582,7 @@ bool lazyMapOfSetsIntersectionExists(const MapTy &Map, 
const ElemTy &E1,
 return false;
 
   for (const auto &E1SetElem : E1Iterator->second)
-if (llvm::find(E2Iterator->second, E1SetElem) != E2Iterator->second.end())
+if (llvm::is_contained(E2Iterator->second, E1SetElem))
   return true;
 
   return false;
@@ -1746,8 +1744,8 @@ class Returned {
   }
 
   bool operator()(const ParmVarDecl *Param1, const ParmVarDecl *Param2) const {
-return llvm::find(ReturnedParams, Param1) != ReturnedParams.end() &&
-   llvm::find(ReturnedParams, Param2) != ReturnedParams.end();
+return llvm::is_contained(ReturnedParams, Param1) &&
+   llvm::is_contained(ReturnedParams, Param2);
   }
 };
 

diff  --git 
a/clang-tools-extra/clang-tidy/cert/ProperlySeededRandomGeneratorCheck.cpp 
b/clang-tools-extra/clang-tidy/cert/ProperlySeededRandomGeneratorCheck.cpp
index 1165eb9a38a56..d35ddd021401b 100644
--- a/clang-tools-extra/clang-tidy/cert/ProperlySeededRandomGeneratorCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cert/ProperlySeededRandomGeneratorCheck.cpp
@@ -112,7 +112,7 @@ void ProperlySeededRandomGeneratorCheck::checkSeed(
 
   const std::string SeedType(
   Func->getArg(0)->IgnoreCasts()->getType().getAsString());
-  if (llvm::find(DisallowedSeedTypes, SeedType) != DisallowedSeedTypes.end()) {
+  if (llvm::is_contained(DisallowedSeedTypes, SeedType)) {
 diag(Func->getExprLoc(),
  "random number generator seeded with a disallowed source of seed "
  "value will generate a predictable sequence of values");

diff  --git a/clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp 
b/clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp
index e818237954891..3cd019d0c386b 100644
--- a/clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp
@@ -60,7 +60,7 @@ template  class 
ImmutableSmallSet {
   size_type count(const T &V) const {
 if (isSmall()) {
   // Since the collection is small, just do a linear search.
-  return llvm::find(Vector, V) == Vector.end() ? 0 : 1;
+  return llvm::is_contained(Vector, V) ? 1 : 0;
 }
 
 return Set.count(V);
@@ -106,7 +106,7 @@ template  class 
SmartSmallSetVector {
   size_type count(const T &V) const {
 if (isSmall()) {
   // Since the collection is small, just do a linear search.
-  return llvm::find(Vector, V) == Vector.end() ? 0 : 1;
+  return llvm::is_contained(Vector, V) ? 1 : 0;
 }
 // Look-up in the Set.
 return Set.count(V);

diff  --git 
a/clang-tools-extra/clang-tidy/readability/DuplicateIncludeCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/DuplicateIncludeCheck.cpp
index 9815952f81759..22a4e4eeec6d7 100644
--- a/clang-tools-extra/clang-tidy/readability/DuplicateIncludeCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/Dup

[clang-tools-extra] 1dd8a31 - [clang-tidy] Use is_contained (NFC)

2022-08-07 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-08-07T23:55:25-07:00
New Revision: 1dd8a318544bdf4d06b337340d678df06e4f2f0a

URL: 
https://github.com/llvm/llvm-project/commit/1dd8a318544bdf4d06b337340d678df06e4f2f0a
DIFF: 
https://github.com/llvm/llvm-project/commit/1dd8a318544bdf4d06b337340d678df06e4f2f0a.diff

LOG: [clang-tidy] Use is_contained (NFC)

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/MoveForwardingReferenceCheck.cpp
clang-tools-extra/clang-tidy/objc/NSDateFormatterCheck.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/MoveForwardingReferenceCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/MoveForwardingReferenceCheck.cpp
index 90b35df09f3d..f4ff4a9a744b 100644
--- a/clang-tools-extra/clang-tidy/bugprone/MoveForwardingReferenceCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/MoveForwardingReferenceCheck.cpp
@@ -112,7 +112,7 @@ void MoveForwardingReferenceCheck::check(
   // template as the function parameter of that type. (This implies that type
   // deduction will happen on the type.)
   const TemplateParameterList *Params = FuncTemplate->getTemplateParameters();
-  if (!std::count(Params->begin(), Params->end(), TypeParmDecl))
+  if (!llvm::is_contained(*Params, TypeParmDecl))
 return;
 
   auto Diag = diag(CallMove->getExprLoc(),

diff  --git a/clang-tools-extra/clang-tidy/objc/NSDateFormatterCheck.cpp 
b/clang-tools-extra/clang-tidy/objc/NSDateFormatterCheck.cpp
index fdc837704a69..e5424c98a72a 100644
--- a/clang-tools-extra/clang-tidy/objc/NSDateFormatterCheck.cpp
+++ b/clang-tools-extra/clang-tidy/objc/NSDateFormatterCheck.cpp
@@ -40,9 +40,7 @@ static char ValidDatePatternChars[] = {
 bool isValidDatePattern(StringRef Pattern) {
   for (auto &PatternChar : Pattern) {
 if (isalpha(PatternChar)) {
-  if (std::find(std::begin(ValidDatePatternChars),
-std::end(ValidDatePatternChars),
-PatternChar) == std::end(ValidDatePatternChars)) {
+  if (!llvm::is_contained(ValidDatePatternChars, PatternChar)) {
 return false;
   }
 }



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8e207e4 - [Basic] Deprecate MapEntryOptionalStorage::{hasValue,getValue}

2022-08-08 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-08-08T21:33:09-07:00
New Revision: 8e207e4c096e89fa5410b519715aba8c20701061

URL: 
https://github.com/llvm/llvm-project/commit/8e207e4c096e89fa5410b519715aba8c20701061
DIFF: 
https://github.com/llvm/llvm-project/commit/8e207e4c096e89fa5410b519715aba8c20701061.diff

LOG: [Basic] Deprecate MapEntryOptionalStorage::{hasValue,getValue}

MapEntryOptionalStorage is an underlying storage class for
OptionalStorage.

This patch deprecates:

  OptionalStorage::hasValue
  OptionalStorage::getValue

as there is no known users of these two methods.

Differential Revision: https://reviews.llvm.org/D131368

Added: 


Modified: 
clang/include/clang/Basic/DirectoryEntry.h

Removed: 




diff  --git a/clang/include/clang/Basic/DirectoryEntry.h 
b/clang/include/clang/Basic/DirectoryEntry.h
index fe5ec958b37c..f1ec63d975a3 100644
--- a/clang/include/clang/Basic/DirectoryEntry.h
+++ b/clang/include/clang/Basic/DirectoryEntry.h
@@ -131,13 +131,15 @@ template  class MapEntryOptionalStorage {
   void reset() { MaybeRef = optional_none_tag(); }
 
   bool has_value() const { return MaybeRef.hasOptionalValue(); }
-  bool hasValue() const { return MaybeRef.hasOptionalValue(); }
+  LLVM_DEPRECATED("Use has_value instead.", "has_value") bool hasValue() const 
{
+return MaybeRef.hasOptionalValue();
+  }
 
   RefTy &value() & {
 assert(has_value());
 return MaybeRef;
   }
-  RefTy &getValue() & {
+  LLVM_DEPRECATED("Use value instead.", "value") RefTy &getValue() & {
 assert(has_value());
 return MaybeRef;
   }
@@ -145,6 +147,7 @@ template  class MapEntryOptionalStorage {
 assert(has_value());
 return MaybeRef;
   }
+  LLVM_DEPRECATED("Use value instead.", "value")
   RefTy const &getValue() const & {
 assert(has_value());
 return MaybeRef;
@@ -153,7 +156,7 @@ template  class MapEntryOptionalStorage {
 assert(has_value());
 return std::move(MaybeRef);
   }
-  RefTy &&getValue() && {
+  LLVM_DEPRECATED("Use value instead.", "value") RefTy &&getValue() && {
 assert(has_value());
 return std::move(MaybeRef);
   }



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 631b94c - [Driver] Remove redundant string initialization (NFC)

2022-02-06 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-02-06T10:54:42-08:00
New Revision: 631b94cc22a83205c1d26baadb579b9c5576c8eb

URL: 
https://github.com/llvm/llvm-project/commit/631b94cc22a83205c1d26baadb579b9c5576c8eb
DIFF: 
https://github.com/llvm/llvm-project/commit/631b94cc22a83205c1d26baadb579b9c5576c8eb.diff

LOG: [Driver] Remove redundant string initialization (NFC)

Identified with readability-redundant-string-init.

Added: 


Modified: 
clang/lib/Driver/ToolChains/WebAssembly.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp 
b/clang/lib/Driver/ToolChains/WebAssembly.cpp
index 4fdfb7e1762e0..292cf4d66971f 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -503,7 +503,7 @@ void WebAssembly::addLibStdCXXIncludePaths(
   bool IsKnownOs = (getTriple().getOS() != llvm::Triple::UnknownOS);
 
   // This is similar to detectLibcxxVersion()
-  std::string Version = "";
+  std::string Version;
   {
 std::error_code EC;
 Generic_GCC::GCCVersion MaxVersion =



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 53daa17 - [clang, clang-tools-extra] Use has_value instead of hasValue (NFC)

2022-07-12 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-07-12T22:47:41-07:00
New Revision: 53daa177f86b3abbc21222d8093fc2ac0aa62035

URL: 
https://github.com/llvm/llvm-project/commit/53daa177f86b3abbc21222d8093fc2ac0aa62035
DIFF: 
https://github.com/llvm/llvm-project/commit/53daa177f86b3abbc21222d8093fc2ac0aa62035.diff

LOG: [clang, clang-tools-extra] Use has_value instead of hasValue (NFC)

Added: 


Modified: 
clang-tools-extra/clangd/AST.cpp
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/ConfigCompile.cpp
clang-tools-extra/clangd/index/YAMLSerialization.cpp
clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
clang-tools-extra/clangd/unittests/FSTests.cpp
clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
clang-tools-extra/clangd/unittests/HeaderSourceSwitchTests.cpp
clang-tools-extra/clangd/unittests/LSPBinderTests.cpp
clang-tools-extra/clangd/unittests/TidyProviderTests.cpp
clang-tools-extra/pseudo/lib/GLR.cpp
clang-tools-extra/unittests/clang-doc/ClangDocTest.cpp
clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
clang-tools-extra/unittests/clang-tidy/OptionsProviderTest.cpp
clang/include/clang/APINotes/Types.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h

clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
clang/lib/Sema/SemaCodeComplete.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/lib/StaticAnalyzer/Core/BugReporter.cpp
clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
clang/unittests/Analysis/MacroExpansionContextTest.cpp
clang/unittests/Basic/DarwinSDKInfoTest.cpp
clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
clang/unittests/Lex/HeaderSearchTest.cpp
clang/unittests/StaticAnalyzer/SValTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/AST.cpp 
b/clang-tools-extra/clangd/AST.cpp
index 1bf876102f991..6ceff56115721 100644
--- a/clang-tools-extra/clangd/AST.cpp
+++ b/clang-tools-extra/clangd/AST.cpp
@@ -745,7 +745,7 @@ class ForwardingCallVisitor
 if (Callee) {
   handleCall(Callee, E->arguments());
 }
-return !Info.hasValue();
+return !Info.has_value();
   }
 
   bool VisitCXXConstructExpr(CXXConstructExpr *E) {
@@ -753,7 +753,7 @@ class ForwardingCallVisitor
 if (Callee) {
   handleCall(Callee, E->arguments());
 }
-return !Info.hasValue();
+return !Info.has_value();
   }
 
   // The expanded parameter pack to be resolved

diff  --git a/clang-tools-extra/clangd/CodeComplete.cpp 
b/clang-tools-extra/clangd/CodeComplete.cpp
index 2da83c05e9702..4e2156bb85bee 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -394,7 +394,7 @@ struct CodeCompletionBuilder {
 std::stable_partition(Completion.Includes.begin(),
   Completion.Includes.end(),
   [](const CodeCompletion::IncludeCandidate &I) {
-return !I.Insertion.hasValue();
+return !I.Insertion.has_value();
   });
   }
 

diff  --git a/clang-tools-extra/clangd/ConfigCompile.cpp 
b/clang-tools-extra/clangd/ConfigCompile.cpp
index 2de8816f9f084..8f207aba29bf4 100644
--- a/clang-tools-extra/clangd/ConfigCompile.cpp
+++ b/clang-tools-extra/clangd/ConfigCompile.cpp
@@ -358,8 +358,8 @@ struct FragmentCompiler {
 }
 #endif
 // Make sure exactly one of the Sources is set.
-unsigned SourceCount = External.File.hasValue() +
-   External.Server.hasValue() + *External.IsNone;
+unsigned SourceCount = External.File.has_value() +
+   External.Server.has_value() + *External.IsNone;
 if (SourceCount != 1) {
   diag(Error, "Exactly one of File, Server or None must be set.",
BlockRange);

diff  --git a/clang-tools-extra/clangd/index/YAMLSerialization.cpp 
b/clang-tools-extra/clangd/index/YAMLSerialization.cpp
index 79c9e1dfd9918..1ac74338298a8 100644
--- a/clang-tools-extra/clangd/index/YAMLSerialization.cpp
+++ b/clang-tools-extra/clangd/index/YAMLSerialization.cpp
@@ -354,23 +354,23 @@ template <> struct MappingTraits {
 
 template <> struct MappingTraits {
   static void mapping(IO &IO, VariantEntry &Variant) {
-if (IO.mapTag("!Symbol", Variant.Symbol.hasValue())) {
+if (IO.mapTag("!Symbol", Variant.Symbol.has_value())) {
   if (!IO.outputting())
 Variant.Symbol.emplace();
   MappingTraits::mapping(IO, *Variant.Symbol);
-} else if (IO.mapTag("!Refs", Variant.Refs.hasValue())) {
+} else if (IO.mapTag("!Refs", Variant.Refs.has_value())) {
   if (!IO.outputti

[clang] cb2c8f6 - [clang] Use value instead of getValue (NFC)

2022-07-13 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-07-13T23:39:33-07:00
New Revision: cb2c8f694db15c488f46de6db5a7db444a189fc4

URL: 
https://github.com/llvm/llvm-project/commit/cb2c8f694db15c488f46de6db5a7db444a189fc4
DIFF: 
https://github.com/llvm/llvm-project/commit/cb2c8f694db15c488f46de6db5a7db444a189fc4.diff

LOG: [clang] Use value instead of getValue (NFC)

Added: 


Modified: 
clang/include/clang/AST/PropertiesBase.td
clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
clang/include/clang/Support/RISCVVIntrinsicUtils.h

clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
clang/lib/AST/AttrImpl.cpp
clang/lib/Analysis/BodyFarm.cpp
clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
clang/lib/Analysis/FlowSensitive/DebugSupport.cpp
clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
clang/lib/Analysis/PathDiagnostic.cpp
clang/lib/Analysis/UninitializedValues.cpp
clang/lib/Basic/Targets/RISCV.cpp
clang/lib/CodeGen/CGClass.cpp
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/AVR.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/Gnu.cpp
clang/lib/Driver/ToolChains/Hexagon.cpp
clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Frontend/InitPreprocessor.cpp
clang/lib/Lex/DependencyDirectivesScanner.cpp
clang/lib/Lex/MacroInfo.cpp
clang/lib/Lex/ModuleMap.cpp
clang/lib/Lex/PPMacroExpansion.cpp
clang/lib/Lex/PreprocessingRecord.cpp
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/SemaCUDA.cpp
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
clang/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
clang/lib/Support/RISCVVIntrinsicUtils.cpp
clang/tools/driver/driver.cpp
clang/tools/libclang/CIndex.cpp
clang/unittests/Analysis/MacroExpansionContextTest.cpp
clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
clang/unittests/Lex/HeaderSearchTest.cpp
clang/utils/TableGen/RISCVVEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/AST/PropertiesBase.td 
b/clang/include/clang/AST/PropertiesBase.td
index 559f29edcf0fe..ec310a459927d 100644
--- a/clang/include/clang/AST/PropertiesBase.td
+++ b/clang/include/clang/AST/PropertiesBase.td
@@ -520,15 +520,15 @@ let Class = PropertyTypeCase in {
 if (hasBase) {
   if (isTypeInfo) {
 base = APValue::LValueBase::getTypeInfo(
-TypeInfoLValue(typeInfo.getValue().getTypePtr()), type.getValue());
+TypeInfoLValue(typeInfo.value().getTypePtr()), type.value());
 elemTy = base.getTypeInfoType();
   } else if (isExpr) {
-base = APValue::LValueBase(cast(stmt.getValue()),
-   callIndex.getValue(), version.getValue());
+base = APValue::LValueBase(cast(stmt.value()),
+   callIndex.value(), version.value());
 elemTy = base.get()->getType();
   } else {
-base = APValue::LValueBase(cast(decl.getValue()),
-   callIndex.getValue(), version.getValue());
+base = APValue::LValueBase(cast(decl.value()),
+   callIndex.value(), version.value());
 elemTy = base.get()->getType();
   }
 }

diff  --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
index 15295e4f6e4ac..50a27a211ef0f 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
@@ -1019,7 +1019,7 @@ class CXXAllocatorCall : public AnyFunctionCall {
   SVal getObjectUnderConstruction() const {
 return ExprEngine::getObjectUnderConstruction(getState(), getOriginExpr(),
   getLocationContext())
-.getValue();
+.value();
   }
 
   /// Number of non-placement arguments to the call. It is equal to 2 for

diff  --git 
a/clang/include/clang/StaticAnalyzer/Core/PathSens

[clang] 3b0dce5 - Use value_or (NFC)

2022-07-15 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-07-15T19:46:29-07:00
New Revision: 3b0dce5b8b1596c50360952a8fb031d52562ccf6

URL: 
https://github.com/llvm/llvm-project/commit/3b0dce5b8b1596c50360952a8fb031d52562ccf6
DIFF: 
https://github.com/llvm/llvm-project/commit/3b0dce5b8b1596c50360952a8fb031d52562ccf6.diff

LOG: Use value_or (NFC)

Added: 


Modified: 
clang/include/clang/APINotes/Types.h
clang/lib/Frontend/InitPreprocessor.cpp
mlir/lib/Dialect/Bufferization/Transforms/BufferUtils.cpp

Removed: 




diff  --git a/clang/include/clang/APINotes/Types.h 
b/clang/include/clang/APINotes/Types.h
index 0e5b43080e4bb..f155d6a063274 100644
--- a/clang/include/clang/APINotes/Types.h
+++ b/clang/include/clang/APINotes/Types.h
@@ -77,7 +77,7 @@ class CommonEntityInfo {
 
   void setSwiftPrivate(llvm::Optional Private) {
 SwiftPrivateSpecified = Private.has_value();
-SwiftPrivate = Private ? *Private : 0;
+SwiftPrivate = Private.value_or(0);
   }
 
   friend bool operator==(const CommonEntityInfo &, const CommonEntityInfo &);

diff  --git a/clang/lib/Frontend/InitPreprocessor.cpp 
b/clang/lib/Frontend/InitPreprocessor.cpp
index d0360696ff9cb..655490ba06e5d 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -829,15 +829,8 @@ static void InitializePredefinedMacros(const TargetInfo 
&TI,
 
 if (LangOpts.ObjCRuntime.getKind() == ObjCRuntime::ObjFW) {
   VersionTuple tuple = LangOpts.ObjCRuntime.getVersion();
-
-  unsigned minor = 0;
-  if (tuple.getMinor())
-minor = tuple.getMinor().value();
-
-  unsigned subminor = 0;
-  if (tuple.getSubminor())
-subminor = tuple.getSubminor().value();
-
+  unsigned minor = tuple.getMinor().value_or(0);
+  unsigned subminor = tuple.getSubminor().value_or(0);
   Builder.defineMacro("__OBJFW_RUNTIME_ABI__",
   Twine(tuple.getMajor() * 1 + minor * 100 +
 subminor));

diff  --git a/mlir/lib/Dialect/Bufferization/Transforms/BufferUtils.cpp 
b/mlir/lib/Dialect/Bufferization/Transforms/BufferUtils.cpp
index 146d9d0fc64ff..e4ae23e9bcde2 100644
--- a/mlir/lib/Dialect/Bufferization/Transforms/BufferUtils.cpp
+++ b/mlir/lib/Dialect/Bufferization/Transforms/BufferUtils.cpp
@@ -160,9 +160,7 @@ bufferization::getGlobalFor(arith::ConstantOp constantOp, 
uint64_t alignment) {
   continue;
 if (!globalOp.getInitialValue().has_value())
   continue;
-uint64_t opAlignment = globalOp.getAlignment().has_value()
-   ? globalOp.getAlignment().value()
-   : 0;
+uint64_t opAlignment = globalOp.getAlignment().value_or(0);
 Attribute initialValue = globalOp.getInitialValue().value();
 if (opAlignment == alignment && initialValue == constantOp.getValue())
   return globalOp;



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 246bf08 - Use drop_begin (NFC)

2022-07-15 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-07-15T23:24:59-07:00
New Revision: 246bf08db3fe0c64a6f59b67a5f48d054f6f9901

URL: 
https://github.com/llvm/llvm-project/commit/246bf08db3fe0c64a6f59b67a5f48d054f6f9901
DIFF: 
https://github.com/llvm/llvm-project/commit/246bf08db3fe0c64a6f59b67a5f48d054f6f9901.diff

LOG: Use drop_begin (NFC)

Added: 


Modified: 
clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
llvm/lib/MC/MCParser/MasmParser.cpp
mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp 
b/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
index 59acc29e8ee9a..fc6b05c672a45 100644
--- a/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
+++ b/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
@@ -308,14 +308,14 @@ bool conflictInNamespace(const ASTContext &AST, 
llvm::StringRef QualifiedSymbol,
 // symbol name would have been shortened.
 const NamedDecl *Scope =
 LookupDecl(*AST.getTranslationUnitDecl(), NsSplitted.front());
-for (auto I = NsSplitted.begin() + 1, E = NsSplitted.end(); I != E; ++I) {
-  if (*I == SymbolTopNs) // Handles "::ny" in "::nx::ny" case.
+for (const auto &I : llvm::drop_begin(NsSplitted)) {
+  if (I == SymbolTopNs) // Handles "::ny" in "::nx::ny" case.
 return true;
   // Handles "::util" and "::nx::util" conflicts.
   if (Scope) {
 if (LookupDecl(*Scope, SymbolTopNs))
   return true;
-Scope = LookupDecl(*Scope, *I);
+Scope = LookupDecl(*Scope, I);
   }
 }
 if (Scope && LookupDecl(*Scope, SymbolTopNs))

diff  --git a/llvm/lib/MC/MCParser/MasmParser.cpp 
b/llvm/lib/MC/MCParser/MasmParser.cpp
index 694ea395fdecb..af80d83272100 100644
--- a/llvm/lib/MC/MCParser/MasmParser.cpp
+++ b/llvm/lib/MC/MCParser/MasmParser.cpp
@@ -4238,11 +4238,8 @@ bool MasmParser::parseStructInitializer(const StructInfo 
&Structure,
 }
   }
   // Default-initialize all remaining fields.
-  for (auto It = Structure.Fields.begin() + FieldIndex;
-   It != Structure.Fields.end(); ++It) {
-const FieldInfo &Field = *It;
+  for (const FieldInfo &Field : llvm::drop_begin(Structure.Fields, FieldIndex))
 FieldInitializers.push_back(Field.Contents);
-  }
 
   if (EndToken) {
 if (EndToken.value() == AsmToken::Greater)
@@ -4350,9 +4347,8 @@ bool MasmParser::emitFieldInitializer(const FieldInfo 
&Field,
   return true;
   }
   // Default-initialize all remaining values.
-  for (auto it = Contents.Values.begin() + Initializer.Values.size();
-   it != Contents.Values.end(); ++it) {
-const auto &Value = *it;
+  for (const auto &Value :
+   llvm::drop_begin(Contents.Values, Initializer.Values.size())) {
 if (emitIntValue(Value, Field.Type))
   return true;
   }
@@ -4367,9 +4363,8 @@ bool MasmParser::emitFieldInitializer(const FieldInfo 
&Field,
AsInt.getBitWidth() / 8);
   }
   // Default-initialize all remaining values.
-  for (auto It = Contents.AsIntValues.begin() + Initializer.AsIntValues.size();
-   It != Contents.AsIntValues.end(); ++It) {
-const auto &AsInt = *It;
+  for (const auto &AsInt :
+   llvm::drop_begin(Contents.AsIntValues, Initializer.AsIntValues.size())) 
{
 getStreamer().emitIntValue(AsInt.getLimitedValue(),
AsInt.getBitWidth() / 8);
   }
@@ -4384,10 +4379,8 @@ bool MasmParser::emitFieldInitializer(const FieldInfo 
&Field,
   return true;
   }
   // Default-initialize all remaining values.
-  for (auto It =
-   Contents.Initializers.begin() + Initializer.Initializers.size();
-   It != Contents.Initializers.end(); ++It) {
-const auto &Init = *It;
+  for (const auto &Init : llvm::drop_begin(Contents.Initializers,
+   Initializer.Initializers.size())) {
 if (emitStructInitializer(Contents.Structure, Init))
   return true;
   }
@@ -4425,10 +4418,8 @@ bool MasmParser::emitStructInitializer(const StructInfo 
&Structure,
   return true;
   }
   // Default-initialize all remaining fields.
-  for (auto It =
-   Structure.Fields.begin() + Initializer.FieldInitializers.size();
-   It != Structure.Fields.end(); ++It) {
-const auto &Field = *It;
+  for (const auto &Field : llvm::drop_begin(
+   Structure.Fields, Initializer.FieldInitializers.size())) {
 getStreamer().emitZeros(Field.Offset - Offset);
 Offset = Field.Offset + Field.SizeOf;
 if (emitFieldValue(Field))
@@ -4649,10 +4640,8 @@ bool MasmParser::parseDirectiveNestedEnds() {
 if (ParentStruct.IsUnion) {
   ParentStruct.Size = std::max(ParentStruct.Size, Structure.Size);
 } else {
-  for (auto FieldIter = ParentStruct.Fields.begin() + OldFields;
-   FieldIter != ParentStruct.Fields.end(); ++FieldIter) {
-

[clang] 8dfdb80 - Ensure newlines at the end of files (NFC)

2022-07-17 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-07-17T15:37:45-07:00
New Revision: 8dfdb80f72c080585517f10862b3b08d745b9155

URL: 
https://github.com/llvm/llvm-project/commit/8dfdb80f72c080585517f10862b3b08d745b9155
DIFF: 
https://github.com/llvm/llvm-project/commit/8dfdb80f72c080585517f10862b3b08d745b9155.diff

LOG: Ensure newlines at the end of files (NFC)

Added: 


Modified: 
clang/lib/Basic/MakeSupport.cpp
libc/src/math/generic/CMakeLists.txt
llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.cpp
llvm/lib/Target/SPIRV/SPIRVDuplicatesTracker.cpp
llvm/lib/Target/SPIRV/SPIRVDuplicatesTracker.h
mlir/lib/Conversion/VectorToGPU/NvGpuSupport.cpp
mlir/lib/Dialect/LLVMIR/IR/LLVMIntrinsicOps.cpp

Removed: 




diff  --git a/clang/lib/Basic/MakeSupport.cpp b/clang/lib/Basic/MakeSupport.cpp
index 37838f7bbc7bc..4ddfcc350410c 100644
--- a/clang/lib/Basic/MakeSupport.cpp
+++ b/clang/lib/Basic/MakeSupport.cpp
@@ -32,4 +32,4 @@ void clang::quoteMakeTarget(StringRef Target, 
SmallVectorImpl &Res) {
 
 Res.push_back(Target[i]);
   }
-}
\ No newline at end of file
+}

diff  --git a/libc/src/math/generic/CMakeLists.txt 
b/libc/src/math/generic/CMakeLists.txt
index 1a693e6d5c2c9..41588104cf62f 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -1115,4 +1115,4 @@ add_entrypoint_object(
 libc.src.__support.FPUtil.generic.fmod
   COMPILE_OPTIONS
 -O3
-)
\ No newline at end of file
+)

diff  --git a/llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.cpp 
b/llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.cpp
index 43b9c2ba400b7..dc07eaeaf615c 100644
--- a/llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.cpp
@@ -524,4 +524,4 @@ COFFLinkGraphBuilder::exportCOMDATSymbol(COFFSymbolIndex 
SymIndex,
 }
 
 } // namespace jitlink
-} // namespace llvm
\ No newline at end of file
+} // namespace llvm

diff  --git a/llvm/lib/Target/SPIRV/SPIRVDuplicatesTracker.cpp 
b/llvm/lib/Target/SPIRV/SPIRVDuplicatesTracker.cpp
index 57cd4bafd3516..1926977ea66ea 100644
--- a/llvm/lib/Target/SPIRV/SPIRVDuplicatesTracker.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVDuplicatesTracker.cpp
@@ -92,4 +92,4 @@ void SPIRVGeneralDuplicatesTracker::buildDepsGraph(
   }
 }
   }
-}
\ No newline at end of file
+}

diff  --git a/llvm/lib/Target/SPIRV/SPIRVDuplicatesTracker.h 
b/llvm/lib/Target/SPIRV/SPIRVDuplicatesTracker.h
index 58ae1f86ce42c..c2801faf6f0eb 100644
--- a/llvm/lib/Target/SPIRV/SPIRVDuplicatesTracker.h
+++ b/llvm/lib/Target/SPIRV/SPIRVDuplicatesTracker.h
@@ -171,4 +171,4 @@ class SPIRVGeneralDuplicatesTracker {
   }
 };
 } // namespace llvm
-#endif
\ No newline at end of file
+#endif

diff  --git a/mlir/lib/Conversion/VectorToGPU/NvGpuSupport.cpp 
b/mlir/lib/Conversion/VectorToGPU/NvGpuSupport.cpp
index af14aaa1deeec..65f97da634675 100644
--- a/mlir/lib/Conversion/VectorToGPU/NvGpuSupport.cpp
+++ b/mlir/lib/Conversion/VectorToGPU/NvGpuSupport.cpp
@@ -332,4 +332,4 @@ 
PrepareContractToGPUMMASync::matchAndRewrite(vector::ContractionOp op,
 }
 
 } // namespace nvgpu
-} // namespace mlir
\ No newline at end of file
+} // namespace mlir

diff  --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMIntrinsicOps.cpp 
b/mlir/lib/Dialect/LLVMIR/IR/LLVMIntrinsicOps.cpp
index 15f15b745e190..a5d85a7cf4ccb 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMIntrinsicOps.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMIntrinsicOps.cpp
@@ -4,4 +4,4 @@ using namespace mlir;
 using namespace mlir::LLVM;
 
 #define GET_OP_CLASSES
-#include "mlir/Dialect/LLVMIR/LLVMIntrinsicOps.cpp.inc"
\ No newline at end of file
+#include "mlir/Dialect/LLVMIR/LLVMIntrinsicOps.cpp.inc"



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8b3ed1f - Remove redundant return statements (NFC)

2022-07-17 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-07-17T15:37:46-07:00
New Revision: 8b3ed1fa984b07c88f218d0ddc6b3e2c0629a9fa

URL: 
https://github.com/llvm/llvm-project/commit/8b3ed1fa984b07c88f218d0ddc6b3e2c0629a9fa
DIFF: 
https://github.com/llvm/llvm-project/commit/8b3ed1fa984b07c88f218d0ddc6b3e2c0629a9fa.diff

LOG: Remove redundant return statements (NFC)

Identified with readability-redundant-control-flow.

Added: 


Modified: 
clang/lib/Sema/SemaExpr.cpp
flang/lib/Frontend/TextDiagnosticPrinter.cpp
flang/lib/Lower/Allocatable.cpp
flang/lib/Lower/ConvertType.cpp
flang/lib/Optimizer/Transforms/AffinePromotion.cpp
flang/lib/Semantics/check-directive-structure.h
lldb/include/lldb/Symbol/SymbolFile.h
llvm/lib/Transforms/Scalar/LoopInterchange.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index c04186dea43eb..0b4c450f76e0d 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -19721,7 +19721,6 @@ class EvaluatedExprMarker : public 
UsedDeclVisitor {
   void VisitConstantExpr(ConstantExpr *E) {
 // Don't mark declarations within a ConstantExpression, as this expression
 // will be evaluated and folded to a value.
-return;
   }
 
   void VisitDeclRefExpr(DeclRefExpr *E) {

diff  --git a/flang/lib/Frontend/TextDiagnosticPrinter.cpp 
b/flang/lib/Frontend/TextDiagnosticPrinter.cpp
index 5ee4122af1053..12c41d77ba467 100644
--- a/flang/lib/Frontend/TextDiagnosticPrinter.cpp
+++ b/flang/lib/Frontend/TextDiagnosticPrinter.cpp
@@ -56,5 +56,4 @@ void TextDiagnosticPrinter::HandleDiagnostic(
   diagMessageStream.str(), diagOpts->ShowColors);
 
   os.flush();
-  return;
 }

diff  --git a/flang/lib/Lower/Allocatable.cpp b/flang/lib/Lower/Allocatable.cpp
index 01a13b8555fa8..08a90f168 100644
--- a/flang/lib/Lower/Allocatable.cpp
+++ b/flang/lib/Lower/Allocatable.cpp
@@ -500,7 +500,6 @@ void Fortran::lower::genAllocateStmt(
 Fortran::lower::AbstractConverter &converter,
 const Fortran::parser::AllocateStmt &stmt, mlir::Location loc) {
   AllocateStmtHelper{converter, stmt, loc}.lower();
-  return;
 }
 
 
//===--===//

diff  --git a/flang/lib/Lower/ConvertType.cpp b/flang/lib/Lower/ConvertType.cpp
index 0ab9d2d1b48e0..772c8508b7c05 100644
--- a/flang/lib/Lower/ConvertType.cpp
+++ b/flang/lib/Lower/ConvertType.cpp
@@ -368,7 +368,6 @@ struct TypeBuilder {
   params.push_back(getCharacterLength(exprOrSym));
 else if (category == Fortran::common::TypeCategory::Derived)
   TODO(converter.getCurrentLocation(), "derived type length parameters");
-return;
   }
   Fortran::lower::LenParameterTy
   getCharacterLength(const Fortran::semantics::Symbol &symbol) {

diff  --git a/flang/lib/Optimizer/Transforms/AffinePromotion.cpp 
b/flang/lib/Optimizer/Transforms/AffinePromotion.cpp
index c6df98769a64b..90b4364866c96 100644
--- a/flang/lib/Optimizer/Transforms/AffinePromotion.cpp
+++ b/flang/lib/Optimizer/Transforms/AffinePromotion.cpp
@@ -242,7 +242,6 @@ struct AffineIfCondition {
 integerSet = mlir::IntegerSet::get(dimCount, symCount,
{constraintPair.getValue().first},
{constraintPair.getValue().second});
-return;
   }
 
   llvm::Optional>
@@ -392,7 +391,6 @@ static void populateIndexArgs(fir::ArrayCoorOp acoOp,
 return populateIndexArgs(acoOp, shapeShift, indexArgs, rewriter);
   if (auto slice = acoOp.getShape().getDefiningOp())
 return populateIndexArgs(acoOp, slice, indexArgs, rewriter);
-  return;
 }
 
 /// Returns affine.apply and fir.convert from array_coor and gendims

diff  --git a/flang/lib/Semantics/check-directive-structure.h 
b/flang/lib/Semantics/check-directive-structure.h
index 6444e839967df..3fdcbf2b88ec4 100644
--- a/flang/lib/Semantics/check-directive-structure.h
+++ b/flang/lib/Semantics/check-directive-structure.h
@@ -142,7 +142,6 @@ template  class NoBranchingEnforce {
 // did not found an enclosing looping construct within the OpenMP/OpenACC
 // directive
 EmitUnlabelledBranchOutError(stmt);
-return;
   }
 
   SemanticsContext &context_;

diff  --git a/lldb/include/lldb/Symbol/SymbolFile.h 
b/lldb/include/lldb/Symbol/SymbolFile.h
index 1470b96f24917..ed0de1b5bce6b 100644
--- a/lldb/include/lldb/Symbol/SymbolFile.h
+++ b/lldb/include/lldb/Symbol/SymbolFile.h
@@ -132,7 +132,7 @@ class SymbolFile : public PluginInterface {
   /// Specify debug info should be loaded.
   ///
   /// It will be no-op for most implementations except SymbolFileOnDemand.
-  virtual void SetLoadDebugInfoEnabled() { return; }
+  virtual void SetLoadDebugInfoEnabled() {}
 
   // Compile Unit function calls
   // Approach 1 - iterator

diff  --git a/llvm/lib/Transforms/Scalar/LoopInterchange.cpp 
b/llvm/lib/Transforms/Scalar/LoopInterchange.cpp
index 1d302

[clang] 41ae78e - Use has_value instead of hasValue (NFC)

2022-07-19 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-07-19T20:15:44-07:00
New Revision: 41ae78ea3a931018cf2be58fb9eaa98bfeaf2db6

URL: 
https://github.com/llvm/llvm-project/commit/41ae78ea3a931018cf2be58fb9eaa98bfeaf2db6
DIFF: 
https://github.com/llvm/llvm-project/commit/41ae78ea3a931018cf2be58fb9eaa98bfeaf2db6.diff

LOG: Use has_value instead of hasValue (NFC)

Added: 


Modified: 
clang/lib/Basic/Sarif.cpp
clang/unittests/Basic/SarifTest.cpp
llvm/lib/CodeGen/ExpandVectorPredication.cpp
llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp
llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
llvm/lib/Target/AMDGPU/SIISelLowering.cpp
llvm/lib/Transforms/IPO/Attributor.cpp
llvm/lib/Transforms/IPO/AttributorAttributes.cpp

Removed: 




diff  --git a/clang/lib/Basic/Sarif.cpp b/clang/lib/Basic/Sarif.cpp
index 668e60d47eecd..ed43c7eab0566 100644
--- a/clang/lib/Basic/Sarif.cpp
+++ b/clang/lib/Basic/Sarif.cpp
@@ -270,18 +270,18 @@ void SarifDocumentWriter::endRun() {
   for (const auto &Pair : CurrentArtifacts) {
 const SarifArtifact &A = Pair.getValue();
 json::Object Loc{{"uri", A.Location.URI}};
-if (A.Location.Index.hasValue()) {
+if (A.Location.Index.has_value()) {
   Loc["index"] = static_cast(A.Location.Index.getValue());
 }
 json::Object Artifact;
 Artifact["location"] = std::move(Loc);
-if (A.Length.hasValue())
+if (A.Length.has_value())
   Artifact["length"] = static_cast(A.Length.getValue());
 if (!A.Roles.empty())
   Artifact["roles"] = json::Array(A.Roles);
 if (!A.MimeType.empty())
   Artifact["mimeType"] = A.MimeType;
-if (A.Offset.hasValue())
+if (A.Offset.has_value())
   Artifact["offset"] = A.Offset;
 Artifacts->push_back(json::Value(std::move(Artifact)));
   }

diff  --git a/clang/unittests/Basic/SarifTest.cpp 
b/clang/unittests/Basic/SarifTest.cpp
index 05221c828afe6..328496ab137d3 100644
--- a/clang/unittests/Basic/SarifTest.cpp
+++ b/clang/unittests/Basic/SarifTest.cpp
@@ -117,9 +117,9 @@ TEST_F(SarifDocumentWriterTest, 
canCreateDocumentWithOneRun) {
   Runs->begin()->getAsObject()->getObject("tool")->getObject("driver");
   ASSERT_THAT(driver, testing::NotNull());
 
-  ASSERT_TRUE(driver->getString("name").hasValue());
-  ASSERT_TRUE(driver->getString("fullName").hasValue());
-  ASSERT_TRUE(driver->getString("language").hasValue());
+  ASSERT_TRUE(driver->getString("name").has_value());
+  ASSERT_TRUE(driver->getString("fullName").has_value());
+  ASSERT_TRUE(driver->getString("language").has_value());
 
   EXPECT_EQ(driver->getString("name").getValue(), ShortName);
   EXPECT_EQ(driver->getString("fullName").getValue(), LongName);
@@ -186,8 +186,8 @@ TEST_F(SarifDocumentWriterTest, 
addingResultWithValidRuleAndRunIsOk) {
   const llvm::json::Array *Artifacts = TheRun->getArray("artifacts");
 
   // The tool is as expected
-  ASSERT_TRUE(Driver->getString("name").hasValue());
-  ASSERT_TRUE(Driver->getString("fullName").hasValue());
+  ASSERT_TRUE(Driver->getString("name").has_value());
+  ASSERT_TRUE(Driver->getString("fullName").has_value());
 
   EXPECT_EQ(Driver->getString("name").getValue(), "sarif test");
   EXPECT_EQ(Driver->getString("fullName").getValue(), "sarif test runner");

diff  --git a/llvm/lib/CodeGen/ExpandVectorPredication.cpp 
b/llvm/lib/CodeGen/ExpandVectorPredication.cpp
index ed95437f39bf9..8840ddde36921 100644
--- a/llvm/lib/CodeGen/ExpandVectorPredication.cpp
+++ b/llvm/lib/CodeGen/ExpandVectorPredication.cpp
@@ -419,7 +419,7 @@ 
CachingVPExpander::expandPredicationInMemoryIntrinsic(IRBuilder<> &Builder,
 if (IsUnmasked) {
   StoreInst *NewStore =
   Builder.CreateStore(DataParam, PtrParam, /*IsVolatile*/ false);
-  if (AlignOpt.hasValue())
+  if (AlignOpt.has_value())
 NewStore->setAlignment(AlignOpt.getValue());
   NewMemoryInst = NewStore;
 } else
@@ -431,7 +431,7 @@ 
CachingVPExpander::expandPredicationInMemoryIntrinsic(IRBuilder<> &Builder,
 if (IsUnmasked) {
   LoadInst *NewLoad =
   Builder.CreateLoad(VPI.getType(), PtrParam, /*IsVolatile*/ false);
-  if (AlignOpt.hasValue())
+  if (AlignOpt.has_value())
 NewLoad->setAlignment(AlignOpt.getValue());
   NewMemoryInst = NewLoad;
 } else

diff  --git a/llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp
index 484e195c055b3..aa4e0116e404c 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp
@@ -815,7 +815,7 @@ bool AMDGPUCallLowering::passSpecialInputs(MachineIRBuilder 
&MIRBuilder,
 } else if (InputID == AMDGPUFunctionArgInfo::LDS_KERNEL_ID) {
   Optional Id =
   AMDGPUMachineFunction::getLDSKernelIdMetadata(MF.getFunction());
-  if (Id.hasValue()) {
+  if (Id.has_value()) {
 MIRBuilder.buildConstant(InputReg, Id.getValue());
   } else

[clang] 0387da6 - Use value instead of getValue (NFC)

2022-07-19 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-07-19T21:18:26-07:00
New Revision: 0387da6f4f68fb00183c76bfd4f4f48533bc10e1

URL: 
https://github.com/llvm/llvm-project/commit/0387da6f4f68fb00183c76bfd4f4f48533bc10e1
DIFF: 
https://github.com/llvm/llvm-project/commit/0387da6f4f68fb00183c76bfd4f4f48533bc10e1.diff

LOG: Use value instead of getValue (NFC)

Added: 


Modified: 
clang/lib/Basic/Sarif.cpp
clang/unittests/Basic/SarifTest.cpp
llvm/lib/CodeGen/ExpandVectorPredication.cpp
llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp
llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
llvm/lib/Target/AMDGPU/SIISelLowering.cpp
llvm/lib/Transforms/IPO/Attributor.cpp
llvm/lib/Transforms/IPO/AttributorAttributes.cpp

Removed: 




diff  --git a/clang/lib/Basic/Sarif.cpp b/clang/lib/Basic/Sarif.cpp
index ed43c7eab056..faca9c508c08 100644
--- a/clang/lib/Basic/Sarif.cpp
+++ b/clang/lib/Basic/Sarif.cpp
@@ -217,7 +217,7 @@ SarifDocumentWriter::createPhysicalLocation(const 
CharSourceRange &R) {
   }
   assert(I != CurrentArtifacts.end() && "Failed to insert new artifact");
   const SarifArtifactLocation &Location = I->second.Location;
-  uint32_t Idx = Location.Index.getValue();
+  uint32_t Idx = Location.Index.value();
   return json::Object{{{"artifactLocation", json::Object{{{"index", Idx,
{"region", createTextRegion(SourceMgr, R)}}};
 }
@@ -271,12 +271,12 @@ void SarifDocumentWriter::endRun() {
 const SarifArtifact &A = Pair.getValue();
 json::Object Loc{{"uri", A.Location.URI}};
 if (A.Location.Index.has_value()) {
-  Loc["index"] = static_cast(A.Location.Index.getValue());
+  Loc["index"] = static_cast(A.Location.Index.value());
 }
 json::Object Artifact;
 Artifact["location"] = std::move(Loc);
 if (A.Length.has_value())
-  Artifact["length"] = static_cast(A.Length.getValue());
+  Artifact["length"] = static_cast(A.Length.value());
 if (!A.Roles.empty())
   Artifact["roles"] = json::Array(A.Roles);
 if (!A.MimeType.empty())

diff  --git a/clang/unittests/Basic/SarifTest.cpp 
b/clang/unittests/Basic/SarifTest.cpp
index 328496ab137d..e647d362fcc6 100644
--- a/clang/unittests/Basic/SarifTest.cpp
+++ b/clang/unittests/Basic/SarifTest.cpp
@@ -121,9 +121,9 @@ TEST_F(SarifDocumentWriterTest, 
canCreateDocumentWithOneRun) {
   ASSERT_TRUE(driver->getString("fullName").has_value());
   ASSERT_TRUE(driver->getString("language").has_value());
 
-  EXPECT_EQ(driver->getString("name").getValue(), ShortName);
-  EXPECT_EQ(driver->getString("fullName").getValue(), LongName);
-  EXPECT_EQ(driver->getString("language").getValue(), "en-US");
+  EXPECT_EQ(driver->getString("name").value(), ShortName);
+  EXPECT_EQ(driver->getString("fullName").value(), LongName);
+  EXPECT_EQ(driver->getString("language").value(), "en-US");
 }
 
 TEST_F(SarifDocumentWriterTest, addingResultsWillCrashIfThereIsNoRun) {
@@ -189,8 +189,8 @@ TEST_F(SarifDocumentWriterTest, 
addingResultWithValidRuleAndRunIsOk) {
   ASSERT_TRUE(Driver->getString("name").has_value());
   ASSERT_TRUE(Driver->getString("fullName").has_value());
 
-  EXPECT_EQ(Driver->getString("name").getValue(), "sarif test");
-  EXPECT_EQ(Driver->getString("fullName").getValue(), "sarif test runner");
+  EXPECT_EQ(Driver->getString("name").value(), "sarif test");
+  EXPECT_EQ(Driver->getString("fullName").value(), "sarif test runner");
 
   // The results are as expected
   EXPECT_EQ(Results->size(), 1UL);

diff  --git a/llvm/lib/CodeGen/ExpandVectorPredication.cpp 
b/llvm/lib/CodeGen/ExpandVectorPredication.cpp
index 8840ddde3692..db4d42bf3ca4 100644
--- a/llvm/lib/CodeGen/ExpandVectorPredication.cpp
+++ b/llvm/lib/CodeGen/ExpandVectorPredication.cpp
@@ -420,7 +420,7 @@ 
CachingVPExpander::expandPredicationInMemoryIntrinsic(IRBuilder<> &Builder,
   StoreInst *NewStore =
   Builder.CreateStore(DataParam, PtrParam, /*IsVolatile*/ false);
   if (AlignOpt.has_value())
-NewStore->setAlignment(AlignOpt.getValue());
+NewStore->setAlignment(AlignOpt.value());
   NewMemoryInst = NewStore;
 } else
   NewMemoryInst = Builder.CreateMaskedStore(
@@ -432,7 +432,7 @@ 
CachingVPExpander::expandPredicationInMemoryIntrinsic(IRBuilder<> &Builder,
   LoadInst *NewLoad =
   Builder.CreateLoad(VPI.getType(), PtrParam, /*IsVolatile*/ false);
   if (AlignOpt.has_value())
-NewLoad->setAlignment(AlignOpt.getValue());
+NewLoad->setAlignment(AlignOpt.value());
   NewMemoryInst = NewLoad;
 } else
   NewMemoryInst = Builder.CreateMaskedLoad(

diff  --git a/llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp
index aa4e0116e404..4550cfdcf883 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp
@@ -816,7 +816,7 @@ bool AMDGPUCallLowering::passSpecialInputs(Mac

[clang] 70257fa - Use any_of (NFC)

2022-07-22 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-07-22T01:05:17-07:00
New Revision: 70257fab68e8081f5a4f182ea580f284b593aa6f

URL: 
https://github.com/llvm/llvm-project/commit/70257fab68e8081f5a4f182ea580f284b593aa6f
DIFF: 
https://github.com/llvm/llvm-project/commit/70257fab68e8081f5a4f182ea580f284b593aa6f.diff

LOG: Use any_of (NFC)

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/MacroRepeatedSideEffectsCheck.cpp
clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
clang-tools-extra/clangd/index/Merge.cpp
clang/lib/Lex/ModuleMap.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaTemplate.cpp
lld/wasm/SyntheticSections.h
llvm/include/llvm/Passes/StandardInstrumentations.h
mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
polly/lib/Analysis/ScopBuilder.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/MacroRepeatedSideEffectsCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/MacroRepeatedSideEffectsCheck.cpp
index 245c03fe8e9c3..dbda14c97e5fc 100644
--- a/clang-tools-extra/clang-tidy/bugprone/MacroRepeatedSideEffectsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/MacroRepeatedSideEffectsCheck.cpp
@@ -49,13 +49,11 @@ void MacroRepeatedPPCallbacks::MacroExpands(const Token 
&MacroNameTok,
 
   // Bail out if the contents of the macro are containing keywords that are
   // making the macro too complex.
-  if (std::find_if(
-  MI->tokens().begin(), MI->tokens().end(), [](const Token &T) {
-return T.isOneOf(tok::kw_if, tok::kw_else, tok::kw_switch,
- tok::kw_case, tok::kw_break, tok::kw_while,
- tok::kw_do, tok::kw_for, tok::kw_continue,
- tok::kw_goto, tok::kw_return);
-  }) != MI->tokens().end())
+  if (llvm::any_of(MI->tokens(), [](const Token &T) {
+return T.isOneOf(tok::kw_if, tok::kw_else, tok::kw_switch, 
tok::kw_case,
+ tok::kw_break, tok::kw_while, tok::kw_do, tok::kw_for,
+ tok::kw_continue, tok::kw_goto, tok::kw_return);
+  }))
 return;
 
   for (unsigned ArgNo = 0U; ArgNo < MI->getNumParams(); ++ArgNo) {

diff  --git a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp 
b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
index b5e5191876cad..67d8ccbd6cad4 100644
--- a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -604,9 +604,9 @@ int clangTidyMain(int argc, const char **argv) {
   std::vector Errors =
   runClangTidy(Context, OptionsParser->getCompilations(), PathList, BaseFS,
FixNotes, EnableCheckProfile, ProfilePrefix);
-  bool FoundErrors = llvm::find_if(Errors, [](const ClangTidyError &E) {
-   return E.DiagLevel == ClangTidyError::Error;
- }) != Errors.end();
+  bool FoundErrors = llvm::any_of(Errors, [](const ClangTidyError &E) {
+return E.DiagLevel == ClangTidyError::Error;
+  });
 
   // --fix-errors and --fix-notes imply --fix.
   FixBehaviour Behaviour = FixNotes ? FB_FixNotes

diff  --git a/clang-tools-extra/clangd/index/Merge.cpp 
b/clang-tools-extra/clangd/index/Merge.cpp
index 997bbfb6672a1..0d15dfcb1f252 100644
--- a/clang-tools-extra/clangd/index/Merge.cpp
+++ b/clang-tools-extra/clangd/index/Merge.cpp
@@ -196,10 +196,9 @@ static bool prefer(const SymbolLocation &L, const 
SymbolLocation &R) {
 return true;
   auto HasCodeGenSuffix = [](const SymbolLocation &Loc) {
 constexpr static const char *CodegenSuffixes[] = {".proto"};
-return std::any_of(std::begin(CodegenSuffixes), std::end(CodegenSuffixes),
-   [&](llvm::StringRef Suffix) {
- return llvm::StringRef(Loc.FileURI).endswith(Suffix);
-   });
+return llvm::any_of(CodegenSuffixes, [&](llvm::StringRef Suffix) {
+  return llvm::StringRef(Loc.FileURI).endswith(Suffix);
+});
   };
   return HasCodeGenSuffix(L) && !HasCodeGenSuffix(R);
 }

diff  --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index 57e344622f25a..47d6f5893e974 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -456,10 +456,8 @@ static bool violatesPrivateInclude(Module 
*RequestingModule,
 &Header.getModule()->Headers[Module::HK_Private],
 &Header.getModule()->Headers[Module::HK_PrivateTextual]};
 for (auto *Hs : HeaderList)
-  IsPrivate |=
-  std::find_if(Hs->begin(), Hs->end(), [&](const Module::Header &H) {
-return H.Entry == IncFileEnt;
-  }) != Hs->end();
+  IsPrivate |= llvm::any_of(
+  *Hs, [&](const Module::Header &H) { return H.Entry == IncFileEnt; });
 assert(IsPrivate && "inconsistent headers and roles");
   }
 #endif

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp

[clang-tools-extra] c730f9a - Convert for_each to range-based for loops (NFC)

2022-07-23 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-07-23T12:17:27-07:00
New Revision: c730f9a164eacc30fdd0f6ae202211ef8a63b64a

URL: 
https://github.com/llvm/llvm-project/commit/c730f9a164eacc30fdd0f6ae202211ef8a63b64a
DIFF: 
https://github.com/llvm/llvm-project/commit/c730f9a164eacc30fdd0f6ae202211ef8a63b64a.diff

LOG: Convert for_each to range-based for loops (NFC)

Added: 


Modified: 
clang-tools-extra/clangd/refactor/Rename.cpp
lld/COFF/DebugTypes.cpp
lld/COFF/PDB.cpp
mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp
mlir/lib/Dialect/Bufferization/Transforms/BufferDeallocation.cpp
mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/Rename.cpp 
b/clang-tools-extra/clangd/refactor/Rename.cpp
index 46d884578d462..83df990d35cd9 100644
--- a/clang-tools-extra/clangd/refactor/Rename.cpp
+++ b/clang-tools-extra/clangd/refactor/Rename.cpp
@@ -768,9 +768,8 @@ llvm::Expected rename(const RenameInputs 
&RInputs) {
   RenameResult Result;
   Result.Target = CurrentIdentifier;
   Edit MainFileEdits = Edit(MainFileCode, std::move(*MainFileRenameEdit));
-  llvm::for_each(MainFileEdits.asTextEdits(), [&Result](const TextEdit &TE) {
+  for (const TextEdit &TE : MainFileEdits.asTextEdits())
 Result.LocalChanges.push_back(TE.range);
-  });
 
   // return the main file edit if this is a within-file rename or the symbol
   // being renamed is function local.

diff  --git a/lld/COFF/DebugTypes.cpp b/lld/COFF/DebugTypes.cpp
index 5878386aeb934..800b40f343aa9 100644
--- a/lld/COFF/DebugTypes.cpp
+++ b/lld/COFF/DebugTypes.cpp
@@ -1126,9 +1126,8 @@ void TypeMerger::mergeTypesWithGHash() {
   }
 
   // In parallel, remap all types.
-  for_each(dependencySources, [&](TpiSource *source) {
+  for (TpiSource *source : dependencySources)
 source->remapTpiWithGHashes(&ghashState);
-  });
   parallelForEach(objectSources, [&](TpiSource *source) {
 source->remapTpiWithGHashes(&ghashState);
   });

diff  --git a/lld/COFF/PDB.cpp b/lld/COFF/PDB.cpp
index 2ceb4fb98031c..87b6bb55d6101 100644
--- a/lld/COFF/PDB.cpp
+++ b/lld/COFF/PDB.cpp
@@ -296,14 +296,14 @@ static void addGHashTypeInfo(COFFLinkerContext &ctx,
   // Start the TPI or IPI stream header.
   builder.getTpiBuilder().setVersionHeader(pdb::PdbTpiV80);
   builder.getIpiBuilder().setVersionHeader(pdb::PdbTpiV80);
-  for_each(ctx.tpiSourceList, [&](TpiSource *source) {
+  for (TpiSource *source : ctx.tpiSourceList) {
 builder.getTpiBuilder().addTypeRecords(source->mergedTpi.recs,
source->mergedTpi.recSizes,
source->mergedTpi.recHashes);
 builder.getIpiBuilder().addTypeRecords(source->mergedIpi.recs,
source->mergedIpi.recSizes,
source->mergedIpi.recHashes);
-  });
+  }
 }
 
 static void
@@ -1134,7 +1134,8 @@ void PDBLinker::addObjectsToPDB() {
   ScopedTimer t1(ctx.addObjectsTimer);
 
   // Create module descriptors
-  for_each(ctx.objFileInstances, [&](ObjFile *obj) { createModuleDBI(obj); });
+  for (ObjFile *obj : ctx.objFileInstances)
+createModuleDBI(obj);
 
   // Reorder dependency type sources to come first.
   tMerger.sortDependencies();
@@ -1144,9 +1145,10 @@ void PDBLinker::addObjectsToPDB() {
 tMerger.mergeTypesWithGHash();
 
   // Merge dependencies and then regular objects.
-  for_each(tMerger.dependencySources,
-   [&](TpiSource *source) { addDebug(source); });
-  for_each(tMerger.objectSources, [&](TpiSource *source) { addDebug(source); 
});
+  for (TpiSource *source : tMerger.dependencySources)
+addDebug(source);
+  for (TpiSource *source : tMerger.objectSources)
+addDebug(source);
 
   builder.getStringTableBuilder().setStrings(pdbStrTab);
   t1.stop();
@@ -1163,10 +1165,10 @@ void PDBLinker::addObjectsToPDB() {
   t2.stop();
 
   if (config->showSummary) {
-for_each(ctx.tpiSourceList, [&](TpiSource *source) {
+for (TpiSource *source : ctx.tpiSourceList) {
   nbTypeRecords += source->nbTypeRecords;
   nbTypeRecordsBytes += source->nbTypeRecordsBytes;
-});
+}
   }
 }
 

diff  --git a/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp 
b/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp
index cf4f96dbcf6a6..6bcceb6ed08a5 100644
--- a/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp
+++ b/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp
@@ -880,9 +880,8 @@ struct UnrollTransferReadConversion
   void getInsertionIndices(TransferReadOp xferOp,
SmallVector &indices) const {
 if (auto insertOp = getInsertOp(xferOp)) {
-  llvm::for_each(insertOp.getPosition(), [&](Attribute attr) {
+  for (Attribute attr : insertOp.getPosition())
 indices.push_back(attr.dyn_cast().getInt());
-  });
 }
   

[clang-tools-extra] 87d627b - Remove redundant string initialization (NFC)

2022-07-24 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-07-24T12:27:11-07:00
New Revision: 87d627b623eb392610c073e6334782982373959a

URL: 
https://github.com/llvm/llvm-project/commit/87d627b623eb392610c073e6334782982373959a
DIFF: 
https://github.com/llvm/llvm-project/commit/87d627b623eb392610c073e6334782982373959a.diff

LOG: Remove redundant string initialization (NFC)

Identified with readability-redundant-string-init.

Added: 


Modified: 
clang-tools-extra/clangd/refactor/tweaks/ObjCMemberwiseInitializer.cpp
mlir/lib/Pass/Pass.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clangd/refactor/tweaks/ObjCMemberwiseInitializer.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/ObjCMemberwiseInitializer.cpp
index f2f2cf674fa7a..30ff058619550 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/ObjCMemberwiseInitializer.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/ObjCMemberwiseInitializer.cpp
@@ -40,7 +40,7 @@ static std::string getTypeStr(const QualType &OrigT, const 
Decl &D,
   QualType T = OrigT;
   PrintingPolicy Policy(D.getASTContext().getLangOpts());
   Policy.SuppressStrongLifetime = true;
-  std::string Prefix = "";
+  std::string Prefix;
   // If the nullability is specified via a property attribute, use the shorter
   // `nullable` form for the method parameter.
   if (PropertyAttributes & ObjCPropertyAttribute::kind_nullability) {

diff  --git a/mlir/lib/Pass/Pass.cpp b/mlir/lib/Pass/Pass.cpp
index c33d9233474f9..a3deafdc7a79e 100644
--- a/mlir/lib/Pass/Pass.cpp
+++ b/mlir/lib/Pass/Pass.cpp
@@ -90,7 +90,7 @@ struct OpPassManagerImpl {
   : name(name == OpPassManager::getAnyOpAnchorName() ? "" : name.str()),
 initializationGeneration(0), nesting(nesting) {}
   OpPassManagerImpl(OpPassManager::Nesting nesting)
-  : name(""), initializationGeneration(0), nesting(nesting) {}
+  : initializationGeneration(0), nesting(nesting) {}
   OpPassManagerImpl(const OpPassManagerImpl &rhs)
   : name(rhs.name), opName(rhs.opName),
 initializationGeneration(rhs.initializationGeneration),



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 9e88cbc - Use any_of (NFC)

2022-07-24 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-07-24T14:48:11-07:00
New Revision: 9e88cbcc403bdf82f29259ad60ff60a8fc4434a1

URL: 
https://github.com/llvm/llvm-project/commit/9e88cbcc403bdf82f29259ad60ff60a8fc4434a1
DIFF: 
https://github.com/llvm/llvm-project/commit/9e88cbcc403bdf82f29259ad60ff60a8fc4434a1.diff

LOG: Use any_of (NFC)

Added: 


Modified: 
clang/lib/Edit/EditedSource.cpp
clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
llvm/tools/llvm-profdata/llvm-profdata.cpp
llvm/tools/llvm-xray/xray-graph.cpp
mlir/lib/Dialect/Transform/IR/TransformInterfaces.cpp

Removed: 




diff  --git a/clang/lib/Edit/EditedSource.cpp b/clang/lib/Edit/EditedSource.cpp
index ee57660b8c72c..a3386b2489b07 100644
--- a/clang/lib/Edit/EditedSource.cpp
+++ b/clang/lib/Edit/EditedSource.cpp
@@ -84,11 +84,11 @@ bool EditedSource::canInsertInOffset(SourceLocation 
OrigLoc, FileOffset Offs) {
 deconstructMacroArgLoc(OrigLoc, ExpLoc, ArgUse);
 auto I = ExpansionToArgMap.find(ExpLoc);
 if (I != ExpansionToArgMap.end() &&
-find_if(I->second, [&](const MacroArgUse &U) {
+llvm::any_of(I->second, [&](const MacroArgUse &U) {
   return ArgUse.Identifier == U.Identifier &&
  std::tie(ArgUse.ImmediateExpansionLoc, ArgUse.UseLoc) !=
  std::tie(U.ImmediateExpansionLoc, U.UseLoc);
-}) != I->second.end()) {
+})) {
   // Trying to write in a macro argument input that has already been
   // written by a previous commit for another expansion of the same macro
   // argument name. For example:

diff  --git a/clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
index cddf206728b1a..27fd40a441fad 100644
--- a/clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
@@ -182,7 +182,7 @@ class PaddingChecker : public 
Checker> {
   return false;
 };
 
-if (std::any_of(RD->field_begin(), RD->field_end(), IsTrickyField))
+if (llvm::any_of(RD->fields(), IsTrickyField))
   return true;
 return false;
   }

diff  --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp 
b/llvm/tools/llvm-profdata/llvm-profdata.cpp
index 0c23d7c1435f3..3af8f800adcb8 100644
--- a/llvm/tools/llvm-profdata/llvm-profdata.cpp
+++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp
@@ -2200,8 +2200,7 @@ static int showInstrProfile(const std::string &Filename, 
bool ShowCounts,
 Builder.addRecord(Func);
 
 if (ShowCovered) {
-  if (std::any_of(Func.Counts.begin(), Func.Counts.end(),
-  [](uint64_t C) { return C; }))
+  if (llvm::any_of(Func.Counts, [](uint64_t C) { return C; }))
 OS << Func.Name << "\n";
   continue;
 }

diff  --git a/llvm/tools/llvm-xray/xray-graph.cpp 
b/llvm/tools/llvm-xray/xray-graph.cpp
index 39d2c5c153ef1..ff47eb64e9473 100644
--- a/llvm/tools/llvm-xray/xray-graph.cpp
+++ b/llvm/tools/llvm-xray/xray-graph.cpp
@@ -232,10 +232,11 @@ Error GraphRenderer::accountRecord(const XRayRecord 
&Record) {
   if (!DeduceSiblingCalls)
 return make_error("No matching ENTRY record",

make_error_code(errc::invalid_argument));
-  auto Parent = std::find_if(
-  ThreadStack.rbegin(), ThreadStack.rend(),
-  [&](const FunctionAttr &A) { return A.FuncId == Record.FuncId; });
-  if (Parent == ThreadStack.rend())
+  bool FoundParent =
+  llvm::any_of(llvm::reverse(ThreadStack), [&](const FunctionAttr &A) {
+return A.FuncId == Record.FuncId;
+  });
+  if (!FoundParent)
 return make_error(
 "No matching Entry record in stack",
 make_error_code(errc::invalid_argument)); // There is no matching

diff  --git a/mlir/lib/Dialect/Transform/IR/TransformInterfaces.cpp 
b/mlir/lib/Dialect/Transform/IR/TransformInterfaces.cpp
index 8c3dc07cd97ed..265797bc61bf2 100644
--- a/mlir/lib/Dialect/Transform/IR/TransformInterfaces.cpp
+++ b/mlir/lib/Dialect/Transform/IR/TransformInterfaces.cpp
@@ -182,7 +182,7 @@ LogicalResult 
transform::TransformState::checkAndRecordHandleInvalidation(
   return isa(effect.getEffect()) &&
  effect.getValue() == target.get();
 };
-if (llvm::find_if(effects, consumesTarget) != effects.end())
+if (llvm::any_of(effects, consumesTarget))
   recordHandleInvalidation(target);
   }
   return success();



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 3650615 - [clang] Remove unused forward declarations (NFC)

2022-07-24 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-07-24T20:51:06-07:00
New Revision: 3650615fb28aad3730c33cc26d23a6836743e305

URL: 
https://github.com/llvm/llvm-project/commit/3650615fb28aad3730c33cc26d23a6836743e305
DIFF: 
https://github.com/llvm/llvm-project/commit/3650615fb28aad3730c33cc26d23a6836743e305.diff

LOG: [clang] Remove unused forward declarations (NFC)

Added: 


Modified: 
clang/include/clang/Driver/Driver.h
clang/include/clang/Lex/PreprocessingRecord.h
clang/include/clang/Lex/Preprocessor.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
clang/lib/CodeGen/SanitizerMetadata.h
clang/lib/Interpreter/IncrementalExecutor.h

Removed: 




diff  --git a/clang/include/clang/Driver/Driver.h 
b/clang/include/clang/Driver/Driver.h
index 774eac613a100..0781d476ec4a0 100644
--- a/clang/include/clang/Driver/Driver.h
+++ b/clang/include/clang/Driver/Driver.h
@@ -44,9 +44,7 @@ typedef SmallVector InputInfoList;
 
 class Command;
 class Compilation;
-class JobList;
 class JobAction;
-class SanitizerArgs;
 class ToolChain;
 
 /// Describes the kind of LTO mode selected via -f(no-)?lto(=.*)? options.

diff  --git a/clang/include/clang/Lex/PreprocessingRecord.h 
b/clang/include/clang/Lex/PreprocessingRecord.h
index 063929dd8f963..c97ca8628e14b 100644
--- a/clang/include/clang/Lex/PreprocessingRecord.h
+++ b/clang/include/clang/Lex/PreprocessingRecord.h
@@ -49,7 +49,6 @@ void operator delete(void *ptr, clang::PreprocessingRecord 
&PR,
 
 namespace clang {
 
-class FileEntry;
 class IdentifierInfo;
 class MacroInfo;
 class SourceManager;

diff  --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index 8fc24c7310358..79454b5addead 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -67,7 +67,6 @@ namespace clang {
 class CodeCompletionHandler;
 class CommentHandler;
 class DirectoryEntry;
-class DirectoryLookup;
 class EmptylineHandler;
 class ExternalPreprocessorSource;
 class FileEntry;

diff  --git 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
index 1092d1292255d..9927b63407938 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
@@ -55,8 +55,6 @@ template  struct ProgramStateTrait {
   }
 };
 
-class RangeSet;
-
 /// \class ProgramState
 /// ProgramState - This class encapsulates:
 ///

diff  --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
index c9c21fcf230ef..2ae811ee33653 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
@@ -40,7 +40,6 @@ class LabelDecl;
 
 namespace ento {
 
-class BasicValueFactory;
 class CompoundValData;
 class LazyCompoundValData;
 class MemRegion;

diff  --git a/clang/lib/CodeGen/SanitizerMetadata.h 
b/clang/lib/CodeGen/SanitizerMetadata.h
index bcad32ce31df0..f5dd0e503cc00 100644
--- a/clang/lib/CodeGen/SanitizerMetadata.h
+++ b/clang/lib/CodeGen/SanitizerMetadata.h
@@ -20,7 +20,6 @@
 namespace llvm {
 class GlobalVariable;
 class Instruction;
-class MDNode;
 } // namespace llvm
 
 namespace clang {

diff  --git a/clang/lib/Interpreter/IncrementalExecutor.h 
b/clang/lib/Interpreter/IncrementalExecutor.h
index f11ec0aa9e758..5b0f982b62ddf 100644
--- a/clang/lib/Interpreter/IncrementalExecutor.h
+++ b/clang/lib/Interpreter/IncrementalExecutor.h
@@ -21,7 +21,6 @@
 
 namespace llvm {
 class Error;
-class Module;
 namespace orc {
 class LLJIT;
 class ThreadSafeContext;



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] a210f40 - [clang] Remove redundant virtual specifies (NFC)

2022-07-24 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-07-24T22:02:58-07:00
New Revision: a210f404da04ff4db60cdf1a7f4060c82c59c360

URL: 
https://github.com/llvm/llvm-project/commit/a210f404da04ff4db60cdf1a7f4060c82c59c360
DIFF: 
https://github.com/llvm/llvm-project/commit/a210f404da04ff4db60cdf1a7f4060c82c59c360.diff

LOG: [clang] Remove redundant virtual specifies (NFC)

Identified with modernize-use-override.

Added: 


Modified: 
clang/lib/Basic/Targets/CSKY.h
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp

clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp

clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp
clang/tools/clang-import-test/clang-import-test.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/CSKY.h b/clang/lib/Basic/Targets/CSKY.h
index 7e932e7c86b1c..6edd035d9eb84 100644
--- a/clang/lib/Basic/Targets/CSKY.h
+++ b/clang/lib/Basic/Targets/CSKY.h
@@ -71,7 +71,7 @@ class LLVM_LIBRARY_VISIBILITY CSKYTargetInfo : public 
TargetInfo {
 
   bool isValidCPUName(StringRef Name) const override;
 
-  virtual unsigned getMinGlobalAlign(uint64_t) const override;
+  unsigned getMinGlobalAlign(uint64_t) const override;
 
   ArrayRef getTargetBuiltins() const override;
 

diff  --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
index ef673ae41a3dc..5897e5096461a 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -240,7 +240,7 @@ class StdLibraryFunctionsChecker
 ArgNo OtherArgN;
 
   public:
-virtual StringRef getName() const override { return "Comparison"; };
+StringRef getName() const override { return "Comparison"; };
 ComparisonConstraint(ArgNo ArgN, BinaryOperator::Opcode Opcode,
  ArgNo OtherArgN)
 : ValueConstraint(ArgN), Opcode(Opcode), OtherArgN(OtherArgN) {}

diff  --git 
a/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
 
b/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
index 38e69e81d8006..cd91fa9b090c3 100644
--- 
a/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
+++ 
b/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
@@ -57,19 +57,17 @@ class RegularField final : public FieldNode {
 public:
   RegularField(const FieldRegion *FR) : FieldNode(FR) {}
 
-  virtual void printNoteMsg(llvm::raw_ostream &Out) const override {
+  void printNoteMsg(llvm::raw_ostream &Out) const override {
 Out << "uninitialized field ";
   }
 
-  virtual void printPrefix(llvm::raw_ostream &Out) const override {}
+  void printPrefix(llvm::raw_ostream &Out) const override {}
 
-  virtual void printNode(llvm::raw_ostream &Out) const override {
+  void printNode(llvm::raw_ostream &Out) const override {
 Out << getVariableName(getDecl());
   }
 
-  virtual void printSeparator(llvm::raw_ostream &Out) const override {
-Out << '.';
-  }
+  void printSeparator(llvm::raw_ostream &Out) const override { Out << '.'; }
 };
 
 /// Represents that the FieldNode that comes after this is declared in a base
@@ -85,20 +83,20 @@ class BaseClass final : public FieldNode {
 assert(T->getAsCXXRecordDecl());
   }
 
-  virtual void printNoteMsg(llvm::raw_ostream &Out) const override {
+  void printNoteMsg(llvm::raw_ostream &Out) const override {
 llvm_unreachable("This node can never be the final node in the "
  "fieldchain!");
   }
 
-  virtual void printPrefix(llvm::raw_ostream &Out) const override {}
+  void printPrefix(llvm::raw_ostream &Out) const override {}
 
-  virtual void printNode(llvm::raw_ostream &Out) const override {
+  void printNode(llvm::raw_ostream &Out) const override {
 Out << BaseClassT->getAsCXXRecordDecl()->getName() << "::";
   }
 
-  virtual void printSeparator(llvm::raw_ostream &Out) const override {}
+  void printSeparator(llvm::raw_ostream &Out) const override {}
 
-  virtual bool isBase() const override { return true; }
+  bool isBase() const override { return true; }
 };
 
 } // end of anonymous namespace

diff  --git 
a/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp
 
b/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp
index a6e81b3657a2a..f5bd765ff679e 100644
--- 
a/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp
+++ 
b/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp
@@ -34,20 +34,20 @@ class LocField final : public FieldNode {
   LocField(const FieldRegion *FR, const bool IsDereferenced = true)
   : FieldNode(FR), IsDereferenced(IsDereferenced) {}
 
-  virtual void printNoteMsg(llvm::raw_ostrea

[clang] 95a932f - Remove redundaunt override specifiers (NFC)

2022-07-24 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-07-24T22:28:11-07:00
New Revision: 95a932fb15960e66fdc43dc9821685addd5ee44d

URL: 
https://github.com/llvm/llvm-project/commit/95a932fb15960e66fdc43dc9821685addd5ee44d
DIFF: 
https://github.com/llvm/llvm-project/commit/95a932fb15960e66fdc43dc9821685addd5ee44d.diff

LOG: Remove redundaunt override specifiers (NFC)

Identified with modernize-use-override.

Added: 


Modified: 
clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp
clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp
clang-tools-extra/clangd/refactor/tweaks/ExpandMacro.cpp
clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
clang-tools-extra/clangd/refactor/tweaks/MemberwiseConstructor.cpp
clang-tools-extra/clangd/refactor/tweaks/ObjCLocalizeStringLiteral.cpp
clang-tools-extra/clangd/refactor/tweaks/ObjCMemberwiseInitializer.cpp
clang-tools-extra/clangd/refactor/tweaks/RawStringLiteral.cpp
clang-tools-extra/clangd/refactor/tweaks/SpecialMembers.cpp
clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp
clang/include/clang/Frontend/Utils.h
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
clang/include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h
clang/include/clang/Tooling/Refactoring/RefactoringActionRules.h
clang/include/clang/Tooling/Refactoring/RefactoringOptions.h
clang/lib/CodeGen/ABIInfo.h
clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
lld/MachO/SyntheticSections.h
llvm/include/llvm/Analysis/DDG.h
llvm/lib/Target/SystemZ/SystemZRegisterInfo.h
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h 
b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
index def04c917bbc9..d00afecd495de 100644
--- a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
+++ b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
@@ -34,12 +34,11 @@ class RenamerClangTidyCheck : public ClangTidyCheck {
   /// class will do the matching and call the derived class'
   /// getDeclFailureInfo() and getMacroFailureInfo() for determining whether a
   /// given identifier passes or fails the check.
-  void registerMatchers(ast_matchers::MatchFinder *Finder) override final;
-  void
-  check(const ast_matchers::MatchFinder::MatchResult &Result) override final;
+  void registerMatchers(ast_matchers::MatchFinder *Finder) final;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) final;
   void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
-   Preprocessor *ModuleExpanderPP) override final;
-  void onEndOfTranslationUnit() override final;
+   Preprocessor *ModuleExpanderPP) final;
+  void onEndOfTranslationUnit() final;
 
   /// Derived classes that override this function should call this method from
   /// the overridden method.

diff  --git a/clang-tools-extra/clangd/CodeComplete.cpp 
b/clang-tools-extra/clangd/CodeComplete.cpp
index b9998711f52e4..edbb1722ae38e 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -788,7 +788,7 @@ struct CompletionRecorder : public CodeCompleteConsumer {
 
   void ProcessCodeCompleteResults(class Sema &S, CodeCompletionContext Context,
   CodeCompletionResult *InResults,
-  unsigned NumResults) override final {
+  unsigned NumResults) final {
 // Results from recovery mode are generally useless, and the callback after
 // recovery (if any) is usually more interesting. To make sure we handle 
the
 // future callback from sema, we just ignore all callbacks in recovery 
mode,

diff  --git 
a/clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp
index 1383560ad4656..2a34e43f980ba 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp
@@ -23,7 +23,7 @@ namespace {
 ///   void /* entity.name.function.cpp */ f() { int /* variable.cpp */ abc; }
 class AnnotateHighlightings : public Tweak {
 public:
-  const char *id() const override final;
+  const char *id() const final;
 
   bool prepare(const Selection &Inputs) override { return true; }
   Expected apply(const Selection &Inputs) override;

diff  --git a/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
in

[clang-tools-extra] 95a932f - Remove redundaunt override specifiers (NFC)

2022-07-24 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-07-24T22:28:11-07:00
New Revision: 95a932fb15960e66fdc43dc9821685addd5ee44d

URL: 
https://github.com/llvm/llvm-project/commit/95a932fb15960e66fdc43dc9821685addd5ee44d
DIFF: 
https://github.com/llvm/llvm-project/commit/95a932fb15960e66fdc43dc9821685addd5ee44d.diff

LOG: Remove redundaunt override specifiers (NFC)

Identified with modernize-use-override.

Added: 


Modified: 
clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp
clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp
clang-tools-extra/clangd/refactor/tweaks/ExpandMacro.cpp
clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
clang-tools-extra/clangd/refactor/tweaks/MemberwiseConstructor.cpp
clang-tools-extra/clangd/refactor/tweaks/ObjCLocalizeStringLiteral.cpp
clang-tools-extra/clangd/refactor/tweaks/ObjCMemberwiseInitializer.cpp
clang-tools-extra/clangd/refactor/tweaks/RawStringLiteral.cpp
clang-tools-extra/clangd/refactor/tweaks/SpecialMembers.cpp
clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp
clang/include/clang/Frontend/Utils.h
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
clang/include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h
clang/include/clang/Tooling/Refactoring/RefactoringActionRules.h
clang/include/clang/Tooling/Refactoring/RefactoringOptions.h
clang/lib/CodeGen/ABIInfo.h
clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
lld/MachO/SyntheticSections.h
llvm/include/llvm/Analysis/DDG.h
llvm/lib/Target/SystemZ/SystemZRegisterInfo.h
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h 
b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
index def04c917bbc9..d00afecd495de 100644
--- a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
+++ b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
@@ -34,12 +34,11 @@ class RenamerClangTidyCheck : public ClangTidyCheck {
   /// class will do the matching and call the derived class'
   /// getDeclFailureInfo() and getMacroFailureInfo() for determining whether a
   /// given identifier passes or fails the check.
-  void registerMatchers(ast_matchers::MatchFinder *Finder) override final;
-  void
-  check(const ast_matchers::MatchFinder::MatchResult &Result) override final;
+  void registerMatchers(ast_matchers::MatchFinder *Finder) final;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) final;
   void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
-   Preprocessor *ModuleExpanderPP) override final;
-  void onEndOfTranslationUnit() override final;
+   Preprocessor *ModuleExpanderPP) final;
+  void onEndOfTranslationUnit() final;
 
   /// Derived classes that override this function should call this method from
   /// the overridden method.

diff  --git a/clang-tools-extra/clangd/CodeComplete.cpp 
b/clang-tools-extra/clangd/CodeComplete.cpp
index b9998711f52e4..edbb1722ae38e 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -788,7 +788,7 @@ struct CompletionRecorder : public CodeCompleteConsumer {
 
   void ProcessCodeCompleteResults(class Sema &S, CodeCompletionContext Context,
   CodeCompletionResult *InResults,
-  unsigned NumResults) override final {
+  unsigned NumResults) final {
 // Results from recovery mode are generally useless, and the callback after
 // recovery (if any) is usually more interesting. To make sure we handle 
the
 // future callback from sema, we just ignore all callbacks in recovery 
mode,

diff  --git 
a/clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp
index 1383560ad4656..2a34e43f980ba 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp
@@ -23,7 +23,7 @@ namespace {
 ///   void /* entity.name.function.cpp */ f() { int /* variable.cpp */ abc; }
 class AnnotateHighlightings : public Tweak {
 public:
-  const char *id() const override final;
+  const char *id() const final;
 
   bool prepare(const Selection &Inputs) override { return true; }
   Expected apply(const Selection &Inputs) override;

diff  --git a/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
in

[clang] ae002f8 - Use isa instead of dyn_cast (NFC)

2022-07-25 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-07-25T23:00:58-07:00
New Revision: ae002f8bca11bf652fa4d2683c8a627fa77158a8

URL: 
https://github.com/llvm/llvm-project/commit/ae002f8bca11bf652fa4d2683c8a627fa77158a8
DIFF: 
https://github.com/llvm/llvm-project/commit/ae002f8bca11bf652fa4d2683c8a627fa77158a8.diff

LOG: Use isa instead of dyn_cast (NFC)

Added: 


Modified: 
clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
llvm/tools/llvm-dwarfutil/llvm-dwarfutil.cpp
mlir/lib/TableGen/Pattern.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp 
b/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
index 08fac9fb2e698..f12a0ee1fc6db 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -908,7 +908,7 @@ void ExprEngine::VisitCXXNewExpr(const CXXNewExpr *CNE, 
ExplodedNode *Pred,
   // values are properly placed inside the required region, however if an
   // initializer list is used, this doesn't happen automatically.
   auto *Init = CNE->getInitializer();
-  bool isInitList = dyn_cast_or_null(Init);
+  bool isInitList = isa_and_nonnull(Init);
 
   QualType ObjTy =
   isInitList ? Init->getType() : CNE->getType()->getPointeeType();

diff  --git a/llvm/tools/llvm-dwarfutil/llvm-dwarfutil.cpp 
b/llvm/tools/llvm-dwarfutil/llvm-dwarfutil.cpp
index e77c82e0fad9a..c91674426bbb0 100644
--- a/llvm/tools/llvm-dwarfutil/llvm-dwarfutil.cpp
+++ b/llvm/tools/llvm-dwarfutil/llvm-dwarfutil.cpp
@@ -292,7 +292,7 @@ using DebugInfoBits = SmallString<1>;
 static Error addSectionsFromLinkedData(objcopy::ConfigManager &Config,
ObjectFile &InputFile,
DebugInfoBits &LinkedDebugInfoBits) {
-  if (dyn_cast>(&InputFile)) {
+  if (isa>(&InputFile)) {
 Expected> MemFile = ELFObjectFile::create(
 MemoryBufferRef(LinkedDebugInfoBits, ""));
 if (!MemFile)
@@ -300,7 +300,7 @@ static Error 
addSectionsFromLinkedData(objcopy::ConfigManager &Config,
 
 if (Error Err = setConfigToAddNewDebugSections(Config, *MemFile))
   return Err;
-  } else if (dyn_cast>(&InputFile)) {
+  } else if (isa>(&InputFile)) {
 Expected> MemFile = ELFObjectFile::create(
 MemoryBufferRef(LinkedDebugInfoBits, ""));
 if (!MemFile)
@@ -308,7 +308,7 @@ static Error 
addSectionsFromLinkedData(objcopy::ConfigManager &Config,
 
 if (Error Err = setConfigToAddNewDebugSections(Config, *MemFile))
   return Err;
-  } else if (dyn_cast>(&InputFile)) {
+  } else if (isa>(&InputFile)) {
 Expected> MemFile = ELFObjectFile::create(
 MemoryBufferRef(LinkedDebugInfoBits, ""));
 if (!MemFile)
@@ -316,7 +316,7 @@ static Error 
addSectionsFromLinkedData(objcopy::ConfigManager &Config,
 
 if (Error Err = setConfigToAddNewDebugSections(Config, *MemFile))
   return Err;
-  } else if (dyn_cast>(&InputFile)) {
+  } else if (isa>(&InputFile)) {
 Expected> MemFile = ELFObjectFile::create(
 MemoryBufferRef(LinkedDebugInfoBits, ""));
 if (!MemFile)

diff  --git a/mlir/lib/TableGen/Pattern.cpp b/mlir/lib/TableGen/Pattern.cpp
index de767d6d3a6a1..d833de5100cc3 100644
--- a/mlir/lib/TableGen/Pattern.cpp
+++ b/mlir/lib/TableGen/Pattern.cpp
@@ -33,7 +33,7 @@ using llvm::formatv;
 
//===--===//
 
 bool DagLeaf::isUnspecified() const {
-  return dyn_cast_or_null(def);
+  return isa_and_nonnull(def);
 }
 
 bool DagLeaf::isOperandMatcher() const {



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 3f3930a - Remove redundaunt virtual specifiers (NFC)

2022-07-25 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-07-25T23:00:59-07:00
New Revision: 3f3930a451e118e82885a6dd20e3918427b816c2

URL: 
https://github.com/llvm/llvm-project/commit/3f3930a451e118e82885a6dd20e3918427b816c2
DIFF: 
https://github.com/llvm/llvm-project/commit/3f3930a451e118e82885a6dd20e3918427b816c2.diff

LOG: Remove redundaunt virtual specifiers (NFC)

Identified with tidy-modernize-use-override.

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/SharedPtrArrayMismatchCheck.h
clang-tools-extra/clangd/AST.cpp
clang-tools-extra/clangd/support/ThreadsafeFS.cpp
clang/lib/Basic/Targets/X86.h
clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
clang/lib/CodeGen/MicrosoftCXXABI.cpp
clang/lib/Sema/Sema.cpp
clang/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp
clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
llvm/lib/MC/ELFObjectWriter.cpp
llvm/lib/Target/Mips/MipsPreLegalizerCombiner.cpp
llvm/lib/Target/RISCV/RISCVInstrInfo.h
llvm/lib/Target/X86/X86InstrInfo.h
llvm/lib/Transforms/IPO/AttributorAttributes.cpp
llvm/lib/Transforms/InstCombine/InstCombineInternal.h
polly/include/polly/CodeGen/BlockGenerators.h
polly/include/polly/CodeGen/LoopGeneratorsGOMP.h
polly/include/polly/CodeGen/LoopGeneratorsKMP.h
polly/include/polly/ScopPass.h
polly/lib/CodeGen/CodegenCleanup.cpp
polly/lib/Support/DumpFunctionPass.cpp
polly/lib/Support/DumpModulePass.cpp
polly/lib/Transform/DeLICM.cpp
polly/lib/Transform/FlattenSchedule.cpp
polly/lib/Transform/Simplify.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/SharedPtrArrayMismatchCheck.h 
b/clang-tools-extra/clang-tidy/bugprone/SharedPtrArrayMismatchCheck.h
index bb549c5a2c695..95b8e22588a50 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SharedPtrArrayMismatchCheck.h
+++ b/clang-tools-extra/clang-tidy/bugprone/SharedPtrArrayMismatchCheck.h
@@ -28,7 +28,7 @@ class SharedPtrArrayMismatchCheck : public 
SmartPtrArrayMismatchCheck {
   SharedPtrArrayMismatchCheck(StringRef Name, ClangTidyContext *Context);
 
 protected:
-  virtual SmartPtrClassMatcher getSmartPointerClassMatcher() const override;
+  SmartPtrClassMatcher getSmartPointerClassMatcher() const override;
 };
 
 } // namespace bugprone

diff  --git a/clang-tools-extra/clangd/AST.cpp 
b/clang-tools-extra/clangd/AST.cpp
index 0c67c548e6c20..f7d526fab0963 100644
--- a/clang-tools-extra/clangd/AST.cpp
+++ b/clang-tools-extra/clangd/AST.cpp
@@ -368,7 +368,7 @@ std::string printType(const QualType QT, const DeclContext 
&CurContext,
   public:
 PrintCB(const DeclContext *CurContext) : CurContext(CurContext) {}
 virtual ~PrintCB() {}
-virtual bool isScopeVisible(const DeclContext *DC) const override {
+bool isScopeVisible(const DeclContext *DC) const override {
   return DC->Encloses(CurContext);
 }
 

diff  --git a/clang-tools-extra/clangd/support/ThreadsafeFS.cpp 
b/clang-tools-extra/clangd/support/ThreadsafeFS.cpp
index efd7e8cc6079c..dca04762b49a6 100644
--- a/clang-tools-extra/clangd/support/ThreadsafeFS.cpp
+++ b/clang-tools-extra/clangd/support/ThreadsafeFS.cpp
@@ -53,7 +53,7 @@ class VolatileFileSystem : public llvm::vfs::ProxyFileSystem {
   assert(this->Wrapped);
 }
 
-virtual llvm::ErrorOr>
+llvm::ErrorOr>
 getBuffer(const llvm::Twine &Name, int64_t FileSize,
   bool RequiresNullTerminator, bool /*IsVolatile*/) override {
   return Wrapped->getBuffer(Name, FileSize, RequiresNullTerminator,

diff  --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h
index ea98dcf42de65..0affa58b2f4c0 100644
--- a/clang/lib/Basic/Targets/X86.h
+++ b/clang/lib/Basic/Targets/X86.h
@@ -229,12 +229,12 @@ class LLVM_LIBRARY_VISIBILITY X86TargetInfo : public 
TargetInfo {
   bool validateInputSize(const llvm::StringMap &FeatureMap,
  StringRef Constraint, unsigned Size) const override;
 
-  virtual bool
+  bool
   checkCFProtectionReturnSupported(DiagnosticsEngine &Diags) const override {
 return true;
   };
 
-  virtual bool
+  bool
   checkCFProtectionBranchSupported(DiagnosticsEngine &Diags) const override {
 return true;
   };

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.h 
b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
index 1d30c5061743a..ff585efa3fce2 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
@@ -186,17 +186,16 @@ class CGOpenMPRuntimeGPU : public CGOpenMPRuntime {
 
   /// Emit call to void __kmpc_push_proc_bind(ident_t *loc, kmp_int32
   /// global_tid, int proc_bind) to generate code for 'proc_bind' clause.
-  virtual void emitProcBindClause(CodeGenFunction &CGF,
-  llvm::omp::ProcBindKind ProcBind,
-   

[clang] 294a6c3 - [clang] Fix a warning

2024-03-20 Thread Kazu Hirata via cfe-commits

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 &Op) {
 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] [AST] Fix a warning (PR #86690)

2024-03-26 Thread Kazu Hirata via cfe-commits

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 &OS, ArrayRef Args, const 
PrintingPolicy &Policy,
 } 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] [AST] Fix a warning (PR #86690)

2024-03-26 Thread Kazu Hirata via cfe-commits

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)

2024-03-26 Thread Kazu Hirata via cfe-commits

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] Fix printing of templated records. (PR #86339)

2024-03-26 Thread Kazu Hirata via cfe-commits

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) { 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] Fix printing of templated records. (PR #86339)

2024-03-26 Thread Kazu Hirata via cfe-commits

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) { 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) { 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)

2024-03-26 Thread Kazu Hirata via cfe-commits

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 buildbot failure. (PR #86741)

2024-03-26 Thread Kazu Hirata via cfe-commits

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 buildbot failure. (PR #86741)

2024-03-28 Thread Kazu Hirata via cfe-commits

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)

2024-03-28 Thread Kazu Hirata via cfe-commits

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)

2024-03-28 Thread Kazu Hirata via cfe-commits

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-tools-extra] 2699c1d - [clang-tidy] Use StringRef::starts_with (NFC)

2024-01-30 Thread Kazu Hirata via cfe-commits

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] b67ce7e - [clang] Use StringRef::starts_with (NFC)

2024-01-31 Thread Kazu Hirata via cfe-commits

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 &OS, ArrayRef Args, const 
PrintingPolicy &Policy,
 // 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 &Tok) {
   // 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 &FileMgr = 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 &PP = CI.getPreprocessor();



___
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)

2024-02-03 Thread Kazu Hirata via cfe-commits

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] 34fba4f - [Basic] Use StringRef::contains (NFC)

2024-02-03 Thread Kazu Hirata via cfe-commits

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(&C, 1);
   return "%" + llvm::toHex(StringRef(&C, 1));
 }



___
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)

2024-02-04 Thread Kazu Hirata via cfe-commits

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-tools-extra] 92d5f64 - [clang-tidy] Use StringRef::contains (NFC)

2024-02-04 Thread Kazu Hirata via cfe-commits

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] 5404a37 - [Driver] Use StringRef::consume_front (NFC)

2024-01-24 Thread Kazu Hirata via cfe-commits

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 
&Major, unsigned &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, 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 &D,
   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 &Args) {
 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] 196a71e - [Sema] Use StringRef::consume_front (NFC)

2024-01-24 Thread Kazu Hirata via cfe-commits

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 &S, const ParsedAttr 
&AL, 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-tools-extra] 5b2772e - [clangd] Use SmallString::operator std::string (NFC)

2024-01-24 Thread Kazu Hirata via cfe-commits

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 &Ctx, 
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 &FS,

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 &AST, 
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 &AST, 
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 a/clang-tools-extra/clangd/ind

[clang] e6bafbe - [TableGen] Use StringRef::consume_{front, back} (NFC)

2024-01-25 Thread Kazu Hirata via cfe-commits

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 &S = 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 &Text,
   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] 2b00d44 - [clang-tools-extra] Use SmallString::operator std::string (NFC)

2024-01-26 Thread Kazu Hirata via cfe-commits

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 &CDCtx) {
 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 
&CDCtx) {
 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 &SM, 
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 a/clang-tools-extr

[clang] fe35d72 - [Driver] Use StringRef::consume_back (NFC)

2024-01-26 Thread Kazu Hirata via cfe-commits

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 &Args,
 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 &Args,
 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 &D, const 
ArgList &Args,
   auto makeFeature = [&Args](Twine T, bool Enable) -> StringRef {
 const std::string &S = 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] d6ad67d - [clang-tidy] Use StringRef::consume_back (NFC)

2024-01-27 Thread Kazu Hirata via cfe-commits

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] d1427fb - [Edit] Use StringRef::consume_back (NFC)

2024-01-28 Thread Kazu Hirata via cfe-commits

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 &text) {
-  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


  1   2   3   4   5   6   7   8   9   10   >