@@ -385,7 +385,7 @@ static bool isDestExprFix(const MatchFinder::MatchResult &Result,
385
385
386
386
std::string TempTyStr = Dest->getType ().getAsString ();
387
387
StringRef TyStr = TempTyStr;
388
- if (TyStr.startswith (" char" ) || TyStr.startswith (" wchar_t" ))
388
+ if (TyStr.starts_with (" char" ) || TyStr.starts_with (" wchar_t" ))
389
389
return false ;
390
390
391
391
Diag << FixItHint::CreateInsertion (Dest->getBeginLoc (), " (char *)" );
@@ -721,8 +721,8 @@ void NotNullTerminatedResultCheck::registerMatchers(MatchFinder *Finder) {
721
721
722
722
// Try to match with 'wchar_t' based function calls.
723
723
std::string WcharHandlerFuncName =
724
- " ::" + (CC.Name .startswith (" mem" ) ? " w" + CC.Name .str ()
725
- : " wcs" + CC.Name .substr (3 ).str ());
724
+ " ::" + (CC.Name .starts_with (" mem" ) ? " w" + CC.Name .str ()
725
+ : " wcs" + CC.Name .substr (3 ).str ());
726
726
727
727
return allOf (callee (functionDecl (
728
728
hasAnyName (CharHandlerFuncName, WcharHandlerFuncName))),
@@ -820,13 +820,13 @@ void NotNullTerminatedResultCheck::check(
820
820
}
821
821
822
822
StringRef Name = FunctionExpr->getDirectCallee ()->getName ();
823
- if (Name.startswith (" mem" ) || Name.startswith (" wmem" ))
823
+ if (Name.starts_with (" mem" ) || Name.starts_with (" wmem" ))
824
824
memoryHandlerFunctionFix (Name, Result);
825
825
else if (Name == " strerror_s" )
826
826
strerror_sFix (Result);
827
- else if (Name.endswith (" ncmp" ))
827
+ else if (Name.ends_with (" ncmp" ))
828
828
ncmpFix (Name, Result);
829
- else if (Name.endswith (" xfrm" ))
829
+ else if (Name.ends_with (" xfrm" ))
830
830
xfrmFix (Name, Result);
831
831
}
832
832
@@ -835,7 +835,7 @@ void NotNullTerminatedResultCheck::memoryHandlerFunctionFix(
835
835
if (isCorrectGivenLength (Result))
836
836
return ;
837
837
838
- if (Name.endswith (" chr" )) {
838
+ if (Name.ends_with (" chr" )) {
839
839
memchrFix (Name, Result);
840
840
return ;
841
841
}
@@ -849,13 +849,13 @@ void NotNullTerminatedResultCheck::memoryHandlerFunctionFix(
849
849
" the result from calling '%0' is not null-terminated" )
850
850
<< Name;
851
851
852
- if (Name.endswith (" cpy" )) {
852
+ if (Name.ends_with (" cpy" )) {
853
853
memcpyFix (Name, Result, Diag);
854
- } else if (Name.endswith (" cpy_s" )) {
854
+ } else if (Name.ends_with (" cpy_s" )) {
855
855
memcpy_sFix (Name, Result, Diag);
856
- } else if (Name.endswith (" move" )) {
856
+ } else if (Name.ends_with (" move" )) {
857
857
memmoveFix (Name, Result, Diag);
858
- } else if (Name.endswith (" move_s" )) {
858
+ } else if (Name.ends_with (" move_s" )) {
859
859
isDestCapacityFix (Result, Diag);
860
860
lengthArgHandle (LengthHandleKind::Increase, Result, Diag);
861
861
}
0 commit comments