Skip to content

Commit 4ff4841

Browse files
committed
[cling][NFC] Use StringRef::operator== instead of StringRef::equals
This was removed in LLVM19 llvm/llvm-project@deffae5 This will reduce the changes needed when upgrading LLVM versions
1 parent 106c735 commit 4ff4841

File tree

17 files changed

+133
-129
lines changed

17 files changed

+133
-129
lines changed

core/clingutils/src/TClingUtils.cxx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5033,7 +5033,10 @@ ROOT::ESTLType ROOT::TMetaUtils::STLKind(const llvm::StringRef type)
50335033
ROOT::kNotSTL
50345034
};
50355035
// kind of stl container
5036-
for(int k=1;stls[k];k++) {if (type.equals(stls[k])) return values[k];}
5036+
for (int k = 1; stls[k]; k++) {
5037+
if (type == stls[k])
5038+
return values[k];
5039+
}
50375040
return ROOT::kNotSTL;
50385041
}
50395042

core/metacling/src/TClingCallbacks.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ bool TClingCallbacks::tryResolveAtRuntimeInternal(LookupResult &R, Scope *S) {
787787
// Prevent redundant declarations for control statements (e.g., for, if, while)
788788
// that have already been annotated.
789789
if (auto annot = Wrapper->getAttr<AnnotateAttr>())
790-
if (annot->getAnnotation().equals("__ResolveAtRuntime") && S->isControlScope())
790+
if (annot->getAnnotation() == "__ResolveAtRuntime" && S->isControlScope())
791791
return false;
792792

793793
VarDecl* Result = VarDecl::Create(C, TU, Loc, Loc, II, C.DependentTy,

core/metacling/src/TClingClassInfo.cxx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,9 @@ const FunctionTemplateDecl *TClingClassInfo::GetFunctionTemplate(const char *fna
261261
const TypedefType *TT = llvm::dyn_cast<TypedefType>(fType);
262262
if (TT) {
263263
llvm::StringRef tname(TT->getDecl()->getName());
264-
if (tname.equals(fname)) {
264+
if (tname == fname) {
265265
const NamedDecl *ndecl = llvm::dyn_cast<NamedDecl>(GetDecl());
266-
if (ndecl && !ndecl->getName().equals(fname)) {
266+
if (ndecl && ndecl->getName() != fname) {
267267
// Constructor name matching the typedef type, use the decl name instead.
268268
return GetFunctionTemplate(ndecl->getName().str().c_str());
269269
}
@@ -308,9 +308,9 @@ TClingMethodInfo TClingClassInfo::GetMethod(const char *fname) const
308308
const TypedefType *TT = llvm::dyn_cast<TypedefType>(fType);
309309
if (TT) {
310310
llvm::StringRef tname(TT->getDecl()->getName());
311-
if (tname.equals(fname)) {
311+
if (tname == fname) {
312312
const NamedDecl *ndecl = llvm::dyn_cast<NamedDecl>(GetDecl());
313-
if (ndecl && !ndecl->getName().equals(fname)) {
313+
if (ndecl && ndecl->getName() != fname) {
314314
// Constructor name matching the typedef type, use the decl name instead.
315315
return GetMethod(ndecl->getName().str().c_str());
316316
}
@@ -359,9 +359,9 @@ TClingMethodInfo TClingClassInfo::GetMethod(const char *fname,
359359
const TypedefType *TT = llvm::dyn_cast<TypedefType>(fType);
360360
if (TT) {
361361
llvm::StringRef tname(TT->getDecl()->getName());
362-
if (tname.equals(fname)) {
362+
if (tname == fname) {
363363
const NamedDecl *ndecl = llvm::dyn_cast<NamedDecl>(GetDecl());
364-
if (ndecl && !ndecl->getName().equals(fname)) {
364+
if (ndecl && ndecl->getName() != fname) {
365365
// Constructor name matching the typedef type, use the decl name instead.
366366
return GetMethod(ndecl->getName().str().c_str(),proto,
367367
objectIsConst,poffset,
@@ -453,9 +453,9 @@ TClingMethodInfo TClingClassInfo::GetMethod(const char *fname,
453453
const TypedefType *TT = llvm::dyn_cast<TypedefType>(fType);
454454
if (TT) {
455455
llvm::StringRef tname(TT->getDecl()->getName());
456-
if (tname.equals(fname)) {
456+
if (tname == fname) {
457457
const NamedDecl *ndecl = llvm::dyn_cast<NamedDecl>(GetDecl());
458-
if (ndecl && !ndecl->getName().equals(fname)) {
458+
if (ndecl && ndecl->getName() != fname) {
459459
// Constructor name matching the typedef type, use the decl name instead.
460460
return GetMethod(ndecl->getName().str().c_str(),proto,objectIsConst,poffset,
461461
mode,imode);
@@ -519,9 +519,9 @@ TClingMethodInfo TClingClassInfo::GetMethodWithArgs(const char *fname,
519519
const TypedefType *TT = llvm::dyn_cast<TypedefType>(fType);
520520
if (TT) {
521521
llvm::StringRef tname(TT->getDecl()->getName());
522-
if (tname.equals(fname)) {
522+
if (tname == fname) {
523523
const NamedDecl *ndecl = llvm::dyn_cast<NamedDecl>(GetDecl());
524-
if (ndecl && !ndecl->getName().equals(fname)) {
524+
if (ndecl && ndecl->getName() != fname) {
525525
// Constructor name matching the typedef type, use the decl name instead.
526526
return GetMethod(ndecl->getName().str().c_str(),arglist,
527527
objectIsConst,poffset

interpreter/cling/include/cling/Interpreter/DynamicLibraryManager.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ namespace cling {
124124
bool prepend = false) {
125125
if (!dir.empty()) {
126126
for (auto & item : m_SearchPaths)
127-
if (dir.equals(item.Path)) return;
127+
if (dir == item.Path)
128+
return;
128129
auto pos = prepend ? m_SearchPaths.begin() : m_SearchPaths.end();
129130
m_SearchPaths.insert(pos, SearchPathInfo{dir.str(), isUser});
130131
}

interpreter/cling/lib/Interpreter/AutoSynthesizer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ namespace cling {
8282
bool VisitDeclRefExpr(DeclRefExpr* DRE) {
8383
const Decl* D = DRE->getDecl();
8484
if (const AnnotateAttr* A = D->getAttr<AnnotateAttr>())
85-
if (A->getAnnotation().equals("__Auto")) {
85+
if (A->getAnnotation() == "__Auto") {
8686
m_FoundDRE = DRE;
8787
return false; // we abort on the first found candidate.
8888
}

interpreter/cling/lib/Interpreter/AutoloadCallback.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ namespace cling {
116116
ConstSearchDirIterator* CurDir = nullptr;
117117
bool needCacheUpdate = false;
118118

119-
if (FileName.equals(m_PrevFileName.first))
119+
if (FileName == m_PrevFileName.first)
120120
FE = m_PrevFE.first;
121-
else if (FileName.equals(m_PrevFileName.second))
121+
else if (FileName == m_PrevFileName.second)
122122
FE = m_PrevFE.second;
123123
else if (auto FERef = m_PP->LookupFile(fileNameLoc, FileName, isAngled,
124124
FromDir, FromFile, CurDir,
@@ -374,9 +374,9 @@ namespace cling {
374374
if (isa<EmptyDecl>(D))
375375
continue;
376376
else if (auto VD = dyn_cast<VarDecl>(D)) {
377-
HaveAutoLoadingMapMarker
378-
= VD->hasExternalStorage() && VD->getIdentifier()
379-
&& VD->getName().equals("__Cling_AutoLoading_Map");
377+
HaveAutoLoadingMapMarker = VD->hasExternalStorage() &&
378+
VD->getIdentifier() &&
379+
VD->getName() == "__Cling_AutoLoading_Map";
380380
if (!HaveAutoLoadingMapMarker)
381381
return;
382382
break;

interpreter/cling/lib/Interpreter/BackendPasses.cpp

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,8 @@ namespace {
307307
if (!GV.hasName())
308308
return false;
309309

310-
if (GV.getName().equals("__cuda_fatbin_wrapper") ||
311-
GV.getName().equals("__cuda_gpubin_handle")) {
310+
if (GV.getName() == "__cuda_fatbin_wrapper" ||
311+
GV.getName() == "__cuda_gpubin_handle") {
312312
GV.setName(add_module_suffix(GV.getName(), ModuleName));
313313
return true;
314314
}
@@ -318,9 +318,9 @@ namespace {
318318

319319
// make CUDA specific functions unique
320320
bool runOnFunction(Function& F, const StringRef ModuleName) {
321-
if (F.hasName() && (F.getName().equals("__cuda_module_ctor") ||
322-
F.getName().equals("__cuda_module_dtor") ||
323-
F.getName().equals("__cuda_register_globals"))) {
321+
if (F.hasName() && (F.getName() == "__cuda_module_ctor" ||
322+
F.getName() == "__cuda_module_dtor" ||
323+
F.getName() == "__cuda_register_globals")) {
324324
F.setName(add_module_suffix(F.getName(), ModuleName));
325325
return true;
326326
}
@@ -486,25 +486,23 @@ void BackendPasses::CreatePasses(int OptLevel, llvm::ModulePassManager& MPM,
486486

487487
// Register a callback for disabling all other inliner passes.
488488
PIC.registerShouldRunOptionalPassCallback([](StringRef P, Any) {
489-
if (P.equals("ModuleInlinerWrapperPass") ||
490-
P.equals("InlineAdvisorAnalysisPrinterPass") ||
491-
P.equals("PartialInlinerPass") || P.equals("buildInlinerPipeline") ||
492-
P.equals("ModuleInlinerPass") || P.equals("InlinerPass") ||
493-
P.equals("InlineAdvisorAnalysis") ||
494-
P.equals("PartiallyInlineLibCallsPass") ||
495-
P.equals("RelLookupTableConverterPass") ||
496-
P.equals("InlineCostAnnotationPrinterPass") ||
497-
P.equals("InlineSizeEstimatorAnalysisPrinterPass") ||
498-
P.equals("InlineSizeEstimatorAnalysis"))
489+
if (P == "ModuleInlinerWrapperPass" ||
490+
P == "InlineAdvisorAnalysisPrinterPass" ||
491+
P == "PartialInlinerPass" || P == "buildInlinerPipeline" ||
492+
P == "ModuleInlinerPass" || P == "InlinerPass" ||
493+
P == "InlineAdvisorAnalysis" || P == "PartiallyInlineLibCallsPass" ||
494+
P == "RelLookupTableConverterPass" ||
495+
P == "InlineCostAnnotationPrinterPass" ||
496+
P == "InlineSizeEstimatorAnalysisPrinterPass" ||
497+
P == "InlineSizeEstimatorAnalysis")
499498
return false;
500499

501500
return true;
502501
});
503502
} else {
504503
// Register a callback for disabling RelLookupTableConverterPass.
505-
PIC.registerShouldRunOptionalPassCallback([](StringRef P, Any) {
506-
return !P.equals("RelLookupTableConverterPass");
507-
});
504+
PIC.registerShouldRunOptionalPassCallback(
505+
[](StringRef P, Any) { return P != "RelLookupTableConverterPass"; });
508506
}
509507

510508
SI.registerCallbacks(PIC, &MAM);

interpreter/cling/lib/Interpreter/DeclUnloader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ namespace {
206206
continue;
207207

208208
// Required by ::DwarfEHPrepare::InsertUnwindResumeCalls (in the JIT)
209-
if ((*I)->getName().equals("_Unwind_Resume"))
209+
if ((*I)->getName() == "_Unwind_Resume")
210210
continue;
211211

212212
m_CodeGen->forgetGlobal(*I);

interpreter/cling/lib/Interpreter/DynamicLookup.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,7 @@ namespace cling {
910910
bool EvaluateTSynthesizer::ShouldVisit(FunctionDecl* D) {
911911
// FIXME: Here we should have our custom attribute.
912912
if (AnnotateAttr* A = D->getAttr<AnnotateAttr>())
913-
if (A->getAnnotation().equals("__ResolveAtRuntime"))
913+
if (A->getAnnotation() == "__ResolveAtRuntime")
914914
return true;
915915
return false;
916916
}

interpreter/cling/lib/Interpreter/Interpreter.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ namespace cling {
672672
llvm::raw_ostream &where = cling::log();
673673
// `.stats decl' and `.stats asttree FILTER' cause deserialization; force transaction
674674
PushTransactionRAII RAII(this);
675-
if (what.equals("asttree")) {
675+
if (what == "asttree") {
676676
std::unique_ptr<clang::ASTConsumer> printer =
677677
clang::CreateASTDumper(nullptr /*Dump to stdout.*/,
678678
filter, true /*DumpDecls*/,
@@ -681,11 +681,11 @@ namespace cling {
681681
false /*DumpDeclTypes*/,
682682
ADOF_Default /*DumpFormat*/);
683683
printer->HandleTranslationUnit(getSema().getASTContext());
684-
} else if (what.equals("ast"))
684+
} else if (what == "ast")
685685
getSema().getASTContext().PrintStats();
686-
else if (what.equals("decl"))
686+
else if (what == "decl")
687687
ClangInternalState::printLookupTables(where, getSema().getASTContext());
688-
else if (what.equals("undo"))
688+
else if (what == "undo")
689689
m_IncrParser->printTransactionStructure();
690690
}
691691

0 commit comments

Comments
 (0)