Skip to content

Commit 9738cc6

Browse files
committed
ValueType: function return type
1 parent cf179f8 commit 9738cc6

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lib/symboldatabase.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3834,6 +3834,13 @@ void SymbolDatabase::setValueTypeInTokenList(Token *tokens)
38343834
if (Token::simpleMatch(parsedecl(tok->next(), &valuetype), ")"))
38353835
::setValueType(tok, valuetype);
38363836
}
3837+
3838+
// function
3839+
if (tok->previous() && tok->previous()->function() && tok->previous()->function()->retDef) {
3840+
ValueType valuetype;
3841+
if (Token::simpleMatch(parsedecl(tok->previous()->function()->retDef, &valuetype), "("))
3842+
::setValueType(tok, valuetype);
3843+
}
38373844
} else if (tok->variable()) {
38383845
const Variable *var = tok->variable();
38393846
ValueType valuetype;

test/testsymboldatabase.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3009,6 +3009,9 @@ class TestSymbolDatabase: public TestFixture {
30093009
ASSERT_EQUALS("const int *", typeOf("const int *a; x = a + 1;", "a +"));
30103010
ASSERT_EQUALS("int * const", typeOf("int * const a; x = a + 1;", "+"));
30113011
ASSERT_EQUALS("const int *", typeOf("const int a[20]; x = a + 1;", "+"));
3012+
3013+
// function call..
3014+
ASSERT_EQUALS("int", typeOf("int a(int); a(5);", "( 5"));
30123015
}
30133016
};
30143017

0 commit comments

Comments
 (0)