[PATCH] D45161: [AST] Add new printing policy to suppress printing template arguments
Kalle Huttunen via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 2 06:15:34 PDT 2018
khuttun created this revision.
khuttun added reviewers: sepavloff, alexfh.
Herald added a subscriber: cfe-commits.
The purpose of this addition is to be able to write AST matchers that match class template member functions by fully qualified name, without the need to explicitly specify the template arguments in the name.
For example, to match the call to `S::f` here
template <typename T>
struct S {
void f();
};
void foo() {
S<int> s;
s.f();
}
the matcher currently needs to specify the template arguments:
callExpr(callee(functionDecl(hasName("::S<int>::f"))))
With the help of this change, it's possible to create a version of `hasName` that ignores the template arguments. The matcher could then be written as
callExpr(callee(functionDecl(hasNameIgnoringTemplateArgs("::S::f"))))
The motivation for this change is to be able to add checking of class template member functions to clang-tidy checker bugprone-unused-return-value: http://clang.llvm.org/extra/clang-tidy/checks/bugprone-unused-return-value.html
The discussion about this can be found in the code review for the checker: https://reviews.llvm.org/D41655?id=130461#inline-374438
Repository:
rC Clang
https://reviews.llvm.org/D45161
Files:
include/clang/AST/PrettyPrinter.h
lib/AST/TypePrinter.cpp
unittests/AST/NamedDeclPrinterTest.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45161.140617.patch
Type: text/x-patch
Size: 5603 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180402/86bda28a/attachment.bin>
More information about the cfe-commits
mailing list