[PATCH] [clang-tidy] Checker for inaccurate use of erase method.
Alexander Kornienko
alexfh at google.com
Mon Feb 9 07:10:05 PST 2015
Looks good!
Thanks for the contribution! Could you run this on LLVM? I don't expect the check to find anything, but it may be useful as a smoke-testing.
A couple of typos in the comment. See below.
================
Comment at: clang-tidy/misc/InaccurateEraseCheck.cpp:25
@@ +24,3 @@
+ .bind("InaccEndCall"))),
+ anything()));
+
----------------
xazax.hun wrote:
> It seems to work for, but I have some concerns. Is it guaranteed to work? Is there some kind of guaranteed matching/evaluating order or matcher priority? What is the idiomatic way to optionally match a construct?
The order of evaluation is right-to-left, and anyOf is short-circuiting, so the construct is guaranteed to work. There was an idea to add an "optionally" matcher for this purpose, but nobody got around to do it yet.
================
Comment at: clang-tidy/misc/InaccurateEraseCheck.h:20
@@ +19,3 @@
+///
+/// Algorithms like \c remove() does not actually remove any element from the
+/// container but returns an iterator to the first redundant element at the end
----------------
nit: s/does not/do not/
================
Comment at: clang-tidy/misc/InaccurateEraseCheck.h:21
@@ +20,3 @@
+/// Algorithms like \c remove() does not actually remove any element from the
+/// container but returns an iterator to the first redundant element at the end
+/// of the container. These redundant elements must be removed using the
----------------
nit: s/returns/return/
http://reviews.llvm.org/D7496
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the cfe-commits
mailing list