[llvm-symbolizer] Simplify. NFC

llvm-svn: 333247
This commit is contained in:
Fangrui Song 2018-05-25 00:11:15 +00:00
parent 7f0a05ada5
commit 3b7499d104
1 changed files with 5 additions and 10 deletions

View File

@ -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) {