Skip to content

Commit

Permalink
[Driver] Use StringRef::consume_front (NFC)
Browse files Browse the repository at this point in the history
  • Loading branch information
kazutakahirata committed Jan 24, 2024
1 parent 3446601 commit 5404a37
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
10 changes: 3 additions & 7 deletions clang/lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6482,18 +6482,15 @@ bool Driver::GetReleaseVersion(StringRef Str, unsigned &Major, unsigned &Minor,
return false;
if (Str.empty())
return true;
if (Str[0] != '.')
if (!Str.consume_front("."))
return false;

Str = Str.drop_front(1);

if (Str.consumeInteger(10, Minor))
return false;
if (Str.empty())
return true;
if (Str[0] != '.')
if (!Str.consume_front("."))
return false;
Str = Str.drop_front(1);

if (Str.consumeInteger(10, Micro))
return false;
Expand Down Expand Up @@ -6521,9 +6518,8 @@ bool Driver::GetReleaseVersion(StringRef Str,
Digits[CurDigit] = Digit;
if (Str.empty())
return true;
if (Str[0] != '.')
if (!Str.consume_front("."))
return false;
Str = Str.drop_front(1);
CurDigit++;
}

Expand Down
4 changes: 1 addition & 3 deletions clang/lib/Driver/ToolChains/CommonArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,7 @@ void tools::handleTargetFeaturesGroup(const Driver &D,
continue;
}

bool IsNegative = Name.starts_with("no-");
if (IsNegative)
Name = Name.substr(3);
bool IsNegative = Name.consume_front("no-");

Features.push_back(Args.MakeArgString((IsNegative ? "-" : "+") + Name));
}
Expand Down
3 changes: 1 addition & 2 deletions clang/lib/Driver/ToolChains/Hexagon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,6 @@ StringRef HexagonToolChain::GetTargetCPUVersion(const ArgList &Args) {
CpuArg = A;

StringRef CPU = CpuArg ? CpuArg->getValue() : GetDefaultCPU();
if (CPU.starts_with("hexagon"))
return CPU.substr(sizeof("hexagon") - 1);
CPU.consume_front("hexagon");
return CPU;
}

0 comments on commit 5404a37

Please sign in to comment.