[llvm] r333247 - [llvm-symbolizer] Simplify. NFC
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Thu May 24 17:11:15 PDT 2018
Author: maskray
Date: Thu May 24 17:11:15 2018
New Revision: 333247
URL: http://llvm.org/viewvc/llvm-project?rev=333247&view=rev
Log:
[llvm-symbolizer] Simplify. NFC
Modified:
llvm/trunk/tools/llvm-symbolizer/llvm-symbolizer.cpp
Modified: llvm/trunk/tools/llvm-symbolizer/llvm-symbolizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-symbolizer/llvm-symbolizer.cpp?rev=333247&r1=333246&r2=333247&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-symbolizer/llvm-symbolizer.cpp (original)
+++ llvm/trunk/tools/llvm-symbolizer/llvm-symbolizer.cpp Thu May 24 17:11:15 2018
@@ -101,22 +101,17 @@ static bool error(Expected<T> &ResOrErr)
static bool parseCommand(StringRef InputString, bool &IsData,
std::string &ModuleName, uint64_t &ModuleOffset) {
- const char *kDataCmd = "DATA ";
- const char *kCodeCmd = "CODE ";
const char kDelimiters[] = " \n\r";
- IsData = false;
ModuleName = "";
- const char *pos = InputString.data();
- if (strncmp(pos, kDataCmd, strlen(kDataCmd)) == 0) {
- IsData = true;
- pos += strlen(kDataCmd);
- } else if (strncmp(pos, kCodeCmd, strlen(kCodeCmd)) == 0) {
+ if (InputString.consume_front("CODE ")) {
IsData = false;
- pos += strlen(kCodeCmd);
+ } else if (InputString.consume_front("DATA ")) {
+ IsData = true;
} else {
// If no cmd, assume it's CODE.
IsData = false;
}
+ const char *pos = InputString.data();
// Skip delimiters and parse input filename (if needed).
if (ClBinaryName == "") {
pos += strspn(pos, kDelimiters);
@@ -183,7 +178,7 @@ int main(int argc, char **argv) {
if (ClPrintAddress) {
outs() << "0x";
outs().write_hex(ModuleOffset);
- StringRef Delimiter = (ClPrettyPrint == true) ? ": " : "\n";
+ StringRef Delimiter = ClPrettyPrint ? ": " : "\n";
outs() << Delimiter;
}
if (IsData) {
More information about the llvm-commits
mailing list