Skip to content

fix #10068 (typedef not replaced when namespace is involved)#3009

Merged
danmar merged 5 commits intocppcheck-opensource:mainfrom
IOBYTE:main
Jan 5, 2021
Merged

fix #10068 (typedef not replaced when namespace is involved)#3009
danmar merged 5 commits intocppcheck-opensource:mainfrom
IOBYTE:main

Conversation

@IOBYTE
Copy link
Copy Markdown
Contributor

@IOBYTE IOBYTE commented Jan 3, 2021

No description provided.

@firewave
Copy link
Copy Markdown
Collaborator

firewave commented Jan 4, 2021

Thanks a lot. The additional findings are expected - there is one missing though which appears with the conversion to using in #3007.

#include <memory>
#include <vector>

namespace clangimport {
	class AstNode;
	typedef std::shared_ptr<AstNode> AstNodePtr;
	//using AstNodePtr = std::shared_ptr<AstNode>;

	class AstNode {
	public:
		AstNode()
		{}
	private:
		void createScope(const std::vector<AstNodePtr> &children);
	};
}

void clangimport::AstNode::createScope(const std::vector<AstNodePtr> & children2)
{
}

typedef

##file /mnt/s/clion/example_lite_2/test.cpp
4: namespace clangimport {
5: class AstNode ;
6:
7:
8:
9: class AstNode {
10: public:
11: AstNode ( )
12: { }
13: private:
14: void createScope ( const std :: vector < std :: shared_ptr < AstNode > > & children@var1 ) ;
15: } ;
16: }
17:
18: void clangimport :: AstNode :: createScope ( const std :: vector < AstNodePtr > & children2@var2 )
19: {
20: }



##Value flow
/mnt/s/clion/example_lite_2/test.cpp:18:28: debug: Executable scope 'createScope' with unknown function. [symbolDatabaseWarning]
void clangimport::AstNode::createScope(const std::vector<AstNodePtr> & children2)
                           ^

using

4: namespace clangimport {
5: class AstNode ;
6:
7:
8:
9: class AstNode {
10: public:
11: AstNode ( )
12: { }
13: private:
14: void createScope ( const std :: vector < std :: shared_ptr < AstNode > > & children@var1 ) ;
15: } ;
16: }
17:
18: void clangimport :: AstNode :: createScope ( const std :: vector < std :: shared_ptr < AstNode > > & children2@var2 )
19: {
20: }



##Value flow
/mnt/s/clion/example_lite_2/test.cpp:18:72: style:inconclusive: Function 'createScope' argument 1 names different: declaration 'children' definition 'children2'. [funcArgNamesDifferent]
void clangimport::AstNode::createScope(const std::vector<AstNodePtr> & children2)
                                                                       ^
/mnt/s/clion/example_lite_2/test.cpp:14:51: note: Function 'createScope' argument 1 names different: declaration 'children' definition 'children2'.
  void createScope(const std::vector<AstNodePtr> &children);
                                                  ^
/mnt/s/clion/example_lite_2/test.cpp:18:72: note: Function 'createScope' argument 1 names different: declaration 'children' definition 'children2'.
void clangimport::AstNode::createScope(const std::vector<AstNodePtr> & children2)
                                                                       ^

Fixing that will probably help with https://trac.cppcheck.net/ticket/10061 and #2973.

@danmar
Copy link
Copy Markdown
Collaborator

danmar commented Jan 4, 2021

I think that the self check warnings are fixed upstream.. can you try rebasing?

@danmar
Copy link
Copy Markdown
Collaborator

danmar commented Jan 4, 2021

I recommend git rebase instead of git merge. Your changes should be applied on top of latest upstream main.

git reset --hard e5cbbb1
git rebase main
git push -f

@danmar
Copy link
Copy Markdown
Collaborator

danmar commented Jan 4, 2021

I recommend git rebase instead of git merge. Your changes should be applied on top of latest upstream main.

ah sorry.. you work on your "main" branch. No harm done..

I suggest (https://medium.com/@topspinj/how-to-git-rebase-into-a-forked-repo-c9f05e821c8a):

git fetch upstream
git rebase upstream/main

Comment thread lib/tokenize.cpp
continue;
if (!func->previous()) // Ticket #4239
continue;
else if (isCPP() && tok2->str() == "(" && isFunctionHead(tok2, "{")) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for using isFunctionHead

@danmar danmar merged commit 8897ad3 into cppcheck-opensource:main Jan 5, 2021
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.

3 participants