[PATCH] D27525: Improve format member detection in llvm::formatv
Pavel Labath via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 7 08:40:42 PST 2016
labath created this revision.
labath added a reviewer: zturner.
labath added a subscriber: llvm-commits.
The existing detection of a format member function has a couple of deficiencies:
- the member function does not get detected if one calls formatv with an lvalue, because the template parameter gets deduced as T&, which fails the is_class check.
- it also did not work if the function was called with a const variable because the template parameter would get deduced as const T&, again failing the is_class check.
This fixes the problem by stripping the references in the uses_format_member
template, to make sure the type is correctly detected as class. It also provides
specializations of the has_FormatMember template for const and non-const members
of the types in order to enable declaring the format member as a "const"
function. I have added tests that verify that formatv can be now called in these
scenarios. As some scenarios could not be verified at runtime (e.g. making sure
that calling a non-const format member on a const object does *not* compile), I
have also added some static_asserts which test the behaviour of the template
classes used internally by formatv().
https://reviews.llvm.org/D27525
Files:
include/llvm/Support/FormatVariadicDetails.h
unittests/Support/FormatVariadicTest.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27525.80602.patch
Type: text/x-patch
Size: 6373 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161207/4a207cfe/attachment.bin>
More information about the llvm-commits
mailing list