Skip to content

Commit e78e711

Browse files
authored
[NFC] Improve for options_compile.cpp (#408)
* [NFC] Improve for options_compile.cpp 1. Check return value for consume_front function 2. Pass by reference to avoid copy StringRef * Apply suggestions
1 parent b3b2d7f commit e78e711

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

options_compile.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ std::string EffectiveOptionsFilter::processOptions(const OpenCLArgList &args,
259259
std::map<std::string, bool> extMap;
260260
llvm::SmallVector<llvm::StringRef> extVec;
261261
llvm::SplitString(PCH_EXTENSION, extVec, ",");
262-
for(auto ext : extVec)
262+
for (auto &ext : extVec)
263263
extMap.insert({ext.str(), true});
264264
#else
265265
std::map<std::string, bool> extMap{
@@ -287,10 +287,12 @@ std::string EffectiveOptionsFilter::processOptions(const OpenCLArgList &args,
287287

288288
auto parseClExt = [&](const std::string &clExtStr) {
289289
llvm::StringRef clExtRef(clExtStr);
290-
clExtRef.consume_front("-cl-ext=");
290+
bool hasPrefix = clExtRef.consume_front("-cl-ext=");
291+
assert(hasPrefix && "clExtRef doesn't start with \"-cl-ext\" prefix");
292+
(void)hasPrefix;
291293
llvm::SmallVector<llvm::StringRef, 32> parsedExt;
292294
clExtRef.split(parsedExt, ',');
293-
for (auto ext : parsedExt) {
295+
for (auto &ext : parsedExt) {
294296
char sign = ext.front();
295297
bool enabled = sign != '-';
296298
llvm::StringRef extName = ext;

0 commit comments

Comments
 (0)