From bf61bcf40276684c0a98981c0dc8842443fa6fce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 14 Oct 2019 09:19:16 +0200 Subject: [PATCH] ValueType: Set ValueType for constructor calls --- lib/symboldatabase.cpp | 6 +++--- test/testsymboldatabase.cpp | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 808624057..c2fafce20 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -5640,11 +5640,11 @@ void SymbolDatabase::setValueTypeInTokenList(bool reportDebugWarnings) setValueType(tok, valuetype); } - // constructor - else if (tok->previous() && tok->previous()->type() && tok->previous()->type()->classScope) { + // constructor call + else if (tok->previous() && tok->previous()->function() && tok->previous()->function()->isConstructor()) { ValueType valuetype; valuetype.type = ValueType::RECORD; - valuetype.typeScope = tok->previous()->type()->classScope; + valuetype.typeScope = tok->previous()->function()->token->scope(); setValueType(tok, valuetype); } diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 514923c57..33af16246 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -6416,6 +6416,7 @@ private: ASSERT_EQUALS("signed int", typeOf("auto a(int) -> int; a(5);", "( 5")); ASSERT_EQUALS("unsigned long", typeOf("sizeof(x);", "(")); ASSERT_EQUALS("signed int", typeOf("int (*a)(int); a(5);", "( 5")); + ASSERT_EQUALS("s", typeOf("struct s { s foo(); s(int, int); }; s s::foo() { return s(1, 2); } ", "( 1 , 2 )")); // Some standard template functions.. TODO library configuration ASSERT_EQUALS("signed int", typeOf("std::move(5);", "( 5 )"));