[PATCH] D55433: [clang-tidy] Adding a new modernize use nodiscard checker

MyDeveloperDay via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 4 04:39:49 PST 2019


MyDeveloperDay added inline comments.


================
Comment at: clang-tidy/modernize/UseNodiscardCheck.cpp:30
+// TODO: Find a better way of detecting a function template.
+static bool isFunctionTemplate(const QualType &ParamType) {
+  // Try to catch both std::function and boost::function
----------------
JonasToth wrote:
> MyDeveloperDay wrote:
> > JonasToth wrote:
> > > Do you want a function-template (`template <class T> void foo(T argument);`) or the template-function `{std,boost}::function`?
> > > For the first the approach should be the same as above, for the second your implementation might work.
> > > 
> > > But a matcher with `hasAnyName("::std::function", "::boost::function")` would be cleaner if you can use that instead.
> > I can't seem to get the hasName or hasAnyName matcher pick up std::function<> as an argument
> > 
> > Using clang-query, I can't get this to work, did I miss something?
> > 
> > ```
> > match functionDecl(hasAnyParameter(hasType(namedDecl(hasName("::std::function"))))).bind("x")
> > ```
> > 
> I experimented a bit and found something that might work for you. See the attachment.
> {F7791969}
This really helped thank you!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55433/new/

https://reviews.llvm.org/D55433





More information about the cfe-commits mailing list