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 }
183 for (const Stmt *Reinit : ReinitsToDelete) {
184 Reinits.erase(Reinit);
185 }
186
187 // Find all uses that potentially come after the move.
188 for (const DeclRefExpr *Use : Uses) {
189 if (!MovingCall || Sequence->potentiallyAfter(Use, MovingCall)) {
190 // Does the use have a saving reinit? A reinit is saving if it definitely
191 // comes before the use, i.e. if there's no potential that the reinit is
192 // after the use.
193 bool HaveSavingReinit = false;
194 for (const Stmt *Reinit : Reinits) {
195 if (!Sequence->potentiallyAfter(Reinit, Use))
196 HaveSavingReinit = true;
197 }
198
199 if (!HaveSavingReinit) {
200 UseAfterMove TheUseAfterMove;
201 TheUseAfterMove.DeclRef = Use;
202
203 // Is this a use-after-move that depends on order of evaluation?
204 // This is the case if the move potentially comes after the use (and we
205 // already know that use potentially comes after the move, which taken
206 // together tells us that the ordering is unclear).
207 TheUseAfterMove.EvaluationOrderUndefined =
208 MovingCall != nullptr &&
209 Sequence->potentiallyAfter(MovingCall, Use);
210
211 return TheUseAfterMove;
212 }
213 }
214 }
215
216 // If the object wasn't reinitialized, call ourselves recursively on all
217 // successors.
218 if (Reinits.empty()) {
219 for (const auto &Succ : Block->succs()) {
220 if (Succ) {
221 if (auto Found = findInternal(Succ, nullptr, MovedVariable)) {
222 return Found;
223 }
224 }
225 }
226 }
227
228 return std::nullopt;
229}
230
231void UseAfterMoveFinder::getUsesAndReinits(
232 const CFGBlock *Block, const ValueDecl *MovedVariable,
233 llvm::SmallVectorImpl<const DeclRefExpr *> *Uses,
234 llvm::SmallPtrSetImpl<const Stmt *> *Reinits) {
235 llvm::SmallPtrSet<const DeclRefExpr *, 1> DeclRefs;
236 llvm::SmallPtrSet<const DeclRefExpr *, 1> ReinitDeclRefs;
237
238 getDeclRefs(Block, MovedVariable, &DeclRefs);
239 getReinits(Block, MovedVariable, Reinits, &ReinitDeclRefs);
240
241 // All references to the variable that aren't reinitializations are uses.
242 Uses->clear();
243 for (const DeclRefExpr *DeclRef : DeclRefs) {
244 if (!ReinitDeclRefs.contains(DeclRef))
245 Uses->push_back(DeclRef);
246 }
247
248 // Sort the uses by their occurrence in the source code.
249 llvm::sort(*Uses, [](const DeclRefExpr *D1, const DeclRefExpr *D2) {
250 return D1->getExprLoc() < D2->getExprLoc();
251 });
252}
253
254static bool isStandardSmartPointer(const ValueDecl *VD) {
255 const Type *TheType = VD->getType().getNonReferenceType().getTypePtrOrNull();
256 if (!TheType)
257 return false;
258
259 const CXXRecordDecl *RecordDecl = TheType->getAsCXXRecordDecl();
260 if (!RecordDecl)
261 return false;
262
263 const IdentifierInfo *ID = RecordDecl->getIdentifier();
264 if (!ID)
265 return false;
266
267 const StringRef Name = ID->getName();
268 if (Name != "unique_ptr" && Name != "shared_ptr" && Name != "weak_ptr")
269 return false;
270
271 return RecordDecl->getDeclContext()->isStdNamespace();
272}
273
274void UseAfterMoveFinder::getDeclRefs(
275 const CFGBlock *Block, const Decl *MovedVariable,
276 llvm::SmallPtrSetImpl<const DeclRefExpr *> *DeclRefs) {
277 DeclRefs->clear();
278 for (const auto &Elem : *Block) {
279 std::optional<CFGStmt> S = Elem.getAs<CFGStmt>();
280 if (!S)
281 continue;
282
283 auto AddDeclRefs = [this, Block,
284 DeclRefs](const ArrayRef<BoundNodes> Matches) {
285 for (const auto &Match : Matches) {
286 const auto *DeclRef = Match.getNodeAs<DeclRefExpr>("declref");
287 const auto *Operator = Match.getNodeAs<CXXOperatorCallExpr>("operator");
288 if (DeclRef && BlockMap->blockContainingStmt(DeclRef) == Block) {
289 // Ignore uses of a standard smart pointer that don't dereference the
290 // pointer.
291 if (Operator || !isStandardSmartPointer(DeclRef->getDecl())) {
292 DeclRefs->insert(DeclRef);
293 }
294 }
295 }
296 };
297
298 auto DeclRefMatcher = declRefExpr(hasDeclaration(equalsNode(MovedVariable)),
299 unless(inDecltypeOrTemplateArg()))
300 .bind("declref");
301
302 AddDeclRefs(match(traverse(TK_AsIs, findAll(DeclRefMatcher)), *S->getStmt(),
303 *Context));
304 AddDeclRefs(match(findAll(cxxOperatorCallExpr(
305 hasAnyOverloadedOperatorName("*", "->", "[]"),
306 hasArgument(0, DeclRefMatcher))
307 .bind("operator")),
308 *S->getStmt(), *Context));
309 }
310}
311
312void UseAfterMoveFinder::getReinits(
313 const CFGBlock *Block, const ValueDecl *MovedVariable,
314 llvm::SmallPtrSetImpl<const Stmt *> *Stmts,
315 llvm::SmallPtrSetImpl<const DeclRefExpr *> *DeclRefs) {
316 auto DeclRefMatcher =
317 declRefExpr(hasDeclaration(equalsNode(MovedVariable))).bind("declref");
318
319 auto StandardContainerTypeMatcher = hasType(hasUnqualifiedDesugaredType(
320 recordType(hasDeclaration(cxxRecordDecl(hasAnyName(
321 "::std::basic_string", "::std::vector", "::std::deque",
322 "::std::forward_list", "::std::list", "::std::set", "::std::map",
323 "::std::multiset", "::std::multimap", "::std::unordered_set",
324 "::std::unordered_map", "::std::unordered_multiset",
325 "::std::unordered_multimap"))))));
326
327 auto StandardResettableOwnerTypeMatcher = hasType(
328 hasUnqualifiedDesugaredType(recordType(hasDeclaration(cxxRecordDecl(
329 hasAnyName("::std::unique_ptr", "::std::shared_ptr",
330 "::std::weak_ptr", "::std::optional", "::std::any"))))));
331
332 // Matches different types of reinitialization.
333 auto ReinitMatcher =
334 stmt(anyOf(
335 // Assignment. In addition to the overloaded assignment operator,
336 // test for built-in assignment as well, since template functions
337 // may be instantiated to use std::move() on built-in types.
338 binaryOperation(hasOperatorName("="), hasLHS(DeclRefMatcher)),
339 // Declaration. We treat this as a type of reinitialization too,
340 // so we don't need to treat it separately.
341 declStmt(hasDescendant(equalsNode(MovedVariable))),
342 // clear() and assign() on standard containers.
343 cxxMemberCallExpr(
344 on(expr(DeclRefMatcher, StandardContainerTypeMatcher)),
345 // To keep the matcher simple, we check for assign() calls
346 // on all standard containers, even though only vector,
347 // deque, forward_list and list have assign(). If assign()
348 // is called on any of the other containers, this will be
349 // flagged by a compile error anyway.
350 callee(cxxMethodDecl(hasAnyName("clear", "assign")))),
351 // reset() on standard smart pointers.
352 cxxMemberCallExpr(
353 on(expr(DeclRefMatcher, StandardResettableOwnerTypeMatcher)),
354 callee(cxxMethodDecl(hasName("reset")))),
355 // Methods that have the [[clang::reinitializes]] attribute.
356 cxxMemberCallExpr(
357 on(DeclRefMatcher),
358 callee(cxxMethodDecl(hasAttr(clang::attr::Reinitializes)))),
359 // Passing variable to a function as a non-const pointer.
360 callExpr(forEachArgumentWithParam(
361 unaryOperator(hasOperatorName("&"),
362 hasUnaryOperand(DeclRefMatcher)),
363 unless(parmVarDecl(hasType(pointsTo(isConstQualified())))))),
364 // Passing variable to a function as a non-const lvalue reference
365 // (unless that function is std::move()).
366 callExpr(forEachArgumentWithParam(
367 traverse(TK_AsIs, DeclRefMatcher),
368 unless(parmVarDecl(hasType(
369 references(qualType(isConstQualified())))))),
370 unless(callee(functionDecl(
371 getNameMatcher(InvalidationFunctions)))))))
372 .bind("reinit");
373
374 Stmts->clear();
375 DeclRefs->clear();
376 for (const auto &Elem : *Block) {
377 std::optional<CFGStmt> S = Elem.getAs<CFGStmt>();
378 if (!S)
379 continue;
380
381 const SmallVector<BoundNodes, 1> Matches =
382 match(findAll(ReinitMatcher), *S->getStmt(), *Context);
383
384 for (const auto &Match : Matches) {
385 const auto *TheStmt = Match.getNodeAs<Stmt>("reinit");
386 const auto *TheDeclRef = Match.getNodeAs<DeclRefExpr>("declref");
387 if (TheStmt && BlockMap->blockContainingStmt(TheStmt) == Block) {
388 Stmts->insert(TheStmt);
389
390 // We count DeclStmts as reinitializations, but they don't have a
391 // DeclRefExpr associated with them -- so we need to check 'TheDeclRef'
392 // before adding it to the set.
393 if (TheDeclRef)
394 DeclRefs->insert(TheDeclRef);
395 }
396 }
397 }
398}
399
401 Forward = 0, // std::forward
402 Move = 1, // std::move
403 Invalidation = 2, // other
404};
405
406static MoveType determineMoveType(const FunctionDecl *FuncDecl) {
407 if (FuncDecl->isInStdNamespace()) {
408 if (FuncDecl->getName() == "move")
409 return MoveType::Move;
410 if (FuncDecl->getName() == "forward")
411 return MoveType::Forward;
412 }
413
415}
416
417static void emitDiagnostic(const Expr *MovingCall, const DeclRefExpr *MoveArg,
418 const UseAfterMove &Use, ClangTidyCheck *Check,
419 ASTContext *Context, MoveType Type) {
420 const SourceLocation UseLoc = Use.DeclRef->getExprLoc();
421 const SourceLocation MoveLoc = MovingCall->getExprLoc();
422
423 Check->diag(UseLoc,
424 "'%0' used after it was %select{forwarded|moved|invalidated}1")
425 << MoveArg->getDecl()->getName() << Type;
426 Check->diag(MoveLoc, "%select{forward|move|invalidation}0 occurred here",
427 DiagnosticIDs::Note)
428 << Type;
429 if (Use.EvaluationOrderUndefined) {
430 Check->diag(
431 UseLoc,
432 "the use and %select{forward|move|invalidation}0 are unsequenced, i.e. "
433 "there is no guarantee about the order in which they are evaluated",
434 DiagnosticIDs::Note)
435 << Type;
436 } else if (Use.UseHappensInLaterLoopIteration) {
437 Check->diag(UseLoc,
438 "the use happens in a later loop iteration than the "
439 "%select{forward|move|invalidation}0",
440 DiagnosticIDs::Note)
441 << Type;
442 }
443}
444
446 : ClangTidyCheck(Name, Context),
447 InvalidationFunctions(utils::options::parseStringList(
448 Options.get("InvalidationFunctions", ""))) {}
449
451 Options.store(Opts, "InvalidationFunctions",
452 utils::options::serializeStringList(InvalidationFunctions));
453}
454
455void UseAfterMoveCheck::registerMatchers(MatchFinder *Finder) {
456 // try_emplace is a common maybe-moving function that returns a
457 // bool to tell callers whether it moved. Ignore std::move inside
458 // try_emplace to avoid false positives as we don't track uses of
459 // the bool.
460 auto TryEmplaceMatcher =
461 cxxMemberCallExpr(callee(cxxMethodDecl(hasName("try_emplace"))));
462 auto Arg = declRefExpr().bind("arg");
463 auto IsMemberCallee = callee(functionDecl(unless(isStaticStorageClass())));
464 auto CallMoveMatcher =
465 callExpr(callee(functionDecl(getNameMatcher(InvalidationFunctions))
466 .bind("move-decl")),
467 anyOf(cxxMemberCallExpr(IsMemberCallee, on(Arg)),
468 callExpr(unless(cxxMemberCallExpr(IsMemberCallee)),
469 hasArgument(0, Arg))),
470 unless(inDecltypeOrTemplateArg()),
471 unless(hasParent(TryEmplaceMatcher)), expr().bind("call-move"),
472 anyOf(hasAncestor(compoundStmt(
473 hasParent(lambdaExpr().bind("containing-lambda")))),
474 hasAncestor(functionDecl(anyOf(
475 cxxConstructorDecl(
476 hasAnyConstructorInitializer(withInitializer(
477 expr(anyOf(equalsBoundNode("call-move"),
478 hasDescendant(expr(
479 equalsBoundNode("call-move")))))
480 .bind("containing-ctor-init"))))
481 .bind("containing-ctor"),
482 functionDecl().bind("containing-func"))))));
483
484 Finder->addMatcher(
485 traverse(
486 TK_AsIs,
487 // To find the Stmt that we assume performs the actual move, we look
488 // for the direct ancestor of the std::move() that isn't one of the
489 // node types ignored by ignoringParenImpCasts().
490 stmt(
491 forEach(expr(ignoringParenImpCasts(CallMoveMatcher))),
492 // Don't allow an InitListExpr to be the moving call. An
493 // InitListExpr has both a syntactic and a semantic form, and the
494 // parent-child relationships are different between the two. This
495 // could cause an InitListExpr to be analyzed as the moving call
496 // in addition to the Expr that we actually want, resulting in two
497 // diagnostics with different code locations for the same move.
498 unless(initListExpr()),
499 unless(expr(ignoringParenImpCasts(equalsBoundNode("call-move")))))
500 .bind("moving-call")),
501 this);
502}
503
504void UseAfterMoveCheck::check(const MatchFinder::MatchResult &Result) {
505 const auto *ContainingCtor =
506 Result.Nodes.getNodeAs<CXXConstructorDecl>("containing-ctor");
507 const auto *ContainingCtorInit =
508 Result.Nodes.getNodeAs<Expr>("containing-ctor-init");
509 const auto *ContainingLambda =
510 Result.Nodes.getNodeAs<LambdaExpr>("containing-lambda");
511 const auto *ContainingFunc =
512 Result.Nodes.getNodeAs<FunctionDecl>("containing-func");
513 const auto *CallMove = Result.Nodes.getNodeAs<CallExpr>("call-move");
514 const auto *MovingCall = Result.Nodes.getNodeAs<Expr>("moving-call");
515 const auto *Arg = Result.Nodes.getNodeAs<DeclRefExpr>("arg");
516 const auto *MoveDecl = Result.Nodes.getNodeAs<FunctionDecl>("move-decl");
517
518 if (!MovingCall || !MovingCall->getExprLoc().isValid())
519 MovingCall = CallMove;
520
521 // Ignore the std::move if the variable that was passed to it isn't a local
522 // variable.
523 if (!Arg->getDecl()->getDeclContext()->isFunctionOrMethod())
524 return;
525
526 // Collect all code blocks that could use the arg after move.
527 llvm::SmallVector<Stmt *> CodeBlocks{};
528 if (ContainingCtor) {
529 CodeBlocks.push_back(ContainingCtor->getBody());
530 if (ContainingCtorInit) {
531 // Collect the constructor initializer expressions.
532 bool BeforeMove{true};
533 for (const CXXCtorInitializer *Init : ContainingCtor->inits()) {
534 if (BeforeMove && Init->getInit()->IgnoreImplicit() ==
535 ContainingCtorInit->IgnoreImplicit())
536 BeforeMove = false;
537 if (!BeforeMove)
538 CodeBlocks.push_back(Init->getInit());
539 }
540 }
541 } else if (ContainingLambda) {
542 CodeBlocks.push_back(ContainingLambda->getBody());
543 } else if (ContainingFunc) {
544 CodeBlocks.push_back(ContainingFunc->getBody());
545 }
546
547 for (Stmt *CodeBlock : CodeBlocks) {
548 UseAfterMoveFinder Finder(Result.Context, InvalidationFunctions);
549 if (auto Use = Finder.find(CodeBlock, MovingCall, Arg))
550 emitDiagnostic(MovingCall, Arg, *Use, this, Result.Context,
551 determineMoveType(MoveDecl));
552 }
553}
554
555} // 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[]