parent
82e9c076da
commit
1b98be458d
|
@ -1584,7 +1584,13 @@ void SymbolDatabase::createSymbolDatabaseExprIds()
|
|||
inConstExpr = tok->next()->link();
|
||||
}
|
||||
}
|
||||
for (const Scope * scope : functionScopes) {
|
||||
|
||||
auto exprScopes = functionScopes; // functions + global lambdas
|
||||
std::copy_if(scopeList.front().nestedList.begin(), scopeList.front().nestedList.end(), std::back_inserter(exprScopes), [](const Scope* scope) {
|
||||
return scope && scope->type == Scope::eLambda;
|
||||
});
|
||||
|
||||
for (const Scope * scope : exprScopes) {
|
||||
nonneg int thisId = 0;
|
||||
std::unordered_map<std::string, std::vector<Token*>> exprs;
|
||||
|
||||
|
|
|
@ -232,6 +232,7 @@ private:
|
|||
TEST_CASE(decltype2);
|
||||
|
||||
TEST_CASE(exprid1);
|
||||
TEST_CASE(exprid2);
|
||||
|
||||
TEST_CASE(structuredBindings);
|
||||
}
|
||||
|
@ -3760,6 +3761,25 @@ private:
|
|||
ASSERT_EQUALS(expected, actual);
|
||||
}
|
||||
|
||||
void exprid2() {
|
||||
const std::string actual = tokenizeExpr( // #11739
|
||||
"struct S { std::unique_ptr<int> u; };\n"
|
||||
"auto f = [](const S& s) -> std::unique_ptr<int> {\n"
|
||||
" if (auto p = s.u.get())\n"
|
||||
" return std::make_unique<int>(*p);\n"
|
||||
" return nullptr;\n"
|
||||
"};\n");
|
||||
|
||||
const char expected[] = "1: struct S { std :: unique_ptr < int > u ; } ;\n"
|
||||
"2: auto f ; f = [ ] ( const S & s ) . std :: unique_ptr < int > {\n"
|
||||
"3: if (@5 auto p@4 =@6 s@3 .@7 u@5 .@8 get (@9 ) ) {\n"
|
||||
"4: return std ::@10 make_unique < int > (@11 *@12 p@4 ) ; }\n"
|
||||
"5: return nullptr ;\n"
|
||||
"6: } ;\n";
|
||||
|
||||
ASSERT_EQUALS(expected, actual);
|
||||
}
|
||||
|
||||
void structuredBindings() {
|
||||
const char code[] = "int foo() { auto [x,y] = xy(); return x+y; }";
|
||||
ASSERT_EQUALS("1: int foo ( ) { auto [ x@1 , y@2 ] = xy ( ) ; return x@1 + y@2 ; }\n",
|
||||
|
|
Loading…
Reference in New Issue