@@ -8278,6 +8278,18 @@ class TestSymbolDatabase : public TestFixture {
82788278 ASSERT (tok && tok->valueType ());
82798279 ASSERT_EQUALS (" iterator(std :: vector <)" , tok->valueType ()->str ());
82808280 }
8281+ {
8282+ GET_SYMBOL_DB (" std::vector<int>& g();\n "
8283+ " void f() {\n "
8284+ " auto it = std::find(g().begin(), g().end(), 0);\n "
8285+ " }\n " );
8286+ ASSERT_EQUALS (" " , errout.str ());
8287+
8288+ const Token* tok = tokenizer.tokens ();
8289+ tok = Token::findsimplematch (tok, " auto" );
8290+ ASSERT (tok && tok->valueType ());
8291+ ASSERT_EQUALS (" iterator(std :: vector <)" , tok->valueType ()->str ());
8292+ }
82818293 {
82828294 GET_SYMBOL_DB (" struct T { std::set<std::string> s; };\n "
82838295 " struct U { std::shared_ptr<T> get(); };\n "
@@ -8289,7 +8301,55 @@ class TestSymbolDatabase : public TestFixture {
82898301 const Token* tok = tokenizer.tokens ();
82908302 tok = Token::findsimplematch (tok, " auto" );
82918303 ASSERT (tok && tok->valueType ());
8292- ASSERT_EQUALS (" container(std :: string|wstring|u16string|u32string)" , tok->valueType ()->str ());
8304+ ASSERT_EQUALS (" const container(std :: string|wstring|u16string|u32string) &" , tok->valueType ()->str ());
8305+ }
8306+ {
8307+ GET_SYMBOL_DB (" void f(std::vector<int>& v) {\n "
8308+ " for (auto& i : v)\n "
8309+ " i = 0;\n "
8310+ " for (auto&& j : v)\n "
8311+ " j = 1;\n "
8312+ " }\n " );
8313+ ASSERT_EQUALS (" " , errout.str ());
8314+
8315+ const Token* tok = tokenizer.tokens ();
8316+ tok = Token::findsimplematch (tok, " auto &" );
8317+ ASSERT (tok && tok->valueType ());
8318+ ASSERT_EQUALS (" signed int &" , tok->valueType ()->str ());
8319+ tok = Token::findsimplematch (tok, " i :" );
8320+ ASSERT (tok && tok->valueType ());
8321+ ASSERT (tok->valueType ()->reference == Reference::LValue);
8322+ tok = Token::findsimplematch (tok, " i =" );
8323+ ASSERT (tok && tok->valueType ());
8324+ ASSERT (tok->valueType ()->reference == Reference::LValue);
8325+ tok = Token::findsimplematch (tok, " auto &&" );
8326+ ASSERT (tok && tok->valueType ());
8327+ ASSERT_EQUALS (" signed int &&" , tok->valueType ()->str ());
8328+ tok = Token::findsimplematch (tok, " j =" );
8329+ ASSERT (tok && tok->valueType ());
8330+ ASSERT (tok->valueType ()->reference == Reference::RValue);
8331+ }
8332+ {
8333+ GET_SYMBOL_DB (" void f(std::vector<int*>& v) {\n "
8334+ " for (const auto& p : v)\n "
8335+ " if (p == nullptr) {}\n "
8336+ " }\n " );
8337+ ASSERT_EQUALS (" " , errout.str ());
8338+
8339+ const Token* tok = tokenizer.tokens ();
8340+ tok = Token::findsimplematch (tok, " auto" );
8341+ ASSERT (tok && tok->valueType ());
8342+ ASSERT_EQUALS (" signed int * const &" , tok->valueType ()->str ());
8343+ tok = Token::findsimplematch (tok, " p :" );
8344+ ASSERT (tok && tok->valueType ());
8345+ ASSERT_EQUALS (" signed int * const &" , tok->valueType ()->str ());
8346+ ASSERT (tok->variable () && tok->variable ()->valueType ());
8347+ ASSERT_EQUALS (" signed int * const &" , tok->variable ()->valueType ()->str ());
8348+ tok = Token::findsimplematch (tok, " p ==" );
8349+ ASSERT (tok && tok->valueType ());
8350+ ASSERT_EQUALS (" signed int * const &" , tok->valueType ()->str ());
8351+ ASSERT (tok->variable () && tok->variable ()->valueType ());
8352+ ASSERT_EQUALS (" signed int * const &" , tok->variable ()->valueType ()->str ());
82938353 }
82948354 }
82958355
@@ -8630,15 +8690,15 @@ class TestSymbolDatabase : public TestFixture {
86308690 ASSERT (autotok && autotok->type () && autotok->type ()->name () == " S" );
86318691
86328692 autotok = Token::findsimplematch (autotok->next (), " auto & c" );
8633- ASSERT (autotok && autotok->valueType () && autotok->valueType ()->pointer == 0 && autotok->valueType ()->constness == 0 && autotok->valueType ()->typeScope && autotok->valueType ()->typeScope ->definedType && autotok->valueType ()->typeScope ->definedType ->name () == " S" );
8693+ ASSERT (autotok && autotok->valueType () && autotok->valueType ()->pointer == 0 && autotok->valueType ()->constness == 1 && autotok->valueType ()->typeScope && autotok->valueType ()->typeScope ->definedType && autotok->valueType ()->typeScope ->definedType ->name () == " S" );
86348694 ASSERT (autotok && autotok->type () && autotok->type ()->name () == " S" );
86358695
86368696 autotok = Token::findsimplematch (autotok->next (), " auto * d" );
86378697 ASSERT (autotok && autotok->valueType () && autotok->valueType ()->pointer == 0 && autotok->valueType ()->constness == 0 && autotok->valueType ()->typeScope && autotok->valueType ()->typeScope ->definedType && autotok->valueType ()->typeScope ->definedType ->name () == " S" );
86388698 ASSERT (autotok && autotok->type () && autotok->type ()->name () == " S" );
86398699
86408700 autotok = Token::findsimplematch (autotok->next (), " auto * e" );
8641- ASSERT (autotok && autotok->valueType () && autotok->valueType ()->pointer == 0 && autotok->valueType ()->constness == 0 && autotok->valueType ()->typeScope && autotok->valueType ()->typeScope ->definedType && autotok->valueType ()->typeScope ->definedType ->name () == " S" );
8701+ ASSERT (autotok && autotok->valueType () && autotok->valueType ()->pointer == 0 && autotok->valueType ()->constness == 1 && autotok->valueType ()->typeScope && autotok->valueType ()->typeScope ->definedType && autotok->valueType ()->typeScope ->definedType ->name () == " S" );
86428702 ASSERT (autotok && autotok->type () && autotok->type ()->name () == " S" );
86438703
86448704 vartok = Token::findsimplematch (tokenizer.tokens (), " a :" );
0 commit comments