Skip to content

Commit e0bb367

Browse files
[clang][libclang] Report auto function parameters as CXType_Auto
1 parent e4b8541 commit e0bb367

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

clang/test/Index/auto-function-param.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,13 @@ int bar(auto p) {
1212

1313
// CHECK: FunctionDecl=bar:{{.*}} CXType_FunctionProto
1414
// CHECK: ParmDecl=p:{{.*}} CXType_Auto
15+
// C++20 constrained auto parameter
16+
template<typename T>
17+
concept Integral = __is_integral(T);
18+
19+
int baz(Integral auto q) {
20+
return q;
21+
}
22+
23+
// CHECK: FunctionDecl=baz:{{.*}} CXType_FunctionProto
24+
// CHECK: ParmDecl=q:{{.*}} CXType_Auto

clang/tools/libclang/CXType.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,11 @@ CXType cxtype::MakeCXType(QualType T, CXTranslationUnit TU) {
150150
return MakeCXType(PTT->getInnerType(), TU);
151151
}
152152

153-
// Handle auto in function parameters
153+
// Handle auto in function parameters (including constrained auto)
154154
if (auto *TTP = T->getAs<TemplateTypeParmType>()) {
155155
auto *D = TTP->getDecl();
156156
if (D && D->isImplicit()) {
157-
if (auto *TC = D->getTypeConstraint(); !TC) {
158-
TK = CXType_Auto;
159-
}
157+
TK = CXType_Auto;
160158
}
161159
}
162160

0 commit comments

Comments
 (0)