llvm / llvm/llvm-project

Invalid FIX-IT performance-single-char performance-prefer-single-char-overloads

Open
#222,970 1 comment 0 reactions 0 assignees View on GitHub
clang-tidy invalid-code-generation
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Assuming the following code

```c++
#include

#define TOKEN_SEPARATING_CHARACTER "_"

void foo()
{
std::string a;
a += TOKEN_SEPARATING_CHARACTER;
}
```

`performance-single-char-overloads` will apply the following changes.

```c++
#include

#define TOKEN_SEPARATING_CHARACTER "_"

void foo()
{
std::string a;
a += '_';
}
```

This is probably not the expected behavior, we should probably not emit any warning if the string is coming from a define (with an option) rather than removing the define.

https://godbolt.org/z/ccqaajchW

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue with the C++ snippet and the performance-single-char-overloads check, then inspect the check's handling of macro-defined strings. Confirm the intended behavior for TOKEN_SEPARATING_CHARACTER and verify that the diagnostic and suggested change no longer produce the invalid replacement shown in the report.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.