[Omit needless words] Fix lowercasing of initialisms with two-letter initial words.

Fixes rdar://problem/26643039.
This commit is contained in:
Doug Gregor
2016-06-13 17:59:14 -07:00
parent 011e306fe8
commit 5bea187b0f
5 changed files with 20 additions and 7 deletions

View File

@@ -857,14 +857,13 @@ camel_case::toLowercaseInitialisms(StringRef string,
// Lowercase until we hit the an uppercase letter followed by a
// non-uppercase letter.
llvm::SmallString<32> scratchStr;
scratchStr.push_back(clang::toLowercase(string[0]));
for (unsigned i = 1, n = string.size(); i != n; ++i) {
for (unsigned i = 0, n = string.size(); i != n; ++i) {
// If the next character is not uppercase, stop.
if (i < n - 1 && !clang::isUppercase(string[i+1])) {
// If the next non-uppercase character was not a letter, we seem
// to have a plural, we should still lowercase the character
// we're on.
if (!clang::isLetter(string[i+1]) ||
// to have a plural, or we're at the beginning, we should still
// lowercase the character we're on.
if (i == 0 || !clang::isLetter(string[i+1]) ||
isPluralSuffix(camel_case::getFirstWord(string.substr(i+1)))) {
scratchStr.push_back(clang::toLowercase(string[i]));
++i;