Skip to content

Commit 2df0fa4

Browse files
[clang] Use StringRef::consume_front (NFC)
1 parent 72390c5 commit 2df0fa4

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

clang/lib/Basic/Warnings.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,7 @@ void clang::ProcessWarningOptions(DiagnosticsEngine &Diags,
9696

9797
// Check to see if this warning starts with "no-", if so, this is a
9898
// negative form of the option.
99-
bool isPositive = true;
100-
if (Opt.starts_with("no-")) {
101-
isPositive = false;
102-
Opt = Opt.substr(3);
103-
}
99+
bool isPositive = !Opt.consume_front("no-");
104100

105101
// Figure out how this option affects the warning. If -Wfoo, map the
106102
// diagnostic to a warning, if -Wno-foo, map it to ignore.

clang/lib/Driver/ToolChains/Arch/X86.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,7 @@ void x86::getX86TargetFeatures(const Driver &D, const llvm::Triple &Triple,
237237
assert(Name.starts_with("m") && "Invalid feature name.");
238238
Name = Name.substr(1);
239239

240-
bool IsNegative = Name.starts_with("no-");
241-
if (IsNegative)
242-
Name = Name.substr(3);
240+
bool IsNegative = Name.consume_front("no-");
243241

244242
#ifndef NDEBUG
245243
assert(Name.starts_with("avx10.") && "Invalid AVX10 feature name.");

0 commit comments

Comments
 (0)