@@ -95,16 +95,14 @@ class MatchResult {
9595
9696public:
9797 template <typename T> const T *getNodeAs (StringRef ID) const {
98- auto It = Nodes.find (std::string (ID) );
98+ auto It = Nodes.find (ID );
9999 if (It == Nodes.end ()) {
100100 return nullptr ;
101101 }
102102 return It->second .get <T>();
103103 }
104104
105- void addNode (StringRef ID, const DynTypedNode &Node) {
106- Nodes[std::string (ID)] = Node;
107- }
105+ void addNode (StringRef ID, const DynTypedNode &Node) { Nodes[ID] = Node; }
108106
109107private:
110108 llvm::StringMap<DynTypedNode> Nodes;
@@ -257,8 +255,8 @@ static void
257255forEachDescendantEvaluatedStmt (const Stmt *S, ASTContext &Ctx,
258256 const UnsafeBufferUsageHandler &Handler,
259257 FastMatcher &Matcher) {
260- MatchDescendantVisitor Visitor (Matcher, /* FindAll */ true ,
261- /* ignoreUnevaluatedContext*/ true );
258+ MatchDescendantVisitor Visitor (Matcher, /* FindAll= */ true ,
259+ /* ignoreUnevaluatedContext= */ true );
262260 Visitor.setASTContext (Ctx);
263261 Visitor.setHandler (Handler);
264262 Visitor.findMatch (DynTypedNode::create (*S));
@@ -267,8 +265,8 @@ forEachDescendantEvaluatedStmt(const Stmt *S, ASTContext &Ctx,
267265static void forEachDescendantStmt (const Stmt *S, ASTContext &Ctx,
268266 const UnsafeBufferUsageHandler &Handler,
269267 FastMatcher &Matcher) {
270- MatchDescendantVisitor Visitor (Matcher, /* FindAll */ true ,
271- /* ignoreUnevaluatedContext*/ false );
268+ MatchDescendantVisitor Visitor (Matcher, /* FindAll= */ true ,
269+ /* ignoreUnevaluatedContext= */ false );
272270 Visitor.setASTContext (Ctx);
273271 Visitor.setHandler (Handler);
274272 Visitor.findMatch (DynTypedNode::create (*S));
@@ -1197,7 +1195,7 @@ class FixableGadget : public Gadget {
11971195 }
11981196};
11991197
1200- static auto toSupportedVariable (const DeclRefExpr &Node) {
1198+ static bool isSupportedVariable (const DeclRefExpr &Node) {
12011199 const Decl *D = Node.getDecl ();
12021200 return D != nullptr && isa<VarDecl>(D);
12031201}
@@ -1357,7 +1355,7 @@ class PointerArithmeticGadget : public WarningGadget {
13571355public:
13581356 PointerArithmeticGadget (const MatchResult &Result)
13591357 : WarningGadget(Kind::PointerArithmetic),
1360- PA (( Result.getNodeAs<BinaryOperator>(PointerArithmeticTag) )),
1358+ PA (Result.getNodeAs<BinaryOperator>(PointerArithmeticTag)),
13611359 Ptr(Result.getNodeAs<Expr>(PointerArithmeticPointerTag)) {}
13621360
13631361 static bool classof (const Gadget *G) {
@@ -1497,7 +1495,7 @@ class PointerInitGadget : public FixableGadget {
14971495 if (!Init)
14981496 return false ;
14991497 const auto *DRE = dyn_cast<DeclRefExpr>(Init->IgnoreImpCasts ());
1500- if (!DRE || !hasPointerType (*DRE) || !toSupportedVariable (*DRE)) {
1498+ if (!DRE || !hasPointerType (*DRE) || !isSupportedVariable (*DRE)) {
15011499 return false ;
15021500 }
15031501 MatchResult R;
@@ -1554,13 +1552,13 @@ class PtrToPtrAssignmentGadget : public FixableGadget {
15541552 const auto *RHS = BO->getRHS ()->IgnoreParenImpCasts ();
15551553 if (const auto *RHSRef = dyn_cast<DeclRefExpr>(RHS);
15561554 !RHSRef || !hasPointerType (*RHSRef) ||
1557- !toSupportedVariable (*RHSRef)) {
1555+ !isSupportedVariable (*RHSRef)) {
15581556 return ;
15591557 }
15601558 const auto *LHS = BO->getLHS ();
15611559 if (const auto *LHSRef = dyn_cast<DeclRefExpr>(LHS);
15621560 !LHSRef || !hasPointerType (*LHSRef) ||
1563- !toSupportedVariable (*LHSRef)) {
1561+ !isSupportedVariable (*LHSRef)) {
15641562 return ;
15651563 }
15661564 MatchResult R;
@@ -1619,13 +1617,13 @@ class CArrayToPtrAssignmentGadget : public FixableGadget {
16191617 if (const auto *RHSRef = dyn_cast<DeclRefExpr>(RHS);
16201618 !RHSRef ||
16211619 !isa<ConstantArrayType>(RHSRef->getType ().getCanonicalType ()) ||
1622- !toSupportedVariable (*RHSRef)) {
1620+ !isSupportedVariable (*RHSRef)) {
16231621 return ;
16241622 }
16251623 const auto *LHS = BO->getLHS ();
16261624 if (const auto *LHSRef = dyn_cast<DeclRefExpr>(LHS);
16271625 !LHSRef || !hasPointerType (*LHSRef) ||
1628- !toSupportedVariable (*LHSRef)) {
1626+ !isSupportedVariable (*LHSRef)) {
16291627 return ;
16301628 }
16311629 MatchResult R;
@@ -1935,7 +1933,7 @@ class ULCArraySubscriptGadget : public FixableGadget {
19351933 const auto *DRE =
19361934 dyn_cast<DeclRefExpr>(ASE->getBase ()->IgnoreParenImpCasts ());
19371935 if (!DRE || (!hasPointerType (*DRE) && !hasArrayType (*DRE)) ||
1938- !toSupportedVariable (*DRE))
1936+ !isSupportedVariable (*DRE))
19391937 return ;
19401938 MatchResult R;
19411939 R.addNode (ULCArraySubscriptTag, DynTypedNode::create (*ASE));
@@ -1985,7 +1983,7 @@ class UPCStandalonePointerGadget : public FixableGadget {
19851983 return ;
19861984 const auto *DRE = dyn_cast<DeclRefExpr>(E->IgnoreParenImpCasts ());
19871985 if (!DRE || (!hasPointerType (*DRE) && !hasArrayType (*DRE)) ||
1988- !toSupportedVariable (*DRE))
1986+ !isSupportedVariable (*DRE))
19891987 return ;
19901988 MatchResult R;
19911989 R.addNode (DeclRefExprTag, DynTypedNode::create (*DRE));
@@ -2031,7 +2029,7 @@ class PointerDereferenceGadget : public FixableGadget {
20312029 continue ;
20322030 CE = CE->IgnoreParenImpCasts ();
20332031 const auto *DRE = dyn_cast<DeclRefExpr>(CE);
2034- if (!DRE || !toSupportedVariable (*DRE))
2032+ if (!DRE || !isSupportedVariable (*DRE))
20352033 continue ;
20362034 MatchResult R;
20372035 R.addNode (BaseDeclRefExprTag, DynTypedNode::create (*DRE));
@@ -2087,7 +2085,7 @@ class UPCAddressofArraySubscriptGadget : public FixableGadget {
20872085 return ;
20882086 const auto *DRE =
20892087 dyn_cast<DeclRefExpr>(ASE->getBase ()->IgnoreParenImpCasts ());
2090- if (!DRE || !toSupportedVariable (*DRE))
2088+ if (!DRE || !isSupportedVariable (*DRE))
20912089 return ;
20922090 MatchResult R;
20932091 R.addNode (UPCAddressofArraySubscriptTag, DynTypedNode::create (*UO));
@@ -2209,7 +2207,7 @@ class UPCPreIncrementGadget : public FixableGadget {
22092207 if (!UO || UO->getOpcode () != UO_PreInc)
22102208 return ;
22112209 const auto *DRE = dyn_cast<DeclRefExpr>(UO->getSubExpr ());
2212- if (!DRE || !toSupportedVariable (*DRE))
2210+ if (!DRE || !isSupportedVariable (*DRE))
22132211 return ;
22142212 MatchResult R;
22152213 R.addNode (UPCPreIncrementTag, DynTypedNode::create (*UO));
@@ -2261,7 +2259,7 @@ class UUCAddAssignGadget : public FixableGadget {
22612259 if (!BO || BO->getOpcode () != BO_AddAssign)
22622260 return ;
22632261 const auto *DRE = dyn_cast<DeclRefExpr>(BO->getLHS ());
2264- if (!DRE || !hasPointerType (*DRE) || !toSupportedVariable (*DRE) ||
2262+ if (!DRE || !hasPointerType (*DRE) || !isSupportedVariable (*DRE) ||
22652263 !isa<Expr>(BO->getRHS ()))
22662264 return ;
22672265 MatchResult R;
@@ -2309,7 +2307,7 @@ class DerefSimplePtrArithFixableGadget : public FixableGadget {
23092307 if (!E || !hasPointerType (*E))
23102308 return false ;
23112309 const auto *DRE = dyn_cast<DeclRefExpr>(E->IgnoreImpCasts ());
2312- if (!DRE || !toSupportedVariable (*DRE))
2310+ if (!DRE || !isSupportedVariable (*DRE))
23132311 return false ;
23142312 R.addNode (BaseDeclRefExprTag, DynTypedNode::create (*DRE));
23152313 return true ;
@@ -3055,7 +3053,7 @@ static inline std::optional<FixItList> createDataFixit(const ASTContext &Ctx,
30553053// `DRE.data()`
30563054std::optional<FixItList>
30573055UPCStandalonePointerGadget::getFixits (const FixitStrategy &S) const {
3058- const auto *const VD = cast<VarDecl>(Node->getDecl ());
3056+ auto *VD = cast<VarDecl>(Node->getDecl ());
30593057 switch (S.lookup (VD)) {
30603058 case FixitStrategy::Kind::Array:
30613059 case FixitStrategy::Kind::Span: {
0 commit comments