From 9738cc66ebd30ada5fa6fa04af8416286eebd2f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 11 Oct 2015 08:42:31 +0200 Subject: [PATCH] ValueType: function return type --- lib/symboldatabase.cpp | 7 +++++++ test/testsymboldatabase.cpp | 3 +++ 2 files changed, 10 insertions(+) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 46481805b..d58d4ca50 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -3834,6 +3834,13 @@ void SymbolDatabase::setValueTypeInTokenList(Token *tokens) if (Token::simpleMatch(parsedecl(tok->next(), &valuetype), ")")) ::setValueType(tok, valuetype); } + + // function + if (tok->previous() && tok->previous()->function() && tok->previous()->function()->retDef) { + ValueType valuetype; + if (Token::simpleMatch(parsedecl(tok->previous()->function()->retDef, &valuetype), "(")) + ::setValueType(tok, valuetype); + } } else if (tok->variable()) { const Variable *var = tok->variable(); ValueType valuetype; diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 9cdf6fcb4..3c5ab5817 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -3009,6 +3009,9 @@ private: ASSERT_EQUALS("const int *", typeOf("const int *a; x = a + 1;", "a +")); ASSERT_EQUALS("int * const", typeOf("int * const a; x = a + 1;", "+")); ASSERT_EQUALS("const int *", typeOf("const int a[20]; x = a + 1;", "+")); + + // function call.. + ASSERT_EQUALS("int", typeOf("int a(int); a(5);", "( 5")); } };