diff --git a/clang-tools-extra/include-cleaner/lib/Record.cpp b/clang-tools-extra/include-cleaner/lib/Record.cpp --- a/clang-tools-extra/include-cleaner/lib/Record.cpp +++ b/clang-tools-extra/include-cleaner/lib/Record.cpp @@ -144,9 +144,13 @@ // FIXME: this is a mirror of clang::clangd::parseIWYUPragma, move to libTooling // to share the code? static llvm::Optional parseIWYUPragma(const char *Text) { - assert(strncmp(Text, "//", 2) || strncmp(Text, "/*", 2)); + // Skip the comment start, // or /*. + if (Text[0] != '/' || (Text[1] != '/' && Text[1] != '*')) + return llvm::None; + Text += 2; + + // Per spec, direcitves are whitespace- and case-sensitive. constexpr llvm::StringLiteral IWYUPragma = " IWYU pragma: "; - Text += 2; // Skip the comment start, // or /*. if (strncmp(Text, IWYUPragma.data(), IWYUPragma.size())) return llvm::None; Text += IWYUPragma.size();