================
@@ -576,6 +576,50 @@ SymbolCollector::getRefContainer(const Decl *Enclosing,
   return Enclosing;
 }
 
+bool SymbolCollector::isLikelyForwardingFunctionCached(
+    const FunctionTemplateDecl *FT) {
+  if (LikelyForwardingFunctionCached.contains(FT))
+    return true;
+  if (isLikelyForwardingFunction(FT)) {
+    LikelyForwardingFunctionCached.insert(FT);
+    return true;
+  }
+  return false;
+}
+
+bool SymbolCollector::potentiallyForwardInBody(const Decl *D) {
+  if (auto *FD = llvm::dyn_cast<clang::FunctionDecl>(D);
+      FD && FD->isTemplateInstantiation())
+    if (auto *PT = FD->getPrimaryTemplate();
+        PT && isLikelyForwardingFunctionCached(PT))
+      return true;
+  if (auto *FT = llvm::dyn_cast<clang::FunctionTemplateDecl>(D);
+      FT && isLikelyForwardingFunctionCached(FT))
+    return true;
+  return false;
+}
+
+SmallVector<CXXConstructorDecl *, 1>
+SymbolCollector::findIndirectConstructors(const Decl *D) {
+  auto *FD = llvm::dyn_cast<clang::FunctionDecl>(D);
+  if (FD == nullptr || !FD->isTemplateInstantiation())
+    return {};
+  if (auto Entry = ForwardingToConstructorCache.find(FD);
+      Entry != ForwardingToConstructorCache.end())
+    return Entry->getSecond();
+  if (auto *PT = FD->getPrimaryTemplate();
+      PT == nullptr || !isLikelyForwardingFunctionCached(PT))
+    return {};
+
+  SmallVector<CXXConstructorDecl *, 1> FoundConstructors =
+      searchConstructorsInForwardingFunction(FD);
+  auto Iter = ForwardingToConstructorCache.try_emplace(
+      FD, std::move(FoundConstructors));
+  if (Iter.second)
+    return Iter.first->getSecond();
+  return {};
----------------
HighCommander4 wrote:

(This case should never happen, right? We check above that `FD` wasn't already 
in the map.)

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

Reply via email to