================
@@ -1040,5 +1038,86 @@ bool isExpandedFromParameterPack(const ParmVarDecl *D) {
return getUnderlyingPackType(D) != nullptr;
}
+bool isLikelyForwardingFunction(const FunctionTemplateDecl *FT) {
+ const auto *FD = FT->getTemplatedDecl();
+ const auto NumParams = FD->getNumParams();
+ // Check whether its last parameter is a parameter pack...
+ if (NumParams > 0) {
+ const auto *LastParam = FD->getParamDecl(NumParams - 1);
+ if (const auto *PET = dyn_cast<PackExpansionType>(LastParam->getType())) {
+ // ... of the type T&&... or T...
+ const auto BaseType = PET->getPattern().getNonReferenceType();
+ if (const auto *TTPT =
+ dyn_cast<TemplateTypeParmType>(BaseType.getTypePtr())) {
+ // ... whose template parameter comes from the function directly
+ if (FT->getTemplateParameters()->getDepth() == TTPT->getDepth()) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+}
+
+class ForwardingToConstructorVisitor
+ : public RecursiveASTVisitor<ForwardingToConstructorVisitor> {
+public:
+ struct SeenFunctions {
+ unsigned int DepthLeft;
+ SeenFunctions *Prev;
----------------
timon-ul wrote:
I don't see how a set would be a useful data structure for this case. The
"similar place" you linked to my understanding never needs to remove things out
of this list. I think this is because they do not branch out in the depth but
only have 1 path they follow. For my case if I have a template that calls 2
different functions that happen to be likely forwarding functions I will visit
both so the path splits and just because I have seen a function in the first
path does not mean I want to see it in the 2nd path so I kinda need to "get
rid" of all seen functions of the first path (the linked list will
automatically do so for me). Unless I have another misunderstanding here.
https://github.com/llvm/llvm-project/pull/169742
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits