hokein created this revision. hokein added a reviewer: gribozavr2. Herald added a subscriber: xazax.hun. hokein requested review of this revision. Herald added a project: clang-tools-extra.
getSourceText could return an empty string for error cases (e.g. invalid source locaiton), this patch makes the code more robust. The crash did happen in our internal codebase, but unfortunately I didn't manage to get a reproduce case. One thing I can confirm from the core dump is that the crash is caused by calling isRawStringLiteral on an empty Text. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D102770 Files: clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.cpp Index: clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.cpp +++ clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.cpp @@ -56,7 +56,7 @@ *Result.SourceManager, Result.Context->getLangOpts()); StringRef Text = Lexer::getSourceText(CharRange, *Result.SourceManager, Result.Context->getLangOpts()); - if (isRawStringLiteral(Text)) + if (Text.empty() || isRawStringLiteral(Text)) return false; return containsEscapes(Text, R"('\"?x01)");
Index: clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.cpp +++ clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.cpp @@ -56,7 +56,7 @@ *Result.SourceManager, Result.Context->getLangOpts()); StringRef Text = Lexer::getSourceText(CharRange, *Result.SourceManager, Result.Context->getLangOpts()); - if (isRawStringLiteral(Text)) + if (Text.empty() || isRawStringLiteral(Text)) return false; return containsEscapes(Text, R"('\"?x01)");
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits