clang-tools 22.0.0git
UseAfterMoveCheck.cpp
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "UseAfterMoveCheck.h"
10
11#include "clang/AST/Expr.h"
12#include "clang/AST/ExprCXX.h"
13#include "clang/ASTMatchers/ASTMatchers.h"
14#include "clang/Analysis/Analyses/CFGReachabilityAnalysis.h"
15#include "clang/Analysis/CFG.h"
16#include "clang/Lex/Lexer.h"
17#include "llvm/ADT/STLExtras.h"
18#include "llvm/ADT/SmallPtrSet.h"
19
21#include "../utils/Matchers.h"
23#include <optional>
24
25using namespace clang::ast_matchers;
26using namespace clang::tidy::utils;
27
28namespace clang::tidy::bugprone {
29
30using matchers::hasUnevaluatedContext;
31
32namespace {
33
34/// Contains information about a use-after-move.
35struct UseAfterMove {
36 // The DeclRefExpr that constituted the use of the object.
37 const DeclRefExpr *DeclRef;
38
39 // Is the order in which the move and the use are evaluated undefined?
40 bool EvaluationOrderUndefined = false;
41
42 // Does the use happen in a later loop iteration than the move?
43 //
44 // We default to false and change it to true if required in find().
45 bool UseHappensInLaterLoopIteration = false;
46};
47
48/// Finds uses of a variable after a move (and maintains state required by the
49/// various internal helper functions).
50class UseAfterMoveFinder {
51public:
52 UseAfterMoveFinder(ASTContext *TheContext,
53 llvm::ArrayRef<StringRef> InvalidationFunctions);
54
55 // Within the given code block, finds the first use of 'MovedVariable' that
56 // occurs after 'MovingCall' (the expression that performs the move). If a
57 // use-after-move is found, writes information about it to 'TheUseAfterMove'.
58 // Returns whether a use-after-move was found.
59 std::optional<UseAfterMove> find(Stmt *CodeBlock, const Expr *MovingCall,
60 const DeclRefExpr *MovedVariable);
61
62private:
63 std::optional<UseAfterMove> findInternal(const CFGBlock *Block,
64 const Expr *MovingCall,
65 const ValueDecl *MovedVariable);
66 void getUsesAndReinits(const CFGBlock *Block, const ValueDecl *MovedVariable,
67 llvm::SmallVectorImpl<const DeclRefExpr *> *Uses,
68 llvm::SmallPtrSetImpl<const Stmt *> *Reinits);
69 void getDeclRefs(const CFGBlock *Block, const Decl *MovedVariable,
70 llvm::SmallPtrSetImpl<const DeclRefExpr *> *DeclRefs);
71 void getReinits(const CFGBlock *Block, const ValueDecl *MovedVariable,
72 llvm::SmallPtrSetImpl<const Stmt *> *Stmts,
73 llvm::SmallPtrSetImpl<const DeclRefExpr *> *DeclRefs);
74
75 ASTContext *Context;
76 llvm::ArrayRef<StringRef> InvalidationFunctions;
77 std::unique_ptr<ExprSequence> Sequence;
78 std::unique_ptr<StmtToBlockMap> BlockMap;
79 llvm::SmallPtrSet<const CFGBlock *, 8> Visited;
80};
81
82} // namespace
83
84static auto getNameMatcher(llvm::ArrayRef<StringRef> InvalidationFunctions) {
85 return anyOf(hasAnyName("::std::move", "::std::forward"),
86 matchers::matchesAnyListedName(InvalidationFunctions));
87}
88
89// Matches nodes that are
90// - Part of a decltype argument or class template argument (we check this by
91// seeing if they are children of a TypeLoc), or
92// - Part of a function template argument (we check this by seeing if they are
93// children of a DeclRefExpr that references a function template).
94// DeclRefExprs that fulfill these conditions should not be counted as a use or
95// move.
96static StatementMatcher inDecltypeOrTemplateArg() {
97 return anyOf(hasAncestor(typeLoc()),
98 hasAncestor(declRefExpr(
99 to(functionDecl(ast_matchers::isTemplateInstantiation())))),
100 hasAncestor(expr(hasUnevaluatedContext())));
101}
102
103UseAfterMoveFinder::UseAfterMoveFinder(
104 ASTContext *TheContext, llvm::ArrayRef<StringRef> InvalidationFunctions)
105 : Context(TheContext), InvalidationFunctions(InvalidationFunctions) {}
106
107std::optional<UseAfterMove>
108UseAfterMoveFinder::find(Stmt *CodeBlock, const Expr *MovingCall,
109 const DeclRefExpr *MovedVariable) {
110 // Generate the CFG manually instead of through an AnalysisDeclContext because
111 // it seems the latter can't be used to generate a CFG for the body of a
112 // lambda.
113 //
114 // We include implicit and temporary destructors in the CFG so that
115 // destructors marked [[noreturn]] are handled correctly in the control flow
116 // analysis. (These are used in some styles of assertion macros.)
117 CFG::BuildOptions Options;
118 Options.AddImplicitDtors = true;
119 Options.AddTemporaryDtors = true;
120 std::unique_ptr<CFG> TheCFG =
121 CFG::buildCFG(nullptr, CodeBlock, Context, Options);
122 if (!TheCFG)
123 return std::nullopt;
124
125 Sequence = std::make_unique<ExprSequence>(TheCFG.get(), CodeBlock, Context);
126 BlockMap = std::make_unique<StmtToBlockMap>(TheCFG.get(), Context);
127 Visited.clear();
128
129 const CFGBlock *MoveBlock = BlockMap->blockContainingStmt(MovingCall);
130 if (!MoveBlock) {
131 // This can happen if MovingCall is in a constructor initializer, which is
132 // not included in the CFG because the CFG is built only from the function
133 // body.
134 MoveBlock = &TheCFG->getEntry();
135 }
136
137 auto TheUseAfterMove =
138 findInternal(MoveBlock, MovingCall, MovedVariable->getDecl());
139
140 if (TheUseAfterMove) {
141 if (const CFGBlock *UseBlock =
142 BlockMap->blockContainingStmt(TheUseAfterMove->DeclRef)) {
143 // Does the use happen in a later loop iteration than the move?
144 // - If they are in the same CFG block, we know the use happened in a
145 // later iteration if we visited that block a second time.
146 // - Otherwise, we know the use happened in a later iteration if the
147 // move is reachable from the use.
148 CFGReverseBlockReachabilityAnalysis CFA(*TheCFG);
149 TheUseAfterMove->UseHappensInLaterLoopIteration =
150 UseBlock == MoveBlock ? Visited.contains(UseBlock)
151 : CFA.isReachable(UseBlock, MoveBlock);
152 }
153 }
154 return TheUseAfterMove;
155}
156
157std::optional<UseAfterMove>
158UseAfterMoveFinder::findInternal(const CFGBlock *Block, const Expr *MovingCall,
159 const ValueDecl *MovedVariable) {
160 if (Visited.contains(Block))
161 return std::nullopt;
162
163 // Mark the block as visited (except if this is the block containing the
164 // std::move() and it's being visited the first time).
165 if (!MovingCall)
166 Visited.insert(Block);
167
168 // Get all uses and reinits in the block.
169 llvm::SmallVector<const DeclRefExpr *, 1> Uses;
170 llvm::SmallPtrSet<const Stmt *, 1> Reinits;
171 getUsesAndReinits(Block, MovedVariable, &Uses, &Reinits);
172
173 // Ignore all reinitializations where the move potentially comes after the
174 // reinit.
175 // If `Reinit` is identical to `MovingCall`, we're looking at a move-to-self
176 // (e.g. `a = std::move(a)`). Count these as reinitializations.
177 llvm::SmallVector<const Stmt *, 1> ReinitsToDelete;
178 for (const Stmt *Reinit : Reinits)
179 if (MovingCall && Reinit != MovingCall &&
180 Sequence->potentiallyAfter(MovingCall, Reinit))
181 ReinitsToDelete.push_back(Reinit);
182 for (const Stmt *Reinit : ReinitsToDelete)
183 Reinits.erase(Reinit);
184
185 // Find all uses that potentially come after the move.
186 for (const DeclRefExpr *Use : Uses) {
187 if (!MovingCall || Sequence->potentiallyAfter(Use, MovingCall)) {
188 // Does the use have a saving reinit? A reinit is saving if it definitely
189 // comes before the use, i.e. if there's no potential that the reinit is
190 // after the use.
191 bool HaveSavingReinit = false;
192 for (const Stmt *Reinit : Reinits)
193 if (!Sequence->potentiallyAfter(Reinit, Use))
194 HaveSavingReinit = true;
195
196 if (!HaveSavingReinit) {
197 UseAfterMove TheUseAfterMove;
198 TheUseAfterMove.DeclRef = Use;
199
200 // Is this a use-after-move that depends on order of evaluation?
201 // This is the case if the move potentially comes after the use (and we
202 // already know that use potentially comes after the move, which taken
203 // together tells us that the ordering is unclear).
204 TheUseAfterMove.EvaluationOrderUndefined =
205 MovingCall != nullptr &&
206 Sequence->potentiallyAfter(MovingCall, Use);
207
208 return TheUseAfterMove;
209 }
210 }
211 }
212
213 // If the object wasn't reinitialized, call ourselves recursively on all
214 // successors.
215 if (Reinits.empty()) {
216 for (const auto &Succ : Block->succs()) {
217 if (Succ) {
218 if (auto Found = findInternal(Succ, nullptr, MovedVariable))
219 return Found;
220 }
221 }
222 }
223
224 return std::nullopt;
225}
226
227void UseAfterMoveFinder::getUsesAndReinits(
228 const CFGBlock *Block, const ValueDecl *MovedVariable,
229 llvm::SmallVectorImpl<const DeclRefExpr *> *Uses,
230 llvm::SmallPtrSetImpl<const Stmt *> *Reinits) {
231 llvm::SmallPtrSet<const DeclRefExpr *, 1> DeclRefs;
232 llvm::SmallPtrSet<const DeclRefExpr *, 1> ReinitDeclRefs;
233
234 getDeclRefs(Block, MovedVariable, &DeclRefs);
235 getReinits(Block, MovedVariable, Reinits, &ReinitDeclRefs);
236
237 // All references to the variable that aren't reinitializations are uses.
238 Uses->clear();
239 for (const DeclRefExpr *DeclRef : DeclRefs)
240 if (!ReinitDeclRefs.contains(DeclRef))
241 Uses->push_back(DeclRef);
242
243 // Sort the uses by their occurrence in the source code.
244 llvm::sort(*Uses, [](const DeclRefExpr *D1, const DeclRefExpr *D2) {
245 return D1->getExprLoc() < D2->getExprLoc();
246 });
247}
248
249static bool isStandardSmartPointer(const ValueDecl *VD) {
250 const Type *TheType = VD->getType().getNonReferenceType().getTypePtrOrNull();
251 if (!TheType)
252 return false;
253
254 const CXXRecordDecl *RecordDecl = TheType->getAsCXXRecordDecl();
255 if (!RecordDecl)
256 return false;
257
258 const IdentifierInfo *ID = RecordDecl->getIdentifier();
259 if (!ID)
260 return false;
261
262 const StringRef Name = ID->getName();
263 if (Name != "unique_ptr" && Name != "shared_ptr" && Name != "weak_ptr")
264 return false;
265
266 return RecordDecl->getDeclContext()->isStdNamespace();
267}
268
269void UseAfterMoveFinder::getDeclRefs(
270 const CFGBlock *Block, const Decl *MovedVariable,
271 llvm::SmallPtrSetImpl<const DeclRefExpr *> *DeclRefs) {
272 DeclRefs->clear();
273 for (const auto &Elem : *Block) {
274 std::optional<CFGStmt> S = Elem.getAs<CFGStmt>();
275 if (!S)
276 continue;
277
278 auto AddDeclRefs = [this, Block,
279 DeclRefs](const ArrayRef<BoundNodes> Matches) {
280 for (const auto &Match : Matches) {
281 const auto *DeclRef = Match.getNodeAs<DeclRefExpr>("declref");
282 const auto *Operator = Match.getNodeAs<CXXOperatorCallExpr>("operator");
283 if (DeclRef && BlockMap->blockContainingStmt(DeclRef) == Block) {
284 // Ignore uses of a standard smart pointer that don't dereference the
285 // pointer.
286 if (Operator || !isStandardSmartPointer(DeclRef->getDecl()))
287 DeclRefs->insert(DeclRef);
288 }
289 }
290 };
291
292 auto DeclRefMatcher = declRefExpr(hasDeclaration(equalsNode(MovedVariable)),
293 unless(inDecltypeOrTemplateArg()))
294 .bind("declref");
295
296 AddDeclRefs(match(traverse(TK_AsIs, findAll(DeclRefMatcher)), *S->getStmt(),
297 *Context));
298 AddDeclRefs(match(findAll(cxxOperatorCallExpr(
299 hasAnyOverloadedOperatorName("*", "->", "[]"),
300 hasArgument(0, DeclRefMatcher))
301 .bind("operator")),
302 *S->getStmt(), *Context));
303 }
304}
305
306void UseAfterMoveFinder::getReinits(
307 const CFGBlock *Block, const ValueDecl *MovedVariable,
308 llvm::SmallPtrSetImpl<const Stmt *> *Stmts,
309 llvm::SmallPtrSetImpl<const DeclRefExpr *> *DeclRefs) {
310 auto DeclRefMatcher =
311 declRefExpr(hasDeclaration(equalsNode(MovedVariable))).bind("declref");
312
313 auto StandardContainerTypeMatcher = hasType(hasUnqualifiedDesugaredType(
314 recordType(hasDeclaration(cxxRecordDecl(hasAnyName(
315 "::std::basic_string", "::std::vector", "::std::deque",
316 "::std::forward_list", "::std::list", "::std::set", "::std::map",
317 "::std::multiset", "::std::multimap", "::std::unordered_set",
318 "::std::unordered_map", "::std::unordered_multiset",
319 "::std::unordered_multimap"))))));
320
321 auto StandardResettableOwnerTypeMatcher = hasType(
322 hasUnqualifiedDesugaredType(recordType(hasDeclaration(cxxRecordDecl(
323 hasAnyName("::std::unique_ptr", "::std::shared_ptr",
324 "::std::weak_ptr", "::std::optional", "::std::any"))))));
325
326 // Matches different types of reinitialization.
327 auto ReinitMatcher =
328 stmt(anyOf(
329 // Assignment. In addition to the overloaded assignment operator,
330 // test for built-in assignment as well, since template functions
331 // may be instantiated to use std::move() on built-in types.
332 binaryOperation(hasOperatorName("="), hasLHS(DeclRefMatcher)),
333 // Declaration. We treat this as a type of reinitialization too,
334 // so we don't need to treat it separately.
335 declStmt(hasDescendant(equalsNode(MovedVariable))),
336 // clear() and assign() on standard containers.
337 cxxMemberCallExpr(
338 on(expr(DeclRefMatcher, StandardContainerTypeMatcher)),
339 // To keep the matcher simple, we check for assign() calls
340 // on all standard containers, even though only vector,
341 // deque, forward_list and list have assign(). If assign()
342 // is called on any of the other containers, this will be
343 // flagged by a compile error anyway.
344 callee(cxxMethodDecl(hasAnyName("clear", "assign")))),
345 // reset() on standard smart pointers.
346 cxxMemberCallExpr(
347 on(expr(DeclRefMatcher, StandardResettableOwnerTypeMatcher)),
348 callee(cxxMethodDecl(hasName("reset")))),
349 // Methods that have the [[clang::reinitializes]] attribute.
350 cxxMemberCallExpr(
351 on(DeclRefMatcher),
352 callee(cxxMethodDecl(hasAttr(clang::attr::Reinitializes)))),
353 // Passing variable to a function as a non-const pointer.
354 callExpr(forEachArgumentWithParam(
355 unaryOperator(hasOperatorName("&"),
356 hasUnaryOperand(DeclRefMatcher)),
357 unless(parmVarDecl(hasType(pointsTo(isConstQualified())))))),
358 // Passing variable to a function as a non-const lvalue reference
359 // (unless that function is std::move()).
360 callExpr(forEachArgumentWithParam(
361 traverse(TK_AsIs, DeclRefMatcher),
362 unless(parmVarDecl(hasType(
363 references(qualType(isConstQualified())))))),
364 unless(callee(functionDecl(
365 getNameMatcher(InvalidationFunctions)))))))
366 .bind("reinit");
367
368 Stmts->clear();
369 DeclRefs->clear();
370 for (const auto &Elem : *Block) {
371 std::optional<CFGStmt> S = Elem.getAs<CFGStmt>();
372 if (!S)
373 continue;
374
375 const SmallVector<BoundNodes, 1> Matches =
376 match(findAll(ReinitMatcher), *S->getStmt(), *Context);
377
378 for (const auto &Match : Matches) {
379 const auto *TheStmt = Match.getNodeAs<Stmt>("reinit");
380 const auto *TheDeclRef = Match.getNodeAs<DeclRefExpr>("declref");
381 if (TheStmt && BlockMap->blockContainingStmt(TheStmt) == Block) {
382 Stmts->insert(TheStmt);
383
384 // We count DeclStmts as reinitializations, but they don't have a
385 // DeclRefExpr associated with them -- so we need to check 'TheDeclRef'
386 // before adding it to the set.
387 if (TheDeclRef)
388 DeclRefs->insert(TheDeclRef);
389 }
390 }
391 }
392}
393
395 Forward = 0, // std::forward
396 Move = 1, // std::move
397 Invalidation = 2, // other
398};
399
400static MoveType determineMoveType(const FunctionDecl *FuncDecl) {
401 if (FuncDecl->isInStdNamespace()) {
402 if (FuncDecl->getName() == "move")
403 return MoveType::Move;
404 if (FuncDecl->getName() == "forward")
405 return MoveType::Forward;
406 }
407
409}
410
411static void emitDiagnostic(const Expr *MovingCall, const DeclRefExpr *MoveArg,
412 const UseAfterMove &Use, ClangTidyCheck *Check,
413 ASTContext *Context, MoveType Type) {
414 const SourceLocation UseLoc = Use.DeclRef->getExprLoc();
415 const SourceLocation MoveLoc = MovingCall->getExprLoc();
416
417 Check->diag(UseLoc,
418 "'%0' used after it was %select{forwarded|moved|invalidated}1")
419 << MoveArg->getDecl()->getName() << Type;
420 Check->diag(MoveLoc, "%select{forward|move|invalidation}0 occurred here",
421 DiagnosticIDs::Note)
422 << Type;
423 if (Use.EvaluationOrderUndefined) {
424 Check->diag(
425 UseLoc,
426 "the use and %select{forward|move|invalidation}0 are unsequenced, i.e. "
427 "there is no guarantee about the order in which they are evaluated",
428 DiagnosticIDs::Note)
429 << Type;
430 } else if (Use.UseHappensInLaterLoopIteration) {
431 Check->diag(UseLoc,
432 "the use happens in a later loop iteration than the "
433 "%select{forward|move|invalidation}0",
434 DiagnosticIDs::Note)
435 << Type;
436 }
437}
438
440 : ClangTidyCheck(Name, Context),
441 InvalidationFunctions(utils::options::parseStringList(
442 Options.get("InvalidationFunctions", ""))) {}
443
445 Options.store(Opts, "InvalidationFunctions",
446 utils::options::serializeStringList(InvalidationFunctions));
447}
448
449void UseAfterMoveCheck::registerMatchers(MatchFinder *Finder) {
450 // try_emplace is a common maybe-moving function that returns a
451 // bool to tell callers whether it moved. Ignore std::move inside
452 // try_emplace to avoid false positives as we don't track uses of
453 // the bool.
454 auto TryEmplaceMatcher =
455 cxxMemberCallExpr(callee(cxxMethodDecl(hasName("try_emplace"))));
456 auto Arg = declRefExpr().bind("arg");
457 auto IsMemberCallee = callee(functionDecl(unless(isStaticStorageClass())));
458 auto CallMoveMatcher =
459 callExpr(callee(functionDecl(getNameMatcher(InvalidationFunctions))
460 .bind("move-decl")),
461 anyOf(cxxMemberCallExpr(IsMemberCallee, on(Arg)),
462 callExpr(unless(cxxMemberCallExpr(IsMemberCallee)),
463 hasArgument(0, Arg))),
464 unless(inDecltypeOrTemplateArg()),
465 unless(hasParent(TryEmplaceMatcher)), expr().bind("call-move"),
466 anyOf(hasAncestor(compoundStmt(
467 hasParent(lambdaExpr().bind("containing-lambda")))),
468 hasAncestor(functionDecl(anyOf(
469 cxxConstructorDecl(
470 hasAnyConstructorInitializer(withInitializer(
471 expr(anyOf(equalsBoundNode("call-move"),
472 hasDescendant(expr(
473 equalsBoundNode("call-move")))))
474 .bind("containing-ctor-init"))))
475 .bind("containing-ctor"),
476 functionDecl().bind("containing-func"))))));
477
478 Finder->addMatcher(
479 traverse(
480 TK_AsIs,
481 // To find the Stmt that we assume performs the actual move, we look
482 // for the direct ancestor of the std::move() that isn't one of the
483 // node types ignored by ignoringParenImpCasts().
484 stmt(
485 forEach(expr(ignoringParenImpCasts(CallMoveMatcher))),
486 // Don't allow an InitListExpr to be the moving call. An
487 // InitListExpr has both a syntactic and a semantic form, and the
488 // parent-child relationships are different between the two. This
489 // could cause an InitListExpr to be analyzed as the moving call
490 // in addition to the Expr that we actually want, resulting in two
491 // diagnostics with different code locations for the same move.
492 unless(initListExpr()),
493 unless(expr(ignoringParenImpCasts(equalsBoundNode("call-move")))))
494 .bind("moving-call")),
495 this);
496}
497
498void UseAfterMoveCheck::check(const MatchFinder::MatchResult &Result) {
499 const auto *ContainingCtor =
500 Result.Nodes.getNodeAs<CXXConstructorDecl>("containing-ctor");
501 const auto *ContainingCtorInit =
502 Result.Nodes.getNodeAs<Expr>("containing-ctor-init");
503 const auto *ContainingLambda =
504 Result.Nodes.getNodeAs<LambdaExpr>("containing-lambda");
505 const auto *ContainingFunc =
506 Result.Nodes.getNodeAs<FunctionDecl>("containing-func");
507 const auto *CallMove = Result.Nodes.getNodeAs<CallExpr>("call-move");
508 const auto *MovingCall = Result.Nodes.getNodeAs<Expr>("moving-call");
509 const auto *Arg = Result.Nodes.getNodeAs<DeclRefExpr>("arg");
510 const auto *MoveDecl = Result.Nodes.getNodeAs<FunctionDecl>("move-decl");
511
512 if (!MovingCall || !MovingCall->getExprLoc().isValid())
513 MovingCall = CallMove;
514
515 // Ignore the std::move if the variable that was passed to it isn't a local
516 // variable.
517 if (!Arg->getDecl()->getDeclContext()->isFunctionOrMethod())
518 return;
519
520 // Collect all code blocks that could use the arg after move.
521 llvm::SmallVector<Stmt *> CodeBlocks{};
522 if (ContainingCtor) {
523 CodeBlocks.push_back(ContainingCtor->getBody());
524 if (ContainingCtorInit) {
525 // Collect the constructor initializer expressions.
526 bool BeforeMove{true};
527 for (const CXXCtorInitializer *Init : ContainingCtor->inits()) {
528 if (BeforeMove && Init->getInit()->IgnoreImplicit() ==
529 ContainingCtorInit->IgnoreImplicit())
530 BeforeMove = false;
531 if (!BeforeMove)
532 CodeBlocks.push_back(Init->getInit());
533 }
534 }
535 } else if (ContainingLambda) {
536 CodeBlocks.push_back(ContainingLambda->getBody());
537 } else if (ContainingFunc) {
538 CodeBlocks.push_back(ContainingFunc->getBody());
539 }
540
541 for (Stmt *CodeBlock : CodeBlocks) {
542 UseAfterMoveFinder Finder(Result.Context, InvalidationFunctions);
543 if (auto Use = Finder.find(CodeBlock, MovingCall, Arg))
544 emitDiagnostic(MovingCall, Arg, *Use, this, Result.Context,
545 determineMoveType(MoveDecl));
546 }
547}
548
549} // namespace clang::tidy::bugprone
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
UseAfterMoveCheck(StringRef Name, ClangTidyContext *Context)
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
void registerMatchers(ast_matchers::MatchFinder *Finder) override
std::vector< std::string > match(const SymbolIndex &I, const FuzzyFindRequest &Req, bool *Incomplete)
static void emitDiagnostic(const Expr *MovingCall, const DeclRefExpr *MoveArg, const UseAfterMove &Use, ClangTidyCheck *Check, ASTContext *Context, MoveType Type)
static bool isStandardSmartPointer(const ValueDecl *VD)
static MoveType determineMoveType(const FunctionDecl *FuncDecl)
static auto getNameMatcher(llvm::ArrayRef< StringRef > InvalidationFunctions)
static StatementMatcher inDecltypeOrTemplateArg()
inline ::clang::ast_matchers::internal::Matcher< NamedDecl > matchesAnyListedName(llvm::ArrayRef< StringRef > NameList)
std::string serializeStringList(ArrayRef< StringRef > Strings)
Serialize a sequence of names that can be parsed by parseStringList.
llvm::StringMap< ClangTidyValue > OptionMap
static constexpr const char FuncDecl[]