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

Carlos Galvez via cfe-commits cfe-commits at lists.llvm.org
Sun Mar 30 23:29:38 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))
----------------
carlosgalvezp wrote:

It picked up on this:

```cpp
#define TRICK(arg_) #arg_
char const *const MacroBody = TRICK(foo\\bar);
```

Since `foo\\bar` does not have quotes, the assertion inside `isRawStringLiteral` failed.

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


More information about the cfe-commits mailing list