Serafean wrote:
Sorry, this doesn't seem to work... when the parameters are visited like so:
```
auto kind = clang_getCursorKind(current_cursor);
if (kind == CXCursor_ParmDecl){
auto type = clang_getCursorType(current_cursor);
std::cout << "Param : \n\ttype:" << type << " kind: " << type.kind <<
std::endl;
}
```
the TypeKind in still `unexposed`.
`AutoTypeLoc` isn't called for the auto parameter, that honor goes to
`VisitFunctionTypeLoc` explicitly calling `Visit()` for every param, and then
`VisitTemplateTypeParmTypeLoc` for the `auto` keyword.
for the `CXType_Auto` not being reported, so far I managed to paper over it
this way:
```
--- a/clang/tools/libclang/CXType.cpp
+++ b/clang/tools/libclang/CXType.cpp
@@ -149,6 +149,16 @@ CXType cxtype::MakeCXType(QualType T, CXTranslationUnit
TU) {
if (auto *PTT = T->getAs<ParenType>()) {
return MakeCXType(PTT->getInnerType(), TU);
}
+
+ // auto in function parameters
+ if(auto *TTP = T->getAs<TemplateTypeParmType>()) {
+ auto *D = TTP->getDecl();
+ if (D && D->isImplicit()) {
+ if (auto *TC = D->getTypeConstraint(); !TC) {
+ TK = CXType_Auto;
+ }
+ }
+ }
```
Logic taken from[
`TypePrinter.cpp:1676`](https://github.com/llvm/llvm-project/blob/main/clang/lib/AST/TypePrinter.cpp#L1676).
No idea yet how to stop visiting and exposing the `auto` keyword as a Cursor.
https://github.com/llvm/llvm-project/pull/172092
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits