Skip to content

Commit 8b58650

Browse files
committed
SymbolDatabase: Fix Variable pointer property for 'std::string x(*p)'
1 parent 2998382 commit 8b58650

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

lib/symboldatabase.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6242,7 +6242,7 @@ static const Token * parsedecl(const Token *type, ValueType * const valuetype, V
62426242
} else if (const Library::Container *container = settings->library.detectContainer(type)) {
62436243
valuetype->type = ValueType::Type::CONTAINER;
62446244
valuetype->container = container;
6245-
while (Token::Match(type, "%name%|::|<")) {
6245+
while (Token::Match(type, "%type%|::|<")) {
62466246
if (type->str() == "<" && type->link()) {
62476247
if (container->type_templateArgNo >= 0) {
62486248
const Token *templateType = type->next();

test/testsymboldatabase.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ class TestSymbolDatabase : public TestFixture {
137137
TEST_CASE(test_isVariableDeclarationIdentifiesScopedStdDeclaration);
138138
TEST_CASE(test_isVariableDeclarationIdentifiesManyScopes);
139139
TEST_CASE(test_isVariableDeclarationIdentifiesPointers);
140+
TEST_CASE(test_isVariableDeclarationIdentifiesPointers2);
140141
TEST_CASE(test_isVariableDeclarationDoesNotIdentifyConstness);
141142
TEST_CASE(test_isVariableDeclarationIdentifiesFirstOfManyVariables);
142143
TEST_CASE(test_isVariableDeclarationIdentifiesScopedPointerDeclaration);
@@ -655,6 +656,18 @@ class TestSymbolDatabase : public TestFixture {
655656
ASSERT(false == v3.isReference());
656657
}
657658

659+
void test_isVariableDeclarationIdentifiesPointers2() {
660+
661+
GET_SYMBOL_DB("void slurpInManifest() {\n"
662+
" std::string tmpiostring(*tI);\n"
663+
" if(tmpiostring==\"infoonly\"){}\n"
664+
"}");
665+
666+
const Token *tok = Token::findsimplematch(tokenizer.tokens(), "tmpiostring ==");
667+
ASSERT(tok->variable());
668+
ASSERT(!tok->variable()->isPointer());
669+
}
670+
658671
void test_isVariableDeclarationDoesNotIdentifyConstness() {
659672
reset();
660673
givenACodeSampleToTokenize constness("const int* cp;");

0 commit comments

Comments
 (0)