[clang] Use StringRef in range-based for loops (NFC) (#144242)
When we iterate over std::vector<std::string>, we can directly assign each element to StringRef. We do not need to go through separate statements.
This commit is contained in:
parent
9adde28df7
commit
f71fb2dc01
@ -555,8 +555,7 @@ void TargetInfo::adjust(DiagnosticsEngine &Diags, LangOptions &Opts) {
|
||||
bool TargetInfo::initFeatureMap(
|
||||
llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags, StringRef CPU,
|
||||
const std::vector<std::string> &FeatureVec) const {
|
||||
for (const auto &F : FeatureVec) {
|
||||
StringRef Name = F;
|
||||
for (StringRef Name : FeatureVec) {
|
||||
if (Name.empty())
|
||||
continue;
|
||||
// Apply the feature via the target.
|
||||
|
@ -3232,8 +3232,7 @@ bool Sema::checkTargetAttr(SourceLocation LiteralLoc, StringRef AttrStr) {
|
||||
if (ParsedAttrs.Duplicate != "")
|
||||
return Diag(LiteralLoc, diag::err_duplicate_target_attribute)
|
||||
<< Duplicate << None << ParsedAttrs.Duplicate << Target;
|
||||
for (const auto &Feature : ParsedAttrs.Features) {
|
||||
StringRef CurFeature = Feature;
|
||||
for (StringRef CurFeature : ParsedAttrs.Features) {
|
||||
if (!CurFeature.starts_with('+') && !CurFeature.starts_with('-'))
|
||||
return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
|
||||
<< Unsupported << None << AttrStr << Target;
|
||||
@ -3241,8 +3240,7 @@ bool Sema::checkTargetAttr(SourceLocation LiteralLoc, StringRef AttrStr) {
|
||||
}
|
||||
|
||||
if (Context.getTargetInfo().getTriple().isLoongArch()) {
|
||||
for (const auto &Feature : ParsedAttrs.Features) {
|
||||
StringRef CurFeature = Feature;
|
||||
for (StringRef CurFeature : ParsedAttrs.Features) {
|
||||
if (CurFeature.starts_with("!arch=")) {
|
||||
StringRef ArchValue = CurFeature.split("=").second.trim();
|
||||
return Diag(LiteralLoc, diag::err_attribute_unsupported)
|
||||
|
@ -22,8 +22,7 @@ namespace clang {
|
||||
namespace tooling {
|
||||
|
||||
static StringRef getDriverMode(const CommandLineArguments &Args) {
|
||||
for (const auto &Arg : Args) {
|
||||
StringRef ArgRef = Arg;
|
||||
for (StringRef ArgRef : Args) {
|
||||
if (ArgRef.consume_front("--driver-mode=")) {
|
||||
return ArgRef;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user