[PATCH] D43763: libclang: Visit class template instantiations

Florian Jung via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 26 07:18:04 PST 2018


Windfisch created this revision.
Windfisch added a project: clang-c.
Herald added a subscriber: cfe-commits.

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).


Repository:
  rC Clang

https://reviews.llvm.org/D43763

Files:
  include/clang-c/Index.h
  lib/Sema/SemaCodeComplete.cpp
  tools/libclang/CIndex.cpp
  tools/libclang/CIndexCXX.cpp
  tools/libclang/CursorVisitor.h
  tools/libclang/libclang.exports

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43763.135898.patch
Type: text/x-patch
Size: 7628 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180226/9ef8ae46/attachment.bin>


More information about the cfe-commits mailing list