This is an archive of the discontinued LLVM Phabricator instance.

libclang: Visit class template instantiations
Needs ReviewPublic

Authored by Windfisch on Feb 26 2018, 7:17 AM.

Details

Reviewers
None
Group Reviewers
Restricted Project
Summary

Changes clang_visitChildren()'s behaviour to also visit all explicit and implicit class template instantiations upon visiting a ClassTemplateDecl. In analogy to clang++'s -dump-ast option, they are treated as children of the ClassTemplateDecl node.

This is done by

  • adding the CXCursor_ClassTemplateSpecialization cursor kind,
  • adding a EnforceVisitBody flag to CursorVisitor::VisitClassTemplateSpecializationDecl, which overrides the existing early exits in that method,
  • and recursively descending into theTemplateDecl->specializations().

This patch also adds a query function clang_getTemplateSpecializationKind and the associated enum type CXTemplateSpecializationKind to retrieve the specialisation kind. That way, users can distinguish between implicit instantiations (which they probably want to visit as child of the ClassTemplateDecl) and explicit instantiation (which they may want choose to ignore, because their node will reappear at the very location where the explicit instantiation takes place).

Diff Detail

Repository
rC Clang

Event Timeline

Windfisch created this revision.Feb 26 2018, 7:17 AM
Windfisch added a reviewer: Restricted Project.Feb 26 2018, 7:18 AM

looks good, but this needs a test, could you add one please?

Herald added a project: Restricted Project. · View Herald TranscriptApr 14 2019, 2:33 AM
Herald added a subscriber: arphaman. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald TranscriptAug 3 2023, 1:21 PM