llvm.org GIT mirror llvm / 42f2a6b
Use startswith_lower() where possible. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194007 91177308-0d34-0410-b5e6-96231b3b80d8 Jakub Staszak 6 years ago
2 changed file(s) with 2 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
174174 return true;
175175 }
176176
177 // Returns true if X starts with Y, ignoring case.
178 static bool startsWithIgnoreCase(StringRef X, StringRef Y) {
179 if (X.size() < Y.size())
180 return false;
181 return X.substr(0, Y.size()).equals_lower(Y);
182 }
183
184177 /// \returns Matched size. 0 means no match.
185178 static unsigned matchOption(const OptTable::Info *I, StringRef Str,
186179 bool IgnoreCase) {
189182 if (Str.startswith(Prefix)) {
190183 StringRef Rest = Str.substr(Prefix.size());
191184 bool Matched = IgnoreCase
192 ? startsWithIgnoreCase(Rest, I->Name)
185 ? Rest.startswith_lower(I->Name)
193186 : Rest.startswith(I->Name);
194187 if (Matched)
195188 return Prefix.size() + StringRef(I->Name).size();
661661 I = Args.begin(), E = Args.end(); I != E; ++I) {
662662 if (StringRef(*I).equals_lower("-arch")) {
663663 ++I;
664 if (I != E && StringRef(*I).substr(0, strlen("arm")).equals_lower("arm"))
664 if (I != E && StringRef(*I).startswith_lower("arm"))
665665 return true;
666666 }
667667 }