[llvm] [NFC] Change FindDbgDeclareUsers interface to match findDbgUsers/values (PR #73498)

Felipe de Azevedo Piovezan via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 11 07:13:23 PST 2023


================
@@ -40,7 +40,7 @@ class Module;
 
 /// Finds dbg.declare intrinsics declaring local variables as living in the
 /// memory that 'V' points to.
-TinyPtrVector<DbgDeclareInst *> FindDbgDeclareUses(Value *V);
+void findDbgDeclares(SmallVectorImpl<DbgDeclareInst *> &DbgUsers, Value *V);
----------------
felipepiovezan wrote:

Forgive me if I mentioned this in another patch (I couldn't find it), but why insist on using out parameters instead of returning a pair of vectors?
Out parameters made a lot of sense in old C++, but nowadays not so much. Out parameters just encourage variables with larger lifetimes and those interfaces create questions like "can this handle a pre-populated container? Will it erase the container?". It also makes callers need to know to about the input type of the container (note how previously the code did not need to know about the type container being returned)

I realize you will later have one of the out parameters be optional, but this could be accomplished with multiple functions. For example, we could minimize a lot of the diffs in this stack of patches by having differently named functions that share an implementation.

https://github.com/llvm/llvm-project/pull/73498


More information about the llvm-commits mailing list