================
@@ -16,6 +18,25 @@ using namespace clang::ast_matchers;
 
 namespace clang::tidy::modernize {
 
+static bool hasInitListConstructor(const CXXRecordDecl *RD) {
+  if (RD == nullptr || !RD->hasDefinition())
+    return false;
+  auto IsInitListCtor = [](const CXXConstructorDecl *Ctor) {
+    return Ctor->hasOneParamOrDefaultArgs() &&
+           utils::type_traits::isStdInitializerList(
+               Ctor->getParamDecl(0)->getType().getNonReferenceType());
+  };
+  return llvm::any_of(RD->decls(), [&](const Decl *D) {
----------------
zeyi2 wrote:

A small suggestion: could we use constructor lookup here instead of iterating 
over `RD->decls()`?

Inherited constructors can participate in list-initialization, but they are not 
direct `CXXConstructorDecls` of the derived class.

```
|-UsingDecl 0x8b3263990 <line:13:3, col:15> col:15 Base::Derived
| `-NestedNameSpecifier TypeSpec 'Base'
|-ConstructorUsingShadowDecl 0x8b3263a88 <line:13:15> col:15 implicit
| |-target CXXConstructor 0x8b3263168 'Base' 'void (std::initializer_list<Bar>)'
| |-nominated CXXRecord 0x8b3214880 'Base' <<<NULL>>>
| |-constructed CXXRecord 0x8b3214880 'Base' <<<NULL>>>
| `-CXXConstructorDecl 0x8b3263168 <line:9:3, col:34> col:3 Base 'void 
(std::initializer_list<Bar>)' external-linkage
|   `-ParmVarDecl 0x8b3263038 <col:8, col:33> col:34 
'std::initializer_list<Bar>'
```

https://github.com/llvm/llvm-project/pull/205440
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to