@@ -117,6 +117,8 @@ class CPPCHECKLIB Token {
117117 Token* mAstOperand1 {};
118118 Token* mAstOperand2 {};
119119 Token* mAstParent {};
120+ Token* mAstTop {};
121+ std::list<Token *> mAstChildren ;
120122
121123 // symbol database information
122124 const Scope* mScope {};
@@ -400,6 +402,9 @@ class CPPCHECKLIB Token {
400402 mTokType == eBoolean || mTokType == eLiteral || mTokType == eEnumerator);
401403 setFlag (fIsLiteral , memoizedIsLiteral);
402404 }
405+ bool isTopSet () const {
406+ return mImpl ->mAstTop != nullptr ;
407+ }
403408 bool isKeyword () const {
404409 return mTokType == eKeyword;
405410 }
@@ -1557,6 +1562,11 @@ class CPPCHECKLIB Token {
15571562 * @throws InternalError thrown on cyclic dependency
15581563 */
15591564 void astParent (Token* tok);
1565+ void astTop (Token * tok) {
1566+ if (tok) {
1567+ mImpl ->mAstTop = tok;
1568+ }
1569+ }
15601570
15611571 Token * astOperand1 () {
15621572 return mImpl ->mAstOperand1 ;
@@ -1576,6 +1586,12 @@ class CPPCHECKLIB Token {
15761586 const Token * astParent () const {
15771587 return mImpl ->mAstParent ;
15781588 }
1589+ std::list<Token *> astChildren () {
1590+ return mImpl ->mAstChildren ;
1591+ }
1592+ const std::list<Token *> astChildren () const {
1593+ return mImpl ->mAstChildren ;
1594+ }
15791595 Token * astSibling () {
15801596 if (!astParent ())
15811597 return nullptr ;
@@ -1597,13 +1613,19 @@ class CPPCHECKLIB Token {
15971613
15981614 }
15991615 RET_NONNULL Token *astTop () {
1616+ if (mImpl ->mAstTop ) {
1617+ return mImpl ->mAstTop ;
1618+ }
16001619 Token *ret = this ;
16011620 while (ret->mImpl ->mAstParent )
16021621 ret = ret->mImpl ->mAstParent ;
16031622 return ret;
16041623 }
16051624
16061625 RET_NONNULL const Token *astTop () const {
1626+ if (mImpl ->mAstTop ) {
1627+ return mImpl ->mAstTop ;
1628+ }
16071629 const Token *ret = this ;
16081630 while (ret->mImpl ->mAstParent )
16091631 ret = ret->mImpl ->mAstParent ;
0 commit comments