Skip to content

Commit d34ac45

Browse files
[Basic] Use StringRef::consume_front (NFC)
1 parent ed7f4ed commit d34ac45

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

clang/lib/Basic/Targets/AMDGPU.h

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,8 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo {
169169
}
170170

171171
bool HasLeftParen = false;
172-
if (S.front() == '{') {
172+
if (S.consume_front("{"))
173173
HasLeftParen = true;
174-
S = S.drop_front();
175-
}
176174
if (S.empty())
177175
return false;
178176
if (S.front() != 'v' && S.front() != 's' && S.front() != 'a') {
@@ -199,29 +197,24 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo {
199197
return true;
200198
}
201199
bool HasLeftBracket = false;
202-
if (!S.empty() && S.front() == '[') {
200+
if (S.consume_front("["))
203201
HasLeftBracket = true;
204-
S = S.drop_front();
205-
}
206202
unsigned long long N;
207203
if (S.empty() || consumeUnsignedInteger(S, 10, N))
208204
return false;
209-
if (!S.empty() && S.front() == ':') {
205+
if (S.consume_front(":")) {
210206
if (!HasLeftBracket)
211207
return false;
212-
S = S.drop_front();
213208
unsigned long long M;
214209
if (consumeUnsignedInteger(S, 10, M) || N >= M)
215210
return false;
216211
}
217212
if (HasLeftBracket) {
218-
if (S.empty() || S.front() != ']')
213+
if (!S.consume_front("]"))
219214
return false;
220-
S = S.drop_front();
221215
}
222-
if (S.empty() || S.front() != '}')
216+
if (!S.consume_front("}"))
223217
return false;
224-
S = S.drop_front();
225218
if (!S.empty())
226219
return false;
227220
// Found {vn}, {sn}, {an}, {v[n]}, {s[n]}, {a[n]}, {v[n:m]}, {s[n:m]}

clang/lib/Basic/Warnings.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,7 @@ void clang::ProcessWarningOptions(DiagnosticsEngine &Diags,
199199

200200
// Check to see if this warning starts with "no-", if so, this is a
201201
// negative form of the option.
202-
bool IsPositive = !Opt.starts_with("no-");
203-
if (!IsPositive) Opt = Opt.substr(3);
202+
bool IsPositive = !Opt.consume_front("no-");
204203

205204
auto Severity = IsPositive ? diag::Severity::Remark
206205
: diag::Severity::Ignored;

0 commit comments

Comments
 (0)