File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2947,7 +2947,7 @@ static bool isExpressionChangedAt(const F& getExprTok,
29472947 Token::Match (tok->astOperand2 () ? tok->astOperand2 () : tok->astOperand1 (), " %varid%" , expr->varId ()))
29482948 aliased = true ;
29492949 if (!aliased)
2950- aliased = isAliasOf (tok, expr, &i);
2950+ aliased = tok-> isAliasOf (expr, &i);
29512951 if (!aliased)
29522952 return false ;
29532953 i += indirect;
Original file line number Diff line number Diff line change @@ -2753,3 +2753,20 @@ const SmallVector<ReferenceToken>& Token::refs(bool temporary) const
27532753 mImpl ->mRefs .reset (new SmallVector<ReferenceToken>(followAllReferences (this , false )));
27542754 return *mImpl ->mRefs ;
27552755}
2756+
2757+ bool Token::isAliasOf (const Token* expr, int * indirect) const
2758+ {
2759+ auto it = mImpl ->mAliases .find (expr);
2760+ if (it != mImpl ->mAliases .end ()) {
2761+ if (indirect)
2762+ *indirect = it->second .second ;
2763+ return it->second .first ;
2764+ }
2765+ int i = 0 ;
2766+ const bool b = ::isAliasOf (this , expr, &i);
2767+ mImpl ->mAliases [expr] = std::make_pair (b, i);
2768+ if (indirect)
2769+ *indirect = i;
2770+ return b;
2771+ }
2772+
Original file line number Diff line number Diff line change @@ -173,6 +173,8 @@ class CPPCHECKLIB Token {
173173 std::unique_ptr<SmallVector<ReferenceToken>> mRefs ;
174174 std::unique_ptr<SmallVector<ReferenceToken>> mRefsTemp ;
175175
176+ std::map<const Token*, std::pair<bool , int >> mAliases ;
177+
176178 void setCppcheckAttribute (CppcheckAttributesType type, MathLib::bigint value);
177179 bool getCppcheckAttribute (CppcheckAttributesType type, MathLib::bigint &value) const ;
178180
@@ -1364,6 +1366,8 @@ class CPPCHECKLIB Token {
13641366 // provides and caches result of a followAllReferences() call
13651367 const SmallVector<ReferenceToken>& refs (bool temporary = true ) const ;
13661368
1369+ bool isAliasOf (const Token* expr, int * indirect) const ;
1370+
13671371 /* *
13681372 * Sets the original name.
13691373 */
You can’t perform that action at this time.
0 commit comments