================
@@ -68,7 +68,8 @@ inline void logWarningFromError(llvm::Error Err) {
 
 /// Find all contributors in an AST.
 void findContributors(ASTContext &Ctx,
-                      std::vector<const NamedDecl *> &Contributors);
+                      std::vector<const NamedDecl *> &Contributors,
+                      bool ExtractFromSystemHeaders = true);
----------------
steakhal wrote:

This is not too relevant, because I had a different recommendation before, but 
in general default args are pretty hostile.
For example, if we ever decided to switch the default of the SSAFOption flag 
backing this, then we would have a problem because this default is never 
spelled at call-sites, so it would complicate keeping those call-sites in sync 
with the `SSAFOption` value.

Another downside usually is that using named parameter passing style is 
`fn(/*ExtractFromSystemHeaders=*/true)` is optional and new code may just 
decide to pass `true` directly.

Many times a new overload does the job like `findContributors` and 
`findContributorsIgnoringSystemHeaders`. Or if multiple defaults are needed, 
then a factory pattern might come handy: 
`Contributors{XXX}.ignoringSystemHeaders().frobbingResults().filteringFancies().find()`.
 The idea is that `Contributors` is a shell structure holding the options, and 
exposing member functions for filling those options, then the real deal is the 
`find` that would do that `findContributors` does. The idea is that if you want 
the default, then you don't need to call any of these member functions on the 
shell struct, but you can pick and choose what you need and when. Anyway, it's 
not relevant here, I just wanted to share how to deal with a few default 
arguments, and what to do when there are incentives for having many many 
default arguments.

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

Reply via email to