Prevent abseil-cleanup-ctad check from stomping on surrounding context
authorCJ Johnson <johnsoncj@google.com>
Thu, 9 Dec 2021 17:28:07 +0000 (17:28 +0000)
committerYitzhak Mandelbaum <yitzhakm@google.com>
Thu, 9 Dec 2021 17:41:12 +0000 (17:41 +0000)
commita1968d5341d7b1ec7889955f230d0375548d165b
tree96251a7c0e9fa4f2c779aee244630c8baa142979
parentccdd5bb2c2a80b9664e8f2e9e1abd80769f5c5a1
Prevent abseil-cleanup-ctad check from stomping on surrounding context

This change applies two fixes to the abseil-cleanup-ctad check. It uses hasSingleDecl() to ensure only declStmt()s with one varDecl() are matched (leaving compount declStmt()s unchanged). It also addresses a bug in the handling of comments that surround the absl::MakeCleanup() calls by switching to the callArgs() combinator from Clang Transformer.

Reviewed By: ymandel

Differential Revision: https://reviews.llvm.org/D115452
clang-tools-extra/clang-tidy/abseil/CleanupCtadCheck.cpp
clang-tools-extra/test/clang-tidy/checkers/abseil-cleanup-ctad.cpp