[clang-tools-extra] [clang-tidy] Detect string literals in macros in modernize-raw-string… (PR #133636)

Richard Thomson via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 2 08:55:01 PDT 2025


================
@@ -58,7 +58,7 @@ bool containsEscapedCharacters(const MatchFinder::MatchResult &Result,
       *Result.SourceManager, Result.Context->getLangOpts());
   StringRef Text = Lexer::getSourceText(CharRange, *Result.SourceManager,
                                         Result.Context->getLangOpts());
-  if (Text.empty() || isRawStringLiteral(Text))
+  if (Text.empty() || !Text.contains('"') || isRawStringLiteral(Text))
----------------
LegalizeAdulthood wrote:

I mean this is a blanket-wide check to see if the text contains a double quote character (`"`), but isn't contextualized to the specific case that matters -- when the text is supplied as an macro argument to the preprocessor string-ize operator `#`.  I don't see how adding this condition applies _only_ to that situation.

https://github.com/llvm/llvm-project/pull/133636


More information about the cfe-commits mailing list