Skip to content

[clang] LambdaExpr::hasExplicitParameters() returns true for lambdas with a trailing return type #168452

@WillemKauf

Description

@WillemKauf

(LLVM version 20.1.8)

For context, I am writing a clang-tidy pass for a codebase which deals with lambda coroutines, and need to disambiguate between a lambda with an empty parameter list like:

auto l = [](){};

and an implicit parameter list like:

auto l = []{};

hasExplicitParameters() correctly returns false, true in the above cases, but when adding a trailing return type (which is needed to properly define a lambda coroutine), hasExplicitParameters() no longer returns what you would expect, e.g.

auto l = []() -> int { return 0; };
auto l = [] -> int { return 0; };

Here, hasExplicitParameters() returns true, true.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:as-a-librarylibclang and C++ APIclang:frontendLanguage frontend issues, e.g. anything involving "Sema"confirmedVerified by a second partygood first issuehttps://github.com/llvm/llvm-project/contributelambdaC++11 lambda expressions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions