Skip to content

[NFC] Improve for options_compile.cpp #408

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions options_compile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ std::string EffectiveOptionsFilter::processOptions(const OpenCLArgList &args,
std::map<std::string, bool> extMap;
llvm::SmallVector<llvm::StringRef> extVec;
llvm::SplitString(PCH_EXTENSION, extVec, ",");
for(auto ext : extVec)
for (auto &ext : extVec)
extMap.insert({ext.str(), true});
#else
std::map<std::string, bool> extMap{
Expand Down Expand Up @@ -287,10 +287,12 @@ std::string EffectiveOptionsFilter::processOptions(const OpenCLArgList &args,

auto parseClExt = [&](const std::string &clExtStr) {
llvm::StringRef clExtRef(clExtStr);
clExtRef.consume_front("-cl-ext=");
bool hasPrefix = clExtRef.consume_front("-cl-ext=");
assert(hasPrefix && "clExtRef doesn't start with \"-cl-ext\" prefix");
(void)hasPrefix;
llvm::SmallVector<llvm::StringRef, 32> parsedExt;
clExtRef.split(parsedExt, ',');
for (auto ext : parsedExt) {
for (auto &ext : parsedExt) {
char sign = ext.front();
bool enabled = sign != '-';
llvm::StringRef extName = ext;
Expand Down