================
@@ -199,15 +204,62 @@ static const FunctionDecl *resolveMocks(const 
FunctionDecl *Func) {
   return Func;
 }
 
+namespace {
+
+enum class InitListKind {
+  None,
+  Anonymous,
+  Typed,
+};
+
+} // namespace
+
+static InitListKind getInitListKind(const Expr *Arg) {
+  Arg = Arg->IgnoreImplicit();
+
+  // Peel std::initializer_list wrappers until we reach the underlying
+  // list-initialization expression.
+  while (const auto *StdInit = dyn_cast<CXXStdInitializerListExpr>(Arg))
+    Arg = StdInit->getSubExpr()->IgnoreImplicit();
+
+  if (isa<InitListExpr>(Arg))
+    return InitListKind::Anonymous;
+
+  if (const auto *Ctor = dyn_cast<CXXConstructExpr>(Arg)) {
+    if (!Ctor->isListInitialization())
+      return InitListKind::None;
+    // CXXTemporaryObjectExpr corresponds to explicit Type{...} syntax.
+    if (isa<CXXTemporaryObjectExpr>(Ctor))
+      return InitListKind::Typed;
+    // Other list-initialized constructions (for example '{}') have no
+    // explicit type at the call site.
+    return InitListKind::Anonymous;
+  }
+
+  if (const auto *FuncCast = dyn_cast<CXXFunctionalCastExpr>(Arg)) {
+    if (FuncCast->isListInitialization())
+      return InitListKind::Typed;
+  }
----------------
unterumarmung wrote:

I decided to keep the 2 `if`s because this branch has changed and with 1 `if` 
it doesn't look great. If you wanna still merge them, please let me know.

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

Reply via email to