From 0452f12eb66d6302cd782b5c2bbed1a3b0e59bac Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Mon, 11 Jan 2021 18:48:09 -0800 Subject: [PATCH] [llvm] Simplify string comparisons (NFC) Identified with readability-string-compare. --- lib/Option/OptTable.cpp | 2 +- lib/Target/PowerPC/PPCAsmPrinter.cpp | 2 +- tools/llvm-mca/llvm-mca.cpp | 2 +- tools/llvm-profdata/llvm-profdata.cpp | 2 +- utils/TableGen/GlobalISelEmitter.cpp | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/Option/OptTable.cpp b/lib/Option/OptTable.cpp index 9564b4433f0..c78c2cee1ed 100644 --- a/lib/Option/OptTable.cpp +++ b/lib/Option/OptTable.cpp @@ -243,7 +243,7 @@ OptTable::findByPrefix(StringRef Cur, unsigned int DisableFlags) const { std::string S = std::string(In.Prefixes[I]) + std::string(In.Name) + "\t"; if (In.HelpText) S += In.HelpText; - if (StringRef(S).startswith(Cur) && S.compare(std::string(Cur) + "\t")) + if (StringRef(S).startswith(Cur) && S != std::string(Cur) + "\t") Ret.push_back(S); } } diff --git a/lib/Target/PowerPC/PPCAsmPrinter.cpp b/lib/Target/PowerPC/PPCAsmPrinter.cpp index 34fd0b883d2..cce21f32414 100644 --- a/lib/Target/PowerPC/PPCAsmPrinter.cpp +++ b/lib/Target/PowerPC/PPCAsmPrinter.cpp @@ -2201,7 +2201,7 @@ bool PPCAIXAsmPrinter::doInitialization(Module &M) { // the sinit and sterm function names. if (FormatIndicatorAndUniqueModId.empty()) { std::string UniqueModuleId = getUniqueModuleId(&M); - if (UniqueModuleId.compare("") != 0) + if (UniqueModuleId != "") // TODO: Use source file full path to generate the unique module id // and add a format indicator as a part of function name in case we // will support more than one format. diff --git a/tools/llvm-mca/llvm-mca.cpp b/tools/llvm-mca/llvm-mca.cpp index 48731c366b7..d122e641ad2 100644 --- a/tools/llvm-mca/llvm-mca.cpp +++ b/tools/llvm-mca/llvm-mca.cpp @@ -325,7 +325,7 @@ int main(int argc, char **argv) { // Apply overrides to llvm-mca specific options. processViewOptions(); - if (!MCPU.compare("native")) + if (MCPU == "native") MCPU = std::string(llvm::sys::getHostCPUName()); std::unique_ptr STI( diff --git a/tools/llvm-profdata/llvm-profdata.cpp b/tools/llvm-profdata/llvm-profdata.cpp index ad188b6a5e9..0e2c75855dd 100644 --- a/tools/llvm-profdata/llvm-profdata.cpp +++ b/tools/llvm-profdata/llvm-profdata.cpp @@ -2430,7 +2430,7 @@ static int show_main(int argc, const char *argv[]) { if (OutputFilename.empty()) OutputFilename = "-"; - if (!Filename.compare(OutputFilename)) { + if (Filename == OutputFilename) { errs() << sys::path::filename(argv[0]) << ": Input file name cannot be the same as the output file name!\n"; return 1; diff --git a/utils/TableGen/GlobalISelEmitter.cpp b/utils/TableGen/GlobalISelEmitter.cpp index c10f85abccc..4be53930fc5 100644 --- a/utils/TableGen/GlobalISelEmitter.cpp +++ b/utils/TableGen/GlobalISelEmitter.cpp @@ -935,7 +935,7 @@ public: std::string ParentName(ParentSymbolicName); if (ComplexSubOperands.count(SymbolicName)) { auto RecordedParentName = ComplexSubOperandsParentName[SymbolicName]; - if (RecordedParentName.compare(ParentName) != 0) + if (RecordedParentName != ParentName) return failedImport("Error: Complex suboperand " + SymbolicName + " referenced by different operands: " + RecordedParentName + " and " + ParentName + "."); @@ -1331,7 +1331,7 @@ public: bool isIdentical(const PredicateMatcher &B) const override { return OperandPredicateMatcher::isIdentical(B) && StoreIdx == cast(&B)->StoreIdx && - Name.compare(cast(&B)->Name) == 0; + Name == cast(&B)->Name; } void emitPredicateOpcodes(MatchTable &Table,