File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2944,7 +2944,7 @@ static bool isExpressionChangedAt(const F& getExprTok,
29442944 Token::Match (tok->astOperand2 () ? tok->astOperand2 () : tok->astOperand1 (), " %varid%" , expr->varId ()))
29452945 aliased = true ;
29462946 if (!aliased)
2947- aliased = isAliasOf (tok, expr, &i);
2947+ aliased = tok-> isAliasOf (expr, &i);
29482948 if (!aliased)
29492949 return false ;
29502950 i += indirect;
Original file line number Diff line number Diff line change @@ -2760,3 +2760,19 @@ bool Token::isMutableExpr() const
27602760 mImpl ->mMutableExpr = isMutableExpression (this );
27612761 return !!mImpl ->mMutableExpr ;
27622762}
2763+
2764+ bool Token::isAliasOf (const Token* expr, int * indirect) const
2765+ {
2766+ const auto it = utils::as_const (mImpl ->mAliases ).find (expr);
2767+ if (it != mImpl ->mAliases .cend ()) {
2768+ if (indirect)
2769+ *indirect = it->second .second ;
2770+ return it->second .first ;
2771+ }
2772+ int i = 0 ;
2773+ const bool b = ::isAliasOf (this , expr, &i);
2774+ mImpl ->mAliases [expr] = std::make_pair (b, i);
2775+ if (indirect)
2776+ *indirect = i;
2777+ return b;
2778+ }
Original file line number Diff line number Diff line change 4141#include < set>
4242#include < string>
4343#include < type_traits>
44+ #include < unordered_map>
4445#include < utility>
4546#include < vector>
4647
@@ -175,6 +176,8 @@ class CPPCHECKLIB Token {
175176
176177 std::int8_t mMutableExpr {-1 };
177178
179+ std::unordered_map<const Token*, std::pair<bool , int >> mAliases ;
180+
178181 void setCppcheckAttribute (CppcheckAttributesType type, MathLib::bigint value);
179182 bool getCppcheckAttribute (CppcheckAttributesType type, MathLib::bigint &value) const ;
180183
@@ -1369,6 +1372,9 @@ class CPPCHECKLIB Token {
13691372 // provides and caches the result of a isMutableExpression() call
13701373 bool isMutableExpr () const ;
13711374
1375+ // provides and caches the result of a isAliasOf() call
1376+ bool isAliasOf (const Token* expr, int * indirect) const ;
1377+
13721378 /* *
13731379 * Sets the original name.
13741380 */
You can’t perform that action at this time.
0 commit comments