Ticket #7805: Ignore enumerators when simplifying known variables.#846
Ticket #7805: Ignore enumerators when simplifying known variables.#846danmar merged 1 commit intocppcheck-opensource:masterfrom
Conversation
|
hmm.. did you try Token::isEnumerator() ? |
|
I had not, thanks for the hint. I did right now, replacing isEnumerator(tok) by tok->isEnumerator() in my patch, and it does not work: the simplification occurs before the symbol database is built, hence the second XX flagged as enumerator. |
|
ok |
|
this solution can waste cpu. imagine a large array initialization with 1000 symbols: one alternative is that you have a "isEnumScope" flag. Every time a "}" is seen you clear it. When a "{" is seen you set it to true if it's an enum scope. However in the setVarIdPass1 it might be most clean to integrate this into the VarIdScopeInfo. I don't look at this code often so .. do you think that would be more messy or less good for some reason? |
096e1d4 to
be393e5
Compare
|
Updated patch with an alternative solution, as suggested. |
…known variables.
be393e5 to
5119ae8
Compare
Known variable simplification must be aware of enumerators and leave them untouched even if they are called the same as a constant variable.