[clang] [AST] Add dump() method to TypeLoc (PR #65484)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 13 11:32:43 PDT 2023


================
@@ -415,9 +443,55 @@ class ASTNodeTraverser
     if (!T->isSugared())
       Visit(T->getPattern());
   }
+  void VisitAutoType(const AutoType *T) {
+    for (const auto &Arg : T->getTypeConstraintArguments())
+      Visit(Arg);
+  }
   // FIXME: ElaboratedType, DependentNameType,
   // DependentTemplateSpecializationType, ObjCObjectType
 
+  // For TypeLocs, we automatically visit the inner type loc (pointee type etc).
+  // We must explicitly visit other lexically-nested nodes.
+  void VisitFunctionProtoTypeLoc(FunctionProtoTypeLoc TL) {
----------------
AaronBallman wrote:

>>another test with a lambda expression
> I'm not sure what such a test should do.
> `[](){}` doesn't really have meaningful TypeLocs, and `[]()->int{}` just has the BuiltinTypeLoc for int.
> Do you want a dump of the (implicit) call operator's typeloc?

Ah, I was thinking of the trailing return type and the types in the parameter list, but I think I confused myself there (the `FunctionProtoTypeLoc` wouldn't be for the lambda but for its call operator, which we already have coverage for).

Thank you for the additional test coverage!

https://github.com/llvm/llvm-project/pull/65484


More information about the cfe-commits mailing list