================ @@ -1213,6 +1213,194 @@ static bool isRemark(const Record &Diag) { return ClsName == "CLASS_REMARK"; } +// Presumes the text has been split at the first whitespace or hyphen. +static bool isExemptAtStart(StringRef Text) { + // Fast path, the first character is lowercase or not alphanumeric. + if (isLower(Text[0]) || !isAlnum(Text[0])) + return true; + + // If the text is all uppercase (or numbers, +, or _), then we assume it's an + // acronym and that's allowed. This covers cases like ISO, C23, C++14, and + // OBJECT_MODE. However, if there's only a single letter other than "C", we + // do not exempt it so that we catch a case like "A really bad idea" while + // still allowing a case like "C does not allow...". + if (llvm::all_of(Text, [](char C) { + return isUpper(C) || isDigit(C) || C == '+' || C == '_'; + })) + return Text.size() > 1 || Text[0] == 'C'; + + // Otherwise, there are a few other exemptions. + return StringSwitch<bool>(Text) + .Case("AddressSanitizer", true) + .Case("CFString", true) + .Case("Clang", true) + .Case("Fuchsia", true) + .Case("GNUstep", true) + .Case("IBOutletCollection", true) + .Case("Microsoft", true) + .Case("Neon", true) + .StartsWith("NSInvocation", true) // NSInvocation, NSInvocation's + .Case("Objective", true) // Objective-C, Objective-C++ ---------------- Endilll wrote:
Probably worth a comment that `-` is considered a word boundary, so both Objective-C and Objective-C++ are covered. https://github.com/llvm/llvm-project/pull/93229 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits