[clang-tools-extra] [clang-tidy][modernize-return-braced-init-list]fix false-positives (PR #68491)

Congcong Cai via cfe-commits cfe-commits at lists.llvm.org
Sat Oct 7 14:58:26 PDT 2023


================
@@ -17,11 +17,21 @@ using namespace clang::ast_matchers;
 namespace clang::tidy::modernize {
 
 void ReturnBracedInitListCheck::registerMatchers(MatchFinder *Finder) {
-  // Skip list initialization and constructors with an initializer list.
+  auto SemanticallyDifferentContainer = allOf(
+      argumentCountIs(2), hasArgument(0, hasType(isInteger())),
----------------
HerrCai0907 wrote:

Do you think we should ignore all when the record has constructor with std::initialList? The fix has potential risk to change program behavior.

For example, it should not change from () to {}.
```
class T {
T(int);
T(std::initialList<int>);
};

T(1);
T{1};
```

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


More information about the cfe-commits mailing list