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

17 files changed

+133
-129
lines changed

Diff for: core/clingutils/src/TClingUtils.cxx

+4-1
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

Diff for: core/metacling/src/TClingCallbacks.cxx

+1-1
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,

Diff for: core/metacling/src/TClingClassInfo.cxx

+10-10
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

Diff for: interpreter/cling/include/cling/Interpreter/DynamicLibraryManager.h

+2-1
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
}

Diff for: interpreter/cling/lib/Interpreter/AutoSynthesizer.cpp

+1-1
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
}

Diff for: interpreter/cling/lib/Interpreter/AutoloadCallback.cpp

+5-5
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;

Diff for: interpreter/cling/lib/Interpreter/BackendPasses.cpp

+16-18
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);

Diff for: interpreter/cling/lib/Interpreter/DeclUnloader.cpp

+1-1
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);

Diff for: interpreter/cling/lib/Interpreter/DynamicLookup.cpp

+1-1
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
}

Diff for: interpreter/cling/lib/Interpreter/Interpreter.cpp

+4-4
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

Diff for: interpreter/cling/lib/Interpreter/InvocationOptions.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ InvocationOptions::InvocationOptions(int argc, const char* const* argv) :
234234
case Option::UnknownClass:
235235
case Option::InputClass:
236236
// prune "-" we need to control where it appears when invoking clang
237-
if (!arg->getSpelling().equals("-")) {
237+
if (arg->getSpelling() != "-") {
238238
if (const char* Arg = argv[arg->getIndex()]) {
239239
#ifdef CLING_TRANSLATE_NOSTDINCxx
240240
if (!::strcmp(Arg, "-nostdinc++"))

Diff for: interpreter/cling/lib/Interpreter/LookupHelper.cpp

+34-27
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ namespace cling {
121121
// Compare the contents of the cached buffer and the string we should
122122
// process. If there are hash collisions this assert should trigger
123123
// making it easier to debug.
124-
CacheIsValid = FIDContents.equals(llvm::StringRef(code.str() + "\n"));
124+
CacheIsValid = FIDContents == llvm::StringRef(code.str() + "\n");
125125
assert(CacheIsValid && "Hash collision!");
126126
if (CacheIsValid) {
127127
// We have already included this file once. Reuse the include loc.
@@ -319,35 +319,42 @@ namespace cling {
319319
isunsigned = true;
320320
typeName = StringRef(typeName.data()+9, typeName.size()-9);
321321
}
322-
if (typeName.equals("char")) {
322+
if (typeName == "char") {
323323
if (isunsigned) return Context.UnsignedCharTy;
324324
return Context.SignedCharTy;
325325
}
326-
if (typeName.equals("short")) {
326+
if (typeName == "short") {
327327
if (isunsigned) return Context.UnsignedShortTy;
328328
return Context.ShortTy;
329329
}
330-
if (typeName.equals("int")) {
330+
if (typeName == "int") {
331331
if (isunsigned) return Context.UnsignedIntTy;
332332
return Context.IntTy;
333333
}
334-
if (typeName.equals("long")) {
334+
if (typeName == "long") {
335335
if (isunsigned) return Context.UnsignedLongTy;
336336
return Context.LongTy;
337337
}
338-
if (typeName.equals("long long")) {
338+
if (typeName == "long long") {
339339
if (isunsigned) return Context.UnsignedLongLongTy;
340340
return Context.LongLongTy;
341341
}
342342
if (!issigned && !isunsigned) {
343-
if (typeName.equals("bool")) return Context.BoolTy;
344-
if (typeName.equals("float")) return Context.FloatTy;
345-
if (typeName.equals("double")) return Context.DoubleTy;
346-
if (typeName.equals("long double")) return Context.LongDoubleTy;
347-
348-
if (typeName.equals("wchar_t")) return Context.WCharTy;
349-
if (typeName.equals("char16_t")) return Context.Char16Ty;
350-
if (typeName.equals("char32_t")) return Context.Char32Ty;
343+
if (typeName == "bool")
344+
return Context.BoolTy;
345+
if (typeName == "float")
346+
return Context.FloatTy;
347+
if (typeName == "double")
348+
return Context.DoubleTy;
349+
if (typeName == "long double")
350+
return Context.LongDoubleTy;
351+
352+
if (typeName == "wchar_t")
353+
return Context.WCharTy;
354+
if (typeName == "char16_t")
355+
return Context.Char16Ty;
356+
if (typeName == "char32_t")
357+
return Context.Char32Ty;
351358
}
352359
/* Missing
353360
CanQualType WideCharTy; // Same as WCharTy in C++, integer type in C99.
@@ -1320,12 +1327,12 @@ namespace cling {
13201327
TagDecl *decl = llvm::dyn_cast<TagDecl>(foundDC);
13211328
if (decl) {
13221329
// We have a class or struct or something.
1323-
if (funcName.substr(1).equals(decl->getName())) {
1324-
ParsedType PT;
1325-
QualType QT( decl->getTypeForDecl(), 0 );
1326-
PT.set(QT);
1327-
FuncId.setDestructorName(SourceLocation(),PT,SourceLocation());
1328-
return true;
1330+
if (funcName.substr(1) == decl->getName()) {
1331+
ParsedType PT;
1332+
QualType QT(decl->getTypeForDecl(), 0);
1333+
PT.set(QT);
1334+
FuncId.setDestructorName(SourceLocation(), PT, SourceLocation());
1335+
return true;
13291336
}
13301337
}
13311338
// So it starts with ~ but is not followed by the name of
@@ -1336,14 +1343,14 @@ namespace cling {
13361343
TagDecl *decl = llvm::dyn_cast<TagDecl>(foundDC);
13371344
if (decl) {
13381345
// We have a class or struct or something.
1339-
if (funcName.equals(decl->getName())) {
1340-
ParsedType PT;
1341-
QualType QT( decl->getTypeForDecl(), 0 );
1342-
PT.set(QT);
1343-
FuncId.setConstructorName(PT,SourceLocation(),SourceLocation());
1346+
if (funcName == decl->getName()) {
1347+
ParsedType PT;
1348+
QualType QT(decl->getTypeForDecl(), 0);
1349+
PT.set(QT);
1350+
FuncId.setConstructorName(PT, SourceLocation(), SourceLocation());
13441351
} else {
1345-
IdentifierInfo *TypeInfoII = &PP.getIdentifierTable().get(funcName);
1346-
FuncId.setIdentifier (TypeInfoII, SourceLocation() );
1352+
IdentifierInfo* TypeInfoII = &PP.getIdentifierTable().get(funcName);
1353+
FuncId.setIdentifier(TypeInfoII, SourceLocation());
13471354
}
13481355
return true;
13491356
} else {

Diff for: interpreter/cling/lib/Interpreter/Transaction.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ namespace cling {
7373
for (auto I = decls_begin(), E = decls_end(); I != E; ++I) {
7474
for (auto DI : I->m_DGR) {
7575
if (NamedDecl* ND = dyn_cast<NamedDecl>(DI)) {
76-
if (name.equals(ND->getNameAsString()))
76+
if (name == ND->getNameAsString())
7777
return ND;
7878
}
7979
}
@@ -84,7 +84,7 @@ namespace cling {
8484
if (LinkageSpecDecl* LSD = dyn_cast<LinkageSpecDecl>(DI)) {
8585
for (Decl* DI : LSD->decls()) {
8686
if (NamedDecl* ND = dyn_cast<NamedDecl>(DI)) {
87-
if (name.equals(ND->getNameAsString()))
87+
if (name == ND->getNameAsString())
8888
return ND;
8989
}
9090
}

0 commit comments

Comments
 (0)