Skip to content

Commit bb6df08

Browse files
[llvm] Use StringRef::operator== instead of StringRef::equals (NFC) (#91441)
I'm planning to remove StringRef::equals in favor of StringRef::operator==. - StringRef::operator==/!= outnumber StringRef::equals by a factor of 70 under llvm/ in terms of their usage. - The elimination of StringRef::equals brings StringRef closer to std::string_view, which has operator== but not equals. - S == "foo" is more readable than S.equals("foo"), especially for !Long.Expression.equals("str") vs Long.Expression != "str".
1 parent 46435ac commit bb6df08

34 files changed

+79
-80
lines changed

llvm/include/llvm/ADT/SmallString.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class SmallString : public SmallVector<char, InternalLen> {
8989

9090
/// Check for string equality. This is more efficient than compare() when
9191
/// the relative ordering of inequal strings isn't needed.
92-
[[nodiscard]] bool equals(StringRef RHS) const { return str().equals(RHS); }
92+
[[nodiscard]] bool equals(StringRef RHS) const { return str() == RHS; }
9393

9494
/// Check for string equality, ignoring case.
9595
[[nodiscard]] bool equals_insensitive(StringRef RHS) const {

llvm/lib/Bitcode/Reader/BitcodeReader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6896,7 +6896,7 @@ Error BitcodeReader::materialize(GlobalValue *GV) {
68966896
MDString *MDS = cast<MDString>(MD->getOperand(0));
68976897
StringRef ProfName = MDS->getString();
68986898
// Check consistency of !prof branch_weights metadata.
6899-
if (!ProfName.equals("branch_weights"))
6899+
if (ProfName != "branch_weights")
69006900
continue;
69016901
unsigned ExpectedNumOperands = 0;
69026902
if (BranchInst *BI = dyn_cast<BranchInst>(&I))

llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ void RuntimeDyldELF::setMipsABI(const ObjectFile &Obj) {
659659
IsMipsO32ABI = AbiVariant & ELF::EF_MIPS_ABI_O32;
660660
IsMipsN32ABI = AbiVariant & ELF::EF_MIPS_ABI2;
661661
}
662-
IsMipsN64ABI = Obj.getFileFormatName().equals("elf64-mips");
662+
IsMipsN64ABI = Obj.getFileFormatName() == "elf64-mips";
663663
}
664664

665665
// Return the .TOC. section and offset.

llvm/lib/FileCheck/FileCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ Expected<NumericVariable *> Pattern::parseNumericVariableDefinition(
374374
Expected<std::unique_ptr<NumericVariableUse>> Pattern::parseNumericVariableUse(
375375
StringRef Name, bool IsPseudo, std::optional<size_t> LineNumber,
376376
FileCheckPatternContext *Context, const SourceMgr &SM) {
377-
if (IsPseudo && !Name.equals("@LINE"))
377+
if (IsPseudo && Name != "@LINE")
378378
return ErrorDiagnostic::get(
379379
SM, Name, "invalid pseudo numeric variable '" + Name + "'");
380380

llvm/lib/FuzzMutate/FuzzerCLI.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ void llvm::parseFuzzerCLOpts(int ArgC, char *ArgV[]) {
2121

2222
int I = 1;
2323
while (I < ArgC)
24-
if (StringRef(ArgV[I++]).equals("-ignore_remaining_args=1"))
24+
if (StringRef(ArgV[I++]) == "-ignore_remaining_args=1")
2525
break;
2626
while (I < ArgC)
2727
CLArgs.push_back(ArgV[I++]);
@@ -39,7 +39,7 @@ void llvm::handleExecNameEncodedBEOpts(StringRef ExecName) {
3939
SmallVector<StringRef, 4> Opts;
4040
NameAndArgs.second.split(Opts, '-');
4141
for (StringRef Opt : Opts) {
42-
if (Opt.equals("gisel")) {
42+
if (Opt == "gisel") {
4343
Args.push_back("-global-isel");
4444
// For now we default GlobalISel to -O0
4545
Args.push_back("-O0");
@@ -151,7 +151,7 @@ int llvm::runFuzzerOnInputs(int ArgC, char *ArgV[], FuzzerTestFun TestOne,
151151
for (int I = 1; I < ArgC; ++I) {
152152
StringRef Arg(ArgV[I]);
153153
if (Arg.starts_with("-")) {
154-
if (Arg.equals("-ignore_remaining_args=1"))
154+
if (Arg == "-ignore_remaining_args=1")
155155
break;
156156
continue;
157157
}

llvm/lib/LTO/LTOModule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ bool LTOModule::hasCtorDtor() const {
694694
if (auto *GV = dyn_cast_if_present<GlobalValue *>(Sym)) {
695695
StringRef Name = GV->getName();
696696
if (Name.consume_front("llvm.global_")) {
697-
if (Name.equals("ctors") || Name.equals("dtors"))
697+
if (Name == "ctors" || Name == "dtors")
698698
return true;
699699
}
700700
}

llvm/lib/MC/MCAsmStreamer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ void MCAsmStreamer::emitRawComment(const Twine &T, bool TabPrefix) {
468468

469469
void MCAsmStreamer::addExplicitComment(const Twine &T) {
470470
StringRef c = T.getSingleStringRef();
471-
if (c.equals(StringRef(MAI->getSeparatorString())))
471+
if (c == MAI->getSeparatorString())
472472
return;
473473
if (c.starts_with(StringRef("//"))) {
474474
ExplicitCommentToEmit.append("\t");

llvm/lib/MC/MCParser/AsmParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4543,7 +4543,7 @@ bool AsmParser::parseDirectiveMacro(SMLoc DirectiveLoc) {
45434543

45444544
// Emit an error if two (or more) named parameters share the same name
45454545
for (const MCAsmMacroParameter& CurrParam : Parameters)
4546-
if (CurrParam.Name.equals(Parameter.Name))
4546+
if (CurrParam.Name == Parameter.Name)
45474547
return TokError("macro '" + Name + "' has multiple parameters"
45484548
" named '" + Parameter.Name + "'");
45494549

llvm/lib/MC/MCParser/DarwinAsmParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ bool DarwinAsmParser::parseDirectiveSection(StringRef, SMLoc) {
705705
.Case("__datacoal_nt", "__data")
706706
.Default(Section);
707707

708-
if (!Section.equals(NonCoalSection)) {
708+
if (Section != NonCoalSection) {
709709
StringRef SectionVal(Loc.getPointer());
710710
size_t B = SectionVal.find(',') + 1, E = SectionVal.find(',', B);
711711
SMLoc BLoc = SMLoc::getFromPointer(SectionVal.data() + B);

llvm/lib/MC/MCSymbolXCOFF.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ using namespace llvm;
1313
MCSectionXCOFF *MCSymbolXCOFF::getRepresentedCsect() const {
1414
assert(RepresentedCsect &&
1515
"Trying to get csect representation of this symbol but none was set.");
16-
assert(getSymbolTableName().equals(RepresentedCsect->getSymbolTableName()) &&
16+
assert(getSymbolTableName() == RepresentedCsect->getSymbolTableName() &&
1717
"SymbolTableNames need to be the same for this symbol and its csect "
1818
"representation.");
1919
return RepresentedCsect;
@@ -24,7 +24,7 @@ void MCSymbolXCOFF::setRepresentedCsect(MCSectionXCOFF *C) {
2424
assert((!RepresentedCsect || RepresentedCsect == C) &&
2525
"Trying to set a csect that doesn't match the one that this symbol is "
2626
"already mapped to.");
27-
assert(getSymbolTableName().equals(C->getSymbolTableName()) &&
27+
assert(getSymbolTableName() == C->getSymbolTableName() &&
2828
"SymbolTableNames need to be the same for this symbol and its csect "
2929
"representation.");
3030
RepresentedCsect = C;

llvm/lib/Object/Archive.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,11 +269,11 @@ Expected<StringRef> ArchiveMemberHeader::getName(uint64_t Size) const {
269269
return Name;
270270
// System libraries from the Windows SDK for Windows 11 contain this symbol.
271271
// It looks like a CFG guard: we just skip it for now.
272-
if (Name.equals("/<XFGHASHMAP>/"))
272+
if (Name == "/<XFGHASHMAP>/")
273273
return Name;
274274
// Some libraries (e.g., arm64rt.lib) from the Windows WDK
275275
// (version 10.0.22000.0) contain this undocumented special member.
276-
if (Name.equals("/<ECSYMBOLS>/"))
276+
if (Name == "/<ECSYMBOLS>/")
277277
return Name;
278278
// It's a long name.
279279
// Get the string table offset.

llvm/lib/Object/MachOObjectFile.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ static Error parseSegmentLoadCommand(
399399
return malformedError("load command " + Twine(LoadCommandIndex) +
400400
" filesize field in " + CmdName +
401401
" greater than vmsize field");
402-
IsPageZeroSegment |= StringRef("__PAGEZERO").equals(S.segname);
402+
IsPageZeroSegment |= StringRef("__PAGEZERO") == S.segname;
403403
} else
404404
return SegOrErr.takeError();
405405

@@ -4364,7 +4364,7 @@ BindRebaseSegInfo::BindRebaseSegInfo(const object::MachOObjectFile *Obj) {
43644364
Info.Size = Section.getSize();
43654365
Info.SegmentName =
43664366
Obj->getSectionFinalSegmentName(Section.getRawDataRefImpl());
4367-
if (!Info.SegmentName.equals(CurSegName)) {
4367+
if (Info.SegmentName != CurSegName) {
43684368
++CurSegIndex;
43694369
CurSegName = Info.SegmentName;
43704370
CurSegAddress = Info.Address;

llvm/lib/Object/OffloadBinary.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ bool object::areTargetsCompatible(const OffloadFile::TargetID &LHS,
359359
return false;
360360

361361
// If the architecture is "all" we assume it is always compatible.
362-
if (LHS.second.equals("generic") || RHS.second.equals("generic"))
362+
if (LHS.second == "generic" || RHS.second == "generic")
363363
return true;
364364

365365
// Only The AMDGPU target requires additional checks.

llvm/lib/ObjectYAML/COFFEmitter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,9 +359,9 @@ static uint32_t initializeOptionalHeader(COFFParser &CP, uint16_t Magic,
359359
SizeOfInitializedData += S.Header.SizeOfRawData;
360360
if (S.Header.Characteristics & COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA)
361361
SizeOfUninitializedData += S.Header.SizeOfRawData;
362-
if (S.Name.equals(".text"))
362+
if (S.Name == ".text")
363363
Header->BaseOfCode = S.Header.VirtualAddress; // RVA
364-
else if (S.Name.equals(".data"))
364+
else if (S.Name == ".data")
365365
BaseOfData = S.Header.VirtualAddress; // RVA
366366
if (S.Header.VirtualAddress)
367367
SizeOfImage += alignTo(S.Header.VirtualSize, Header->SectionAlignment);

llvm/lib/Passes/StandardInstrumentations.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -822,8 +822,7 @@ PrintIRInstrumentation::PassRunDescriptor
822822
PrintIRInstrumentation::popPassRunDescriptor(StringRef PassID) {
823823
assert(!PassRunDescriptorStack.empty() && "empty PassRunDescriptorStack");
824824
PassRunDescriptor Descriptor = PassRunDescriptorStack.pop_back_val();
825-
assert(Descriptor.PassID.equals(PassID) &&
826-
"malformed PassRunDescriptorStack");
825+
assert(Descriptor.PassID == PassID && "malformed PassRunDescriptorStack");
827826
return Descriptor;
828827
}
829828

llvm/lib/ProfileData/GCOV.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ std::string Context::getCoveragePath(StringRef filename,
678678
return std::string(filename);
679679

680680
std::string CoveragePath;
681-
if (options.LongFileNames && !filename.equals(mainFilename))
681+
if (options.LongFileNames && filename != mainFilename)
682682
CoveragePath =
683683
mangleCoveragePath(mainFilename, options.PreservePaths) + "##";
684684
CoveragePath += mangleCoveragePath(filename, options.PreservePaths);

llvm/lib/ProfileData/InstrProf.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1283,7 +1283,7 @@ MDNode *mayHaveValueProfileOfKind(const Instruction &Inst,
12831283
return nullptr;
12841284

12851285
MDString *Tag = cast<MDString>(MD->getOperand(0));
1286-
if (!Tag || !Tag->getString().equals("VP"))
1286+
if (!Tag || Tag->getString() != "VP")
12871287
return nullptr;
12881288

12891289
// Now check kind:

llvm/lib/ProfileData/MemProfReader.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ bool isRuntimePath(const StringRef Path) {
164164
const StringRef Filename = llvm::sys::path::filename(Path);
165165
// This list should be updated in case new files with additional interceptors
166166
// are added to the memprof runtime.
167-
return Filename.equals("memprof_malloc_linux.cpp") ||
168-
Filename.equals("memprof_interceptors.cpp") ||
169-
Filename.equals("memprof_new_delete.cpp");
167+
return Filename == "memprof_malloc_linux.cpp" ||
168+
Filename == "memprof_interceptors.cpp" ||
169+
Filename == "memprof_new_delete.cpp";
170170
}
171171

172172
std::string getBuildIdString(const SegmentEntry &Entry) {

llvm/lib/Support/VirtualFileSystem.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1725,7 +1725,7 @@ class llvm::vfs::RedirectingFileSystemParser {
17251725
RedirectingFileSystem::Entry *ParentEntry = nullptr) {
17261726
if (!ParentEntry) { // Look for a existent root
17271727
for (const auto &Root : FS->Roots) {
1728-
if (Name.equals(Root->getName())) {
1728+
if (Name == Root->getName()) {
17291729
ParentEntry = Root.get();
17301730
return ParentEntry;
17311731
}
@@ -1736,7 +1736,7 @@ class llvm::vfs::RedirectingFileSystemParser {
17361736
llvm::make_range(DE->contents_begin(), DE->contents_end())) {
17371737
auto *DirContent =
17381738
dyn_cast<RedirectingFileSystem::DirectoryEntry>(Content.get());
1739-
if (DirContent && Name.equals(Content->getName()))
1739+
if (DirContent && Name == Content->getName())
17401740
return DirContent;
17411741
}
17421742
}

llvm/lib/TargetParser/ARMTargetParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ StringRef ARM::getARMCPUForArch(const llvm::Triple &Triple, StringRef MArch) {
610610
return StringRef();
611611

612612
StringRef CPU = llvm::ARM::getDefaultCPU(MArch);
613-
if (!CPU.empty() && !CPU.equals("invalid"))
613+
if (!CPU.empty() && CPU != "invalid")
614614
return CPU;
615615

616616
// If no specific architecture version is requested, return the minimum CPU

llvm/lib/TargetParser/Triple.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,14 +373,14 @@ StringRef Triple::getObjectFormatTypeName(ObjectFormatType Kind) {
373373
}
374374

375375
static Triple::ArchType parseBPFArch(StringRef ArchName) {
376-
if (ArchName.equals("bpf")) {
376+
if (ArchName == "bpf") {
377377
if (sys::IsLittleEndianHost)
378378
return Triple::bpfel;
379379
else
380380
return Triple::bpfeb;
381-
} else if (ArchName.equals("bpf_be") || ArchName.equals("bpfeb")) {
381+
} else if (ArchName == "bpf_be" || ArchName == "bpfeb") {
382382
return Triple::bpfeb;
383-
} else if (ArchName.equals("bpf_le") || ArchName.equals("bpfel")) {
383+
} else if (ArchName == "bpf_le" || ArchName == "bpfel") {
384384
return Triple::bpfel;
385385
} else {
386386
return Triple::UnknownArch;

llvm/tools/dsymutil/DwarfLinkerForBinary.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ bool DwarfLinkerForBinary::linkImpl(
705705
} else {
706706
// Try and emit more helpful warnings by applying some heuristics.
707707
StringRef ObjFile = ContainerName;
708-
bool IsClangModule = sys::path::extension(Path).equals(".pcm");
708+
bool IsClangModule = sys::path::extension(Path) == ".pcm";
709709
bool IsArchive = ObjFile.ends_with(")");
710710

711711
if (IsClangModule) {

llvm/tools/llvm-dwarfdump/Statistics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ static std::string constructDieID(DWARFDie Die,
229229
<< Die.getName(DINameKind::LinkageName);
230230

231231
// Prefix + Name is enough for local variables and parameters.
232-
if (!Prefix.empty() && !Prefix.equals("g"))
232+
if (!Prefix.empty() && Prefix != "g")
233233
return ID.str();
234234

235235
auto DeclFile = Die.findRecursively(dwarf::DW_AT_decl_file);

llvm/tools/llvm-extract/llvm-extract.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ int main(int argc, char **argv) {
357357
// The function has been materialized, so add its matching basic blocks
358358
// to the block extractor list, or fail if a name is not found.
359359
auto Res = llvm::find_if(*P.first, [&](const BasicBlock &BB) {
360-
return BB.getName().equals(BBName);
360+
return BB.getName() == BBName;
361361
});
362362
if (Res == P.first->end()) {
363363
errs() << argv[0] << ": function " << P.first->getName()

llvm/tools/llvm-objdump/MachODump.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2148,7 +2148,7 @@ static void ProcessMachO(StringRef Name, MachOObjectFile *MachOOF,
21482148
else
21492149
consumeError(NameOrErr.takeError());
21502150

2151-
if (SectName.equals("__text")) {
2151+
if (SectName == "__text") {
21522152
DataRefImpl Ref = Section.getRawDataRefImpl();
21532153
StringRef SegName = MachOOF->getSectionFinalSegmentName(Ref);
21542154
DisassembleMachO(FileName, MachOOF, SegName, SectName);

llvm/tools/llvm-xray/xray-graph-diff.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,14 +381,14 @@ void GraphDiffRenderer::exportGraphAsDOT(raw_ostream &OS, StatType EdgeLabel,
381381
R"(color="{5}" labelfontcolor="{5}" penwidth={6}])"
382382
"\n",
383383
VertexNo[HeadId], VertexNo[TailId],
384-
(HeadId.equals("")) ? static_cast<StringRef>("F0") : HeadId,
384+
HeadId.empty() ? static_cast<StringRef>("F0") : HeadId,
385385
TailId, getLabel(E, EdgeLabel), getColor(E, G, H, EdgeColor),
386386
getLineWidth(E, EdgeColor));
387387
}
388388

389389
for (const auto &V : G.vertices()) {
390390
const auto &VertexId = V.first;
391-
if (VertexId.equals("")) {
391+
if (VertexId.empty()) {
392392
OS << formatv(R"(F{0} [label="F0"])"
393393
"\n",
394394
VertexNo[VertexId]);

llvm/tools/llvm-yaml-numeric-parser-fuzzer/yaml-numeric-parser-fuzzer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ inline bool isNumericRegex(llvm::StringRef S) {
1818
static llvm::Regex Float(
1919
"^[-+]?(\\.[0-9]+|[0-9]+(\\.[0-9]*)?)([eE][-+]?[0-9]+)?$");
2020

21-
if (S.equals(".nan") || S.equals(".NaN") || S.equals(".NAN"))
21+
if (S == ".nan" || S == ".NaN" || S == ".NAN")
2222
return true;
2323

2424
if (Infinity.match(S))

llvm/unittests/ADT/StringRefTest.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,7 @@ TEST(StringRefTest, AllocatorCopy) {
998998
// allocator.
999999
StringRef StrEmpty = "";
10001000
StringRef StrEmptyc = StrEmpty.copy(Alloc);
1001-
EXPECT_TRUE(StrEmpty.equals(StrEmptyc));
1001+
EXPECT_TRUE(StrEmpty == StrEmptyc);
10021002
EXPECT_EQ(StrEmptyc.data(), nullptr);
10031003
EXPECT_EQ(StrEmptyc.size(), 0u);
10041004
EXPECT_EQ(Alloc.getTotalMemory(), 0u);
@@ -1007,9 +1007,9 @@ TEST(StringRefTest, AllocatorCopy) {
10071007
StringRef Str2 = "bye";
10081008
StringRef Str1c = Str1.copy(Alloc);
10091009
StringRef Str2c = Str2.copy(Alloc);
1010-
EXPECT_TRUE(Str1.equals(Str1c));
1010+
EXPECT_TRUE(Str1 == Str1c);
10111011
EXPECT_NE(Str1.data(), Str1c.data());
1012-
EXPECT_TRUE(Str2.equals(Str2c));
1012+
EXPECT_TRUE(Str2 == Str2c);
10131013
EXPECT_NE(Str2.data(), Str2c.data());
10141014
}
10151015

llvm/unittests/IR/VerifierTest.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -173,27 +173,27 @@ TEST(VerifierTest, CrossModuleRef) {
173173
std::string Error;
174174
raw_string_ostream ErrorOS(Error);
175175
EXPECT_TRUE(verifyModule(M2, &ErrorOS));
176-
EXPECT_TRUE(StringRef(ErrorOS.str())
177-
.equals("Global is referenced in a different module!\n"
178-
"ptr @foo2\n"
179-
"; ModuleID = 'M2'\n"
180-
" %call = call i32 @foo2()\n"
181-
"ptr @foo1\n"
182-
"; ModuleID = 'M1'\n"
183-
"Global is used by function in a different module\n"
184-
"ptr @foo2\n"
185-
"; ModuleID = 'M2'\n"
186-
"ptr @foo3\n"
187-
"; ModuleID = 'M3'\n"));
176+
EXPECT_TRUE(StringRef(ErrorOS.str()) ==
177+
"Global is referenced in a different module!\n"
178+
"ptr @foo2\n"
179+
"; ModuleID = 'M2'\n"
180+
" %call = call i32 @foo2()\n"
181+
"ptr @foo1\n"
182+
"; ModuleID = 'M1'\n"
183+
"Global is used by function in a different module\n"
184+
"ptr @foo2\n"
185+
"; ModuleID = 'M2'\n"
186+
"ptr @foo3\n"
187+
"; ModuleID = 'M3'\n");
188188

189189
Error.clear();
190190
EXPECT_TRUE(verifyModule(M1, &ErrorOS));
191-
EXPECT_TRUE(StringRef(ErrorOS.str()).equals(
192-
"Referencing function in another module!\n"
193-
" %call = call i32 @foo2()\n"
194-
"; ModuleID = 'M1'\n"
195-
"ptr @foo2\n"
196-
"; ModuleID = 'M2'\n"));
191+
EXPECT_TRUE(StringRef(ErrorOS.str()) ==
192+
"Referencing function in another module!\n"
193+
" %call = call i32 @foo2()\n"
194+
"; ModuleID = 'M1'\n"
195+
"ptr @foo2\n"
196+
"; ModuleID = 'M2'\n");
197197

198198
Error.clear();
199199
EXPECT_TRUE(verifyModule(M3, &ErrorOS));

0 commit comments

Comments
 (0)