llvm/llvm-project

clang-tidy check readability-container-data-pointer fix isn't configurable to use std::string::c_str() instead of data()

Open

#55.026 geöffnet am 21. Apr. 2022

Auf GitHub ansehen
 (12 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)C++ (10.782 Forks)batch import
clang-tidyenhancementgood first issue

Repository-Metriken

Stars
 (26.378 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 1T 2h) (1.000 gemergte PRs in 30 T)

Beschreibung

This is an "enhancement" request. I used clang-tidy 14.0.0.

Use C++ code

#include <string>

int main()
{
    std::string st1;
    char *cp1 = &st1[0];
    return 0;
}

The clang-tidy fix creates st1.data() -- ideally the fix would create std.c_str() instead or have a fix configuration option for that.

However, usage of c_str() would only work if the "const char* data()" overload were used instead of "char * data()".

Contributor Guide