-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Original Name to types for Typedefs #5968
Conversation
Please add a test for this in |
Okay will try it likely tomorrow. |
I'm not on Linux, but don't you get a |
You can run the tests with make check. |
Hi @chrchr-github It will now test that the original name of the type is set. I wanted to additionally test that the valueType-originalTypeName for the dump file variable was also set. But the access via the token->valueType() wasn't possible, as it does not have a method to get the original Name and i got an access error about "C++ The type of a pointer to an incomplete class () is not allowed." Not exactly sure if the test of original Name in the Value Type is even necessary or if the copying of originalName of the type to the variable is tested also somewhere else. |
Hi @pfultz2 thanks for the note. as mentioned above i tried windows and it worked for me too |
ef3e60a
to
7e9cf79
Compare
Added also Tests that the valueTypeOriginalName is present in the Variable, actually the thing which gets printed into the dump file and in what i am interested. I also tested the main branch and both tests fail on the main branch therefore double-checked that this wasn't tested before in any way. If all Actions pass i would appreciate a merge :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me.
you need to pass "-DBUILD_TESTS=ON" to cmake then you should get the testrunner. Personally I don't usually use cmake nor windows.. and usually build and run the tests like so: |
Found the cmake solution. And added PR to document in the readme as you already saw in #5973. not sure why make caused build problems for me maybe some dependency issue on my side, but cmake worked for me and that’s why I didn’t dig deeper. thanks for approval. Hope the contribution will be helpful for others too after merge and the 2.14 gets released. |
could you test what happens if there is code:
I would assume that the "char" token will not get a originalName? Should insertTokens set the originalName instead? |
By experience from the function pointer where all the information is written to the In the first place I wondered why the typedef resolves into such a strange pattern of tokens. Actually the tokens directly before a functionpointer variable are (*. And the info is written on the * I will test it tomorrow, with your pointer type. |
Hi @danmar for your Pointer Typedef i get this token result in the dump file, as expected the originalName is written to the *
Similar to the function pointer
It handles the token directly before it as the type. |
@wienans I let you decide. You are the one who wants to use this info.. Is it ok that originalName is set on the "*" token only or should we try to set it on all/other tokens? maybe all the name tokens. maybe on all the leading name tokens.. |
For my purpose using it together with the namingng addon it’s the convenient if it is directly in the token before the variable which is what it is doing now. Otherwise I would need to search for the real type and in cases of char const * const* and other crazy combinations it’s best to have it easily accessible within the first token before the variable name. As we talking about namingng addon I will contribute the non specific part which uses this feature in the future. So that the namingng addon works with more complex type structures. conclusion if the PR is fine from your side we can merge it. |
Trying to Fix the issue described here: https://sourceforge.net/p/cppcheck/discussion/general/thread/5775ff1666/
For the small example purpose script it works. Actually it shows the
valueType-originalTypeName
. But i am not 100% sure, what is done. I printed the tok2 and tok3 and in my simple case both where the same. And if i add either of both the originalName it also works. But for now i couldn't deduct what exactly tok2 and tok3 are doing