Issue 97243
Summary clang-tidy: modernize-raw-string-literal wrongly removes suffix, e.g. `s` (`std::string_literals`)
Labels clang-tidy
Assignees
Reporter e-kwsm
    Prepare `/tmp/a.cpp`:

```cpp
#include <string>
int main() {
  using namespace std::literals::string_literals;
  auto s = "id=\"0\""s;
}
```

and

```json
[ { "directory": "/tmp", "command": "clang++ -std=c++14 -c -o a.o a.cpp", "file": "a.cpp", "output": "a.o" } ]
```

```ShellSession
$ clang-tidy --version
LLVM (http://llvm.org/):
  LLVM version 17.0.6
  Optimized build.
$ clang-tidy --checks=modernize-raw-string-literal --fix a.cpp
1 warning generated.
a.cpp:4:12: warning: escaped string literal can be written as a raw string literal [modernize-raw-string-literal]
    4 |   auto s = "id=\"0\""s;
      |            ^~~~~~~~~~~
      | R"(id="0")"
a.cpp:4:12: note: FIX-IT applied suggested code changes
clang-tidy applied 1 of 1 suggested fixes.
```

gives

```cpp
  auto s = R"(id="0")";
```

which must be

```cpp
  auto s = R"(id="0")"s;
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to