parent
617cd29a41
commit
76c28073aa
|
@ -4062,6 +4062,17 @@ static const Type* findVariableTypeIncludingUsedNamespaces(const SymbolDatabase*
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static const Token* findLambdaEndTokenWithoutAST(const Token* tok) {
|
||||||
|
if (!(Token::simpleMatch(tok, "[") && tok->link()))
|
||||||
|
return nullptr;
|
||||||
|
tok = tok->link()->next();
|
||||||
|
if (Token::simpleMatch(tok, "(") && tok->link())
|
||||||
|
tok = tok->link()->next();
|
||||||
|
if (!(Token::simpleMatch(tok, "{") && tok->link()))
|
||||||
|
return nullptr;
|
||||||
|
return tok->link()->next();
|
||||||
|
};
|
||||||
|
|
||||||
void Function::addArguments(const SymbolDatabase *symbolDatabase, const Scope *scope)
|
void Function::addArguments(const SymbolDatabase *symbolDatabase, const Scope *scope)
|
||||||
{
|
{
|
||||||
// check for non-empty argument list "( ... )"
|
// check for non-empty argument list "( ... )"
|
||||||
|
@ -4185,7 +4196,7 @@ void Function::addArguments(const SymbolDatabase *symbolDatabase, const Scope *s
|
||||||
initArgCount++;
|
initArgCount++;
|
||||||
if (tok->strAt(1) == "[") {
|
if (tok->strAt(1) == "[") {
|
||||||
const Token* lambdaStart = tok->next();
|
const Token* lambdaStart = tok->next();
|
||||||
tok = findLambdaEndToken(lambdaStart);
|
tok = type == eLambda ? findLambdaEndTokenWithoutAST(lambdaStart) : findLambdaEndToken(lambdaStart);
|
||||||
if (!tok)
|
if (!tok)
|
||||||
throw InternalError(lambdaStart, "Analysis failed (lambda not recognized). If the code is valid then please report this failure.", InternalError::INTERNAL);
|
throw InternalError(lambdaStart, "Analysis failed (lambda not recognized). If the code is valid then please report this failure.", InternalError::INTERNAL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -489,8 +489,6 @@ struct AST_state {
|
||||||
explicit AST_state(bool cpp) : depth(0), inArrayAssignment(0), cpp(cpp), assign(0), inCase(false),stopAtColon(false), functionCallEndPar(nullptr) {}
|
explicit AST_state(bool cpp) : depth(0), inArrayAssignment(0), cpp(cpp), assign(0), inCase(false),stopAtColon(false), functionCallEndPar(nullptr) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
static Token * createAstAtToken(Token *tok, bool cpp);
|
|
||||||
|
|
||||||
static Token* skipDecl(Token* tok, std::vector<Token*>* inner = nullptr)
|
static Token* skipDecl(Token* tok, std::vector<Token*>* inner = nullptr)
|
||||||
{
|
{
|
||||||
auto isDecltypeFuncParam = [](const Token* tok) -> bool {
|
auto isDecltypeFuncParam = [](const Token* tok) -> bool {
|
||||||
|
@ -1008,9 +1006,6 @@ static void compilePrecedence2(Token *&tok, AST_state& state)
|
||||||
squareBracket->astOperand1(roundBracket);
|
squareBracket->astOperand1(roundBracket);
|
||||||
roundBracket->astOperand1(curlyBracket);
|
roundBracket->astOperand1(curlyBracket);
|
||||||
state.op.push(squareBracket);
|
state.op.push(squareBracket);
|
||||||
for (tok = roundBracket->next(); precedes(tok, roundBracket->link()); tok = tok->next()) {
|
|
||||||
tok = createAstAtToken(tok, state.cpp);
|
|
||||||
}
|
|
||||||
tok = curlyBracket->link()->next();
|
tok = curlyBracket->link()->next();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1406,6 +1401,8 @@ const Token* isLambdaCaptureList(const Token * tok)
|
||||||
return params->astOperand1();
|
return params->astOperand1();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Token * createAstAtToken(Token *tok, bool cpp);
|
||||||
|
|
||||||
// Compile inner expressions inside inner ({..}) and lambda bodies
|
// Compile inner expressions inside inner ({..}) and lambda bodies
|
||||||
static void createAstAtTokenInner(Token * const tok1, const Token *endToken, bool cpp)
|
static void createAstAtTokenInner(Token * const tok1, const Token *endToken, bool cpp)
|
||||||
{
|
{
|
||||||
|
|
|
@ -6243,10 +6243,6 @@ private:
|
||||||
ASSERT_EQUALS("decltypexy+(yx+{", testAst("decltype(x+y){y+x};"));
|
ASSERT_EQUALS("decltypexy+(yx+{", testAst("decltype(x+y){y+x};"));
|
||||||
ASSERT_EQUALS("adecltypeac::(,decltypead::(,",
|
ASSERT_EQUALS("adecltypeac::(,decltypead::(,",
|
||||||
testAst("template <typename a> void b(a &, decltype(a::c), decltype(a::d));"));
|
testAst("template <typename a> void b(a &, decltype(a::c), decltype(a::d));"));
|
||||||
ASSERT_EQUALS("g{([= decltypea0[(",
|
|
||||||
testAst("auto g = [](decltype(a[0]) i) {};"));
|
|
||||||
ASSERT_EQUALS("g{([= decltypea0[(i&",
|
|
||||||
testAst("auto g = [](decltype(a[0])& i) {};"));
|
|
||||||
|
|
||||||
ASSERT_NO_THROW(tokenizeAndStringify("struct A;\n" // #10839
|
ASSERT_NO_THROW(tokenizeAndStringify("struct A;\n" // #10839
|
||||||
"struct B { A* hash; };\n"
|
"struct B { A* hash; };\n"
|
||||||
|
@ -6281,6 +6277,14 @@ private:
|
||||||
" for (int i = 0; i <= 123; ++i)\n"
|
" for (int i = 0; i <= 123; ++i)\n"
|
||||||
" x->emplace_back(y);\n"
|
" x->emplace_back(y);\n"
|
||||||
"}");
|
"}");
|
||||||
|
|
||||||
|
ASSERT_NO_THROW(tokenizeAndStringify("void f() {\n" // #10831
|
||||||
|
" auto g = [](std::function<void()> h = []() {}) { };\n"
|
||||||
|
"}"));
|
||||||
|
|
||||||
|
ASSERT_NO_THROW(tokenizeAndStringify("void f() {\n" // #11379
|
||||||
|
" auto l = [x = 3](std::string&& v) { };\n"
|
||||||
|
"}\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void astbrackets() { // []
|
void astbrackets() { // []
|
||||||
|
@ -6505,9 +6509,6 @@ private:
|
||||||
" switch (y) {}\n"
|
" switch (y) {}\n"
|
||||||
"};"));
|
"};"));
|
||||||
|
|
||||||
// #10831
|
|
||||||
ASSERT_EQUALS("f{([= x{([=", testAst("void foo() { F f = [](t x = []() {}) {}; }"));
|
|
||||||
|
|
||||||
// #11357
|
// #11357
|
||||||
ASSERT_NO_THROW(tokenizeAndStringify("void f(std::vector<int>& v, bool c) {\n"
|
ASSERT_NO_THROW(tokenizeAndStringify("void f(std::vector<int>& v, bool c) {\n"
|
||||||
" std::sort(v.begin(), v.end(), [&c](const auto a, const auto b) {\n"
|
" std::sort(v.begin(), v.end(), [&c](const auto a, const auto b) {\n"
|
||||||
|
|
Loading…
Reference in New Issue