================
@@ -253,6 +254,23 @@ resolveForwardingParameters(const FunctionDecl *D,
unsigned MaxDepth = 10);
/// reference to one (e.g. `Args&...` or `Args&&...`).
bool isExpandedFromParameterPack(const ParmVarDecl *D);
+/// Heuristic that checks if FT is forwarding a parameter pack to another
+/// function (e.g. `make_unique`).
+bool isLikelyForwardingFunction(FunctionTemplateDecl *FT);
+
+class ForwardingToConstructorVisitor
+ : public RecursiveASTVisitor<ForwardingToConstructorVisitor> {
+public:
+ ForwardingToConstructorVisitor() {}
+
+ bool VisitCallExpr(CallExpr *E);
+
+ bool VisitCXXNewExpr(CXXNewExpr *E);
+
+ // Output of this visitor
+ std::vector<CXXConstructorDecl *> Constructors{};
----------------
HighCommander4 wrote:
In answer to your question about `vector` vs. `SmallVector`: this (and other
places in the patch where we store constructors) are a great candidate for
using `SmallVector<CXXConstructorDecl*, 1>` in particular, since most of the
time we expect the number of constructors to be called by an instantiation of
e.g. `make_unique` to be 1.
(In terms of implementation, `SmallVector` uses a "small buffer optimization"
with a customizable buffer size, such that if the size of the vector is no
larger than the specified buffer size, the elements are stored entirely on the
stack. So it's useful in cases where the size of the vector is frequently
small, and we have some idea of how small.)
https://github.com/llvm/llvm-project/pull/169742
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits