llvm / llvm/llvm-project

concept constraining auto return type doesn't have a cursor

Open
#166,580 0 comments 0 reactions 0 assignees View on GitHub
clang:as-a-library
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

clang 21.1.4 , using `libclang`'s `clang_visitChlidren` .

Example:
```
template
concept Decrementable = requires (T t){ --t; };

Decrementable auto bar(){return 5;};
```
`clang-21 -cc1 -std=c++20 -ast-dump` output:
```
|-ConceptDecl 0x562aefcdfaf8 col:9 Decrementable
| |-TemplateTypeParmDecl 0x562aefcdfa18 col:19 referenced typename depth 0 index 0 T
| `-RequiresExpr 0x562aefcdfc90 'bool'
| |-ParmVarDecl 0x562aefcdfb58 col:37 referenced t 'T'
| `-SimpleRequirement 0x562aefcdfc60 dependent
| `-UnaryOperator 0x562aefcdfc48 '' lvalue prefix '--' cannot overflow
| `-DeclRefExpr 0x562aefcdfc28 'T' lvalue ParmVar 0x562aefcdfb58 't' 'T' non_odr_use_unevaluated
|-FunctionDecl 0x562aefcdfdd8 col:20 bar 'int ()'
| `-CompoundStmt 0x562aefce0280
| `-ReturnStmt 0x562aefce0270
| `-IntegerLiteral 0x562aefcdfee8 'int' 5
`-EmptyDecl 0x562aefce02a0 col:36
```

I would expect to get a `ConceptSpecializationExpr`, same as for
```
auto bar(Decrementable auto i){}
```
~~Also note that the return type is reported as `int` for some reason.~~

Edit: misread output, return typekind is `Auto` . That sounds correct.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.