@@ -63,100 +63,6 @@ struct ScopeInfo2 {
6363
6464enum class TokenDebug : std::uint8_t { None, ValueFlow, ValueType };
6565
66- struct TokenImpl {
67- nonneg int mVarId {};
68- nonneg int mFileIndex {};
69- nonneg int mLineNumber {};
70- nonneg int mColumn {};
71- nonneg int mExprId {};
72-
73- // original template argument location
74- int mTemplateArgFileIndex {-1 };
75- int mTemplateArgLineNumber {-1 };
76- int mTemplateArgColumn {-1 };
77-
78- /* *
79- * A value from 0-100 that provides a rough idea about where in the token
80- * list this token is located.
81- */
82- nonneg int mProgressValue {};
83-
84- /* *
85- * Token index. Position in token list
86- */
87- nonneg int mIndex {};
88-
89- /* * Bitfield bit count. */
90- short mBits = -1 ;
91-
92- // AST..
93- Token* mAstOperand1 {};
94- Token* mAstOperand2 {};
95- Token* mAstParent {};
96-
97- // symbol database information
98- const Scope* mScope {};
99- union {
100- const Function *mFunction ;
101- const Variable *mVariable ;
102- const ::Type* mType ;
103- const Enumerator *mEnumerator ;
104- };
105-
106- // original name like size_t
107- std::string* mOriginalName {};
108-
109- // If this token came from a macro replacement list, this is the name of that macro
110- std::string* mMacroName {};
111-
112- // ValueType
113- ValueType* mValueType {};
114-
115- // ValueFlow
116- std::list<ValueFlow::Value>* mValues {};
117- static const std::list<ValueFlow::Value> mEmptyValueList ;
118-
119- // Pointer to a template in the template simplifier
120- std::set<TemplateSimplifier::TokenAndName*>* mTemplateSimplifierPointers {};
121-
122- // Pointer to the object representing this token's scope
123- std::shared_ptr<ScopeInfo2> mScopeInfo ;
124-
125- // __cppcheck_in_range__
126- struct CppcheckAttributes {
127- enum Type : std::uint8_t { LOW, HIGH } type = LOW;
128- MathLib::bigint value{};
129- CppcheckAttributes* next{};
130- };
131- CppcheckAttributes* mCppcheckAttributes {};
132-
133- // alignas expressions
134- std::unique_ptr<std::vector<std::string>> mAttributeAlignas ;
135- void addAttributeAlignas (const std::string& a) {
136- if (!mAttributeAlignas )
137- mAttributeAlignas = std::unique_ptr<std::vector<std::string>>(new std::vector<std::string>());
138- if (std::find (mAttributeAlignas ->cbegin (), mAttributeAlignas ->cend (), a) == mAttributeAlignas ->cend ())
139- mAttributeAlignas ->push_back (a);
140- }
141-
142- std::string mAttributeCleanup ;
143-
144- // For memoization, to speed up parsing of huge arrays #8897
145- enum class Cpp11init : std::uint8_t { UNKNOWN, CPP11INIT, NOINIT } mCpp11init = Cpp11init::UNKNOWN;
146-
147- TokenDebug mDebug {};
148-
149- void setCppcheckAttribute (CppcheckAttributes::Type type, MathLib::bigint value);
150- bool getCppcheckAttribute (CppcheckAttributes::Type type, MathLib::bigint &value) const ;
151-
152- TokenImpl () : mFunction (nullptr ) {}
153-
154- ~TokenImpl ();
155-
156- TokenImpl (const TokenImpl &) = delete ;
157- TokenImpl operator =(const TokenImpl &) = delete ;
158- };
159-
16066// / @addtogroup Core
16167// / @{
16268
@@ -173,7 +79,104 @@ struct TokenImpl {
17379class CPPCHECKLIB Token {
17480 friend class TestToken ;
17581
82+ public:
83+ enum CppcheckAttributesType : std::uint8_t { LOW, HIGH };
84+ enum class Cpp11init : std::uint8_t { UNKNOWN, CPP11INIT, NOINIT };
85+
17686private:
87+ struct Impl {
88+ nonneg int mVarId {};
89+ nonneg int mFileIndex {};
90+ nonneg int mLineNumber {};
91+ nonneg int mColumn {};
92+ nonneg int mExprId {};
93+
94+ // original template argument location
95+ int mTemplateArgFileIndex {-1 };
96+ int mTemplateArgLineNumber {-1 };
97+ int mTemplateArgColumn {-1 };
98+
99+ /* *
100+ * A value from 0-100 that provides a rough idea about where in the token
101+ * list this token is located.
102+ */
103+ nonneg int mProgressValue {};
104+
105+ /* *
106+ * Token index. Position in token list
107+ */
108+ nonneg int mIndex {};
109+
110+ /* * Bitfield bit count. */
111+ short mBits = -1 ;
112+
113+ // AST..
114+ Token* mAstOperand1 {};
115+ Token* mAstOperand2 {};
116+ Token* mAstParent {};
117+
118+ // symbol database information
119+ const Scope* mScope {};
120+ union {
121+ const Function *mFunction ;
122+ const Variable *mVariable ;
123+ const ::Type* mType ;
124+ const Enumerator *mEnumerator ;
125+ };
126+
127+ // original name like size_t
128+ std::string* mOriginalName {};
129+
130+ // If this token came from a macro replacement list, this is the name of that macro
131+ std::string* mMacroName {};
132+
133+ // ValueType
134+ ValueType* mValueType {};
135+
136+ // ValueFlow
137+ std::list<ValueFlow::Value>* mValues {};
138+
139+ // Pointer to a template in the template simplifier
140+ std::set<TemplateSimplifier::TokenAndName*>* mTemplateSimplifierPointers {};
141+
142+ // Pointer to the object representing this token's scope
143+ std::shared_ptr<ScopeInfo2> mScopeInfo ;
144+
145+ // __cppcheck_in_range__
146+ struct CppcheckAttributes {
147+ CppcheckAttributesType type{LOW};
148+ MathLib::bigint value{};
149+ CppcheckAttributes* next{};
150+ };
151+ CppcheckAttributes* mCppcheckAttributes {};
152+
153+ // alignas expressions
154+ std::unique_ptr<std::vector<std::string>> mAttributeAlignas ;
155+ void addAttributeAlignas (const std::string& a) {
156+ if (!mAttributeAlignas )
157+ mAttributeAlignas = std::unique_ptr<std::vector<std::string>>(new std::vector<std::string>());
158+ if (std::find (mAttributeAlignas ->cbegin (), mAttributeAlignas ->cend (), a) == mAttributeAlignas ->cend ())
159+ mAttributeAlignas ->push_back (a);
160+ }
161+
162+ std::string mAttributeCleanup ;
163+
164+ // For memoization, to speed up parsing of huge arrays #8897
165+ Cpp11init mCpp11init {Cpp11init::UNKNOWN};
166+
167+ TokenDebug mDebug {};
168+
169+ void setCppcheckAttribute (CppcheckAttributesType type, MathLib::bigint value);
170+ bool getCppcheckAttribute (CppcheckAttributesType type, MathLib::bigint &value) const ;
171+
172+ Impl () : mFunction (nullptr ) {}
173+
174+ ~Impl ();
175+
176+ Impl (const Impl &) = delete ;
177+ Impl operator =(const Impl &) = delete ;
178+ };
179+
177180 const TokenList& mList ;
178181 std::shared_ptr<TokensFrontBack> mTokensFrontBack ;
179182
@@ -594,10 +597,10 @@ class CPPCHECKLIB Token {
594597 bool hasAttributeCleanup () const {
595598 return !mImpl ->mAttributeCleanup .empty ();
596599 }
597- void setCppcheckAttribute (TokenImpl::CppcheckAttributes::Type type, MathLib::bigint value) {
600+ void setCppcheckAttribute (CppcheckAttributesType type, MathLib::bigint value) {
598601 mImpl ->setCppcheckAttribute (type, value);
599602 }
600- bool getCppcheckAttribute (TokenImpl::CppcheckAttributes::Type type, MathLib::bigint &value) const {
603+ bool getCppcheckAttribute (CppcheckAttributesType type, MathLib::bigint &value) const {
601604 return mImpl ->getCppcheckAttribute (type, value);
602605 }
603606 // cppcheck-suppress unusedFunction
@@ -1346,7 +1349,7 @@ class CPPCHECKLIB Token {
13461349 }
13471350
13481351 const std::list<ValueFlow::Value>& values () const {
1349- return mImpl ->mValues ? *mImpl ->mValues : TokenImpl:: mEmptyValueList ;
1352+ return mImpl ->mValues ? *mImpl ->mValues : mEmptyValueList ;
13501353 }
13511354
13521355 /* *
@@ -1406,6 +1409,7 @@ class CPPCHECKLIB Token {
14061409 void assignIndexes ();
14071410
14081411private:
1412+ static const std::list<ValueFlow::Value> mEmptyValueList ;
14091413
14101414 void next (Token *nextToken) {
14111415 mNext = nextToken;
@@ -1499,7 +1503,7 @@ class CPPCHECKLIB Token {
14991503
15001504 uint64_t mFlags {};
15011505
1502- TokenImpl * mImpl {};
1506+ Impl * mImpl {};
15031507
15041508 /* *
15051509 * Get specified flag state.
@@ -1630,9 +1634,9 @@ class CPPCHECKLIB Token {
16301634 std::shared_ptr<ScopeInfo2> scopeInfo () const ;
16311635
16321636 void setCpp11init (bool cpp11init) const {
1633- mImpl ->mCpp11init =cpp11init ? TokenImpl:: Cpp11init::CPP11INIT : TokenImpl:: Cpp11init::NOINIT;
1637+ mImpl ->mCpp11init =cpp11init ? Cpp11init::CPP11INIT : Cpp11init::NOINIT;
16341638 }
1635- TokenImpl:: Cpp11init isCpp11init () const {
1639+ Cpp11init isCpp11init () const {
16361640 return mImpl ->mCpp11init ;
16371641 }
16381642
0 commit comments