================
@@ -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 {};
----------------
timon-ul wrote:
Yeah it should never happen, I saw something like this elsewehere in the code
and got a bit confused if this operation could fail and we should have a case
for this, but going back to it I now see that there is a different reason for
it there and it makes no sense in my case, will remove.
https://github.com/llvm/llvm-project/pull/169742
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits