Skip to content

Add support for simple c++ 11 type ailases like: using INT = int;#1024

Merged
danmar merged 2 commits intocppcheck-opensource:masterfrom
IOBYTE:master
Jan 10, 2018
Merged

Add support for simple c++ 11 type ailases like: using INT = int;#1024
danmar merged 2 commits intocppcheck-opensource:masterfrom
IOBYTE:master

Conversation

@IOBYTE
Copy link
Copy Markdown
Contributor

@IOBYTE IOBYTE commented Jan 9, 2018

Only types supported by ValueType are supported. Complex types like
function pointers are not supported. Template type aliases are not
supported.

Only types supported by ValueType are supported. Complex types like
function pointers are not supported. Template type aliases are not
supported.
@IOBYTE
Copy link
Copy Markdown
Contributor Author

IOBYTE commented Jan 9, 2018

I'm able to reproduce the travis crash and am looking into it now.

@IOBYTE
Copy link
Copy Markdown
Contributor Author

IOBYTE commented Jan 9, 2018

This is the code that is causing the crash:

using size_t = unsigned long;
void foo(size_t N);

Please don't apply this pull request until I figure out how to fix this case.

@danmar
Copy link
Copy Markdown
Collaborator

danmar commented Jan 9, 2018

thanks for looking at this. My plan is to release cppcheck in the weekend so if you fix the problem please let me know if you think it can be committed now or if we should wait a few days.

@IOBYTE
Copy link
Copy Markdown
Contributor Author

IOBYTE commented Jan 9, 2018

I know what the problem is but I don't have a fix. I would wait till after the release and after I come up with a fix to apply this.

Since size_t and other related common typedefs are built into cppcheck, overriding them is proving to be tricky and I want to get it right.

This fixes a crash when size_t is replaced with unsigned long in: using
size_t = unsigned long; by the tokenizer.

This does not fix the problem where Tokenizer::simplifyPlatformTypes()
simplifies away size_t in other cases.  This is only a problem when the
new type is different from the platform type.
@IOBYTE
Copy link
Copy Markdown
Contributor Author

IOBYTE commented Jan 10, 2018

I fixed the crash. The case where size_t is redefined doesn't work.

using size_t = unsigned short;
size_t i;

get tokenized to:

using size_t = unsigned short ;
unsigned long i ;

because all uses of size_t get simplified to the platform type. I could add a symbol database pass to correct this back to:

using size_t = unsigned short ;
size_t i ;

where size_t will have a ValueType of unsigned short.

Does DACA-2 automatically get run or is it possible to run it with this change to see if any other unforeseen problems show up? I'm OK with applying this before the next release if no other problems show up.

@danmar
Copy link
Copy Markdown
Collaborator

danmar commented Jan 10, 2018

Does DACA-2 automatically get run or is it possible to run it with this change to see if any other unforeseen problems show up?

It is possible. But I will merge this now and if we see some problem we can revert this change.

@danmar danmar merged commit cefb213 into cppcheck-opensource:master Jan 10, 2018
@danmar
Copy link
Copy Markdown
Collaborator

danmar commented Jan 10, 2018

Stupid question.. is it necessary to simplify size_t in Tokenizer? Or could we just make sure that a proper valueType() is set?

@IOBYTE
Copy link
Copy Markdown
Contributor Author

IOBYTE commented Jan 10, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants