Additional call to setValueTypeInTokenList() (#5300)

This commit is contained in:
chrchr-github 2023-08-08 22:54:27 +02:00 committed by GitHub
parent 47c9a941a0
commit c3d7c91e88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 5 deletions

View File

@ -3850,12 +3850,9 @@ void SymbolDatabase::printOut(const char *title) const
}
std::cout << " retType: " << func->retType << std::endl;
if (func->tokenDef->next()->valueType()) {
const ValueType * valueType = func->tokenDef->next()->valueType();
if (const ValueType* valueType = func->tokenDef->next()->valueType()) {
std::cout << " valueType: " << valueType << std::endl;
if (valueType) {
std::cout << " " << valueType->str() << std::endl;
}
std::cout << " " << valueType->str() << std::endl;
}
if (func->hasBody()) {

View File

@ -3339,8 +3339,10 @@ bool Tokenizer::simplifyTokens1(const std::string &configuration)
if (mTimerResults) {
Timer t("Tokenizer::simplifyTokens1::setValueType", mSettings->showtime, mTimerResults);
mSymbolDatabase->setValueTypeInTokenList(false);
mSymbolDatabase->setValueTypeInTokenList(true);
} else {
mSymbolDatabase->setValueTypeInTokenList(false);
mSymbolDatabase->setValueTypeInTokenList(true);
}

View File

@ -510,6 +510,7 @@ private:
TEST_CASE(auto17); // #11163
TEST_CASE(auto18);
TEST_CASE(auto19);
TEST_CASE(auto20);
TEST_CASE(unionWithConstructor);
@ -9437,6 +9438,22 @@ private:
}
}
void auto20() {
GET_SYMBOL_DB("enum A { A0 };\n"
"enum B { B0 };\n"
"const int& g(A a);\n"
"const int& g(B b);\n"
"void f() {\n"
" const auto& r = g(B::B0);\n"
"}\n");
const Token* a = Token::findsimplematch(tokenizer.tokens(), "auto");
ASSERT(a && a->valueType());
ASSERT_EQUALS(a->valueType()->type, ValueType::INT);
const Token* g = Token::findsimplematch(a, "g ( B ::");
ASSERT(g && g->function());
ASSERT_EQUALS(g->function()->tokenDef->linenr(), 4);
}
void unionWithConstructor() {
GET_SYMBOL_DB("union Fred {\n"
" Fred(int x) : i(x) { }\n"