From 5cd92a0eb12a0c8e2d69d16464d14446576f1861 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 3 Sep 2020 19:49:02 +0200 Subject: [PATCH] test/cli/test-clang-import: Improved testing --- lib/clangimport.cpp | 5 +++++ test/cli/test-clang-import.py | 14 ++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/clangimport.cpp b/lib/clangimport.cpp index 7813c167f..08dc2779a 100644 --- a/lib/clangimport.cpp +++ b/lib/clangimport.cpp @@ -1095,16 +1095,21 @@ void clangimport::AstNode::createTokensFunctionDecl(TokenList *tokenList) symbolDatabase->scopeList.push_back(Scope(nullptr, nullptr, nestedIn)); scope = &symbolDatabase->scopeList.back(); scope->function = function; + scope->classDef = nameToken; scope->type = Scope::ScopeType::eFunction; scope->className = nameToken->str(); nestedIn->nestedList.push_back(scope); function->hasBody(true); + function->functionScope = scope; } Token *par1 = addtoken(tokenList, "("); if (!function->arg) function->arg = par1; function->token = nameToken; + if (!function->nestedIn) + function->nestedIn = nestedIn; + function->argDef = par1; // Function arguments for (int i = 0; i < children.size(); ++i) { AstNodePtr child = children[i]; diff --git a/test/cli/test-clang-import.py b/test/cli/test-clang-import.py index 13c93a8f6..9c34b1bc4 100644 --- a/test/cli/test-clang-import.py +++ b/test/cli/test-clang-import.py @@ -8,12 +8,13 @@ from testutils import create_gui_project_file, cppcheck def get_debug_section(title, stdout): s = re.sub(r'0x[0-9a-fA-F]+', '0x12345678', stdout) + s = re.sub(r'nestedIn: Struct', 'nestedIn: Class', s) + s = re.sub(r'classDef: struct', 'classDef: class', s) s = re.sub(r'isInline: [a-z]+', 'isInline: ---', s) - s = re.sub(r'argDef: .*', 'argDef: ---', s) - s = re.sub(r'nestedIn: .*', 'nestedIn: ---', s) - s = re.sub(r'functionScope: .*', 'functionScope: ---', s) s = re.sub(r'definedType: .*', 'definedType: ---', s) - s = re.sub(r'classDef: .*', 'classDef: ---', s) + s = re.sub(r'needInitialization: .*', 'needInitialization: ---', s) + s = re.sub(r'functionOf: .*', 'functionOf: ---', s) + s = re.sub(r'0x12345678 Struct', '0x12345678 Class', s) pos1 = s.find(title) assert pos1 > 0 pos1 = s.find('\n', pos1) + 1 @@ -37,4 +38,9 @@ def check_symbol_database(code): def test1(): check_symbol_database('int main(){return 0;}') +def test2(): + code = 'struct Foo { void f(); }; void Foo::f() {}' + check_symbol_database(code) + +