Skip to content

Commit 92f0e76

Browse files
[TableGen] Use std::string::find (NFC)
This patch partially reverts #139661 for a better solution. Specifically, we can take advantage of the fact that std::string::find accepts anything that can be converted to std::string_view, including StringRef, starting with C++17. This way, we do not need to cast Val to StringRef or LHSs->getValue() to std::string.
1 parent 3cfdf2c commit 92f0e76

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

llvm/lib/TableGen/Record.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,11 +1796,11 @@ const Init *TernOpInit::Fold(const Record *CurRec) const {
17961796
if (LHSs && MHSs && RHSs) {
17971797
std::string Val = RHSs->getValue().str();
17981798

1799-
StringRef::size_type found;
1800-
StringRef::size_type idx = 0;
1799+
std::string::size_type found;
1800+
std::string::size_type idx = 0;
18011801
while (true) {
1802-
found = StringRef(Val).find(LHSs->getValue(), idx);
1803-
if (found == StringRef::npos)
1802+
found = Val.find(LHSs->getValue(), idx);
1803+
if (found == std::string::npos)
18041804
break;
18051805
Val.replace(found, LHSs->getValue().size(), MHSs->getValue().str());
18061806
idx = found + MHSs->getValue().size();

0 commit comments

Comments
 (0)