[PATCH] D128372: [Clang-Tidy] Empty Check
Abraham Corea Diaz via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 27 09:55:09 PDT 2022
abrahamcd added inline comments.
================
Comment at: clang-tools-extra/clang-tidy/bugprone/StandaloneEmptyCheck.cpp:51-57
+ auto Methods = MemberCall->getRecordDecl()->methods();
+ auto Clear = llvm::find_if(Methods, [](const CXXMethodDecl *F) {
+ return F->getDeclName().getAsString() == "clear" &&
+ F->getMinRequiredArguments() == 0;
+ });
+
+ if (Clear != Methods.end()) {
----------------
cjdb wrote:
> Note to other reviewers: I suggested this because we couldn't work out a better way to identify if .clear() exists (Abraham can best expand on the issues regarding how a matcher wasn't working).
Yes, I wrote a matcher for the declaration of a .clear() member function and another matcher for a call to .empty(), but it seemed like the check() function runs multiple times to match the different matchers. It would find .clear() on one run of check() and find .empty() on another, and I couldn't find a way to see if .clear() had already been found on a previous run of check().
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D128372/new/
https://reviews.llvm.org/D128372
More information about the cfe-commits
mailing list