readability-redundant-string-init

查找不必要的字符串初始化。

示例

// Initializing string with empty string literal is unnecessary.
std::string a = "";
std::string b("");

// becomes

std::string a;
std::string b;

// Initializing a string_view with an empty string literal produces an
// instance that compares equal to string_view().
std::string_view a = "";
std::string_view b("");

// becomes
std::string_view a;
std::string_view b;

选项

StringNames

默认值为 ::std::basic_string;::std::basic_string_view

用分号分隔的类名列表,用于应用此检查。默认情况下,::std::basic_string 应用于 std::stringstd::wstring。设置为例如 ::std::basic_string;llvm::StringRef;QString,以对自定义类执行此检查。