1f4a2713aSLionel Sambuc //===--- Comment.cpp - Comment AST node implementation --------------------===//
2f4a2713aSLionel Sambuc //
3f4a2713aSLionel Sambuc // The LLVM Compiler Infrastructure
4f4a2713aSLionel Sambuc //
5f4a2713aSLionel Sambuc // This file is distributed under the University of Illinois Open Source
6f4a2713aSLionel Sambuc // License. See LICENSE.TXT for details.
7f4a2713aSLionel Sambuc //
8f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
9f4a2713aSLionel Sambuc
10f4a2713aSLionel Sambuc #include "clang/AST/ASTContext.h"
11f4a2713aSLionel Sambuc #include "clang/AST/Comment.h"
12f4a2713aSLionel Sambuc #include "clang/AST/Decl.h"
13f4a2713aSLionel Sambuc #include "clang/AST/DeclObjC.h"
14f4a2713aSLionel Sambuc #include "clang/AST/DeclTemplate.h"
15f4a2713aSLionel Sambuc #include "clang/Basic/CharInfo.h"
16f4a2713aSLionel Sambuc #include "llvm/Support/ErrorHandling.h"
17f4a2713aSLionel Sambuc #include "llvm/Support/raw_ostream.h"
18f4a2713aSLionel Sambuc
19f4a2713aSLionel Sambuc namespace clang {
20f4a2713aSLionel Sambuc namespace comments {
21f4a2713aSLionel Sambuc
getCommentKindName() const22f4a2713aSLionel Sambuc const char *Comment::getCommentKindName() const {
23f4a2713aSLionel Sambuc switch (getCommentKind()) {
24f4a2713aSLionel Sambuc case NoCommentKind: return "NoCommentKind";
25f4a2713aSLionel Sambuc #define ABSTRACT_COMMENT(COMMENT)
26f4a2713aSLionel Sambuc #define COMMENT(CLASS, PARENT) \
27f4a2713aSLionel Sambuc case CLASS##Kind: \
28f4a2713aSLionel Sambuc return #CLASS;
29f4a2713aSLionel Sambuc #include "clang/AST/CommentNodes.inc"
30f4a2713aSLionel Sambuc #undef COMMENT
31f4a2713aSLionel Sambuc #undef ABSTRACT_COMMENT
32f4a2713aSLionel Sambuc }
33f4a2713aSLionel Sambuc llvm_unreachable("Unknown comment kind!");
34f4a2713aSLionel Sambuc }
35f4a2713aSLionel Sambuc
36f4a2713aSLionel Sambuc namespace {
37f4a2713aSLionel Sambuc struct good {};
38f4a2713aSLionel Sambuc struct bad {};
39f4a2713aSLionel Sambuc
40f4a2713aSLionel Sambuc template <typename T>
implements_child_begin_end(Comment::child_iterator (T::*)()const)41f4a2713aSLionel Sambuc good implements_child_begin_end(Comment::child_iterator (T::*)() const) {
42f4a2713aSLionel Sambuc return good();
43f4a2713aSLionel Sambuc }
44f4a2713aSLionel Sambuc
45f4a2713aSLionel Sambuc LLVM_ATTRIBUTE_UNUSED
implements_child_begin_end(Comment::child_iterator (Comment::*)()const)46f4a2713aSLionel Sambuc static inline bad implements_child_begin_end(
47f4a2713aSLionel Sambuc Comment::child_iterator (Comment::*)() const) {
48f4a2713aSLionel Sambuc return bad();
49f4a2713aSLionel Sambuc }
50f4a2713aSLionel Sambuc
51f4a2713aSLionel Sambuc #define ASSERT_IMPLEMENTS_child_begin(function) \
52f4a2713aSLionel Sambuc (void) good(implements_child_begin_end(function))
53f4a2713aSLionel Sambuc
54f4a2713aSLionel Sambuc LLVM_ATTRIBUTE_UNUSED
CheckCommentASTNodes()55f4a2713aSLionel Sambuc static inline void CheckCommentASTNodes() {
56f4a2713aSLionel Sambuc #define ABSTRACT_COMMENT(COMMENT)
57f4a2713aSLionel Sambuc #define COMMENT(CLASS, PARENT) \
58f4a2713aSLionel Sambuc ASSERT_IMPLEMENTS_child_begin(&CLASS::child_begin); \
59f4a2713aSLionel Sambuc ASSERT_IMPLEMENTS_child_begin(&CLASS::child_end);
60f4a2713aSLionel Sambuc #include "clang/AST/CommentNodes.inc"
61f4a2713aSLionel Sambuc #undef COMMENT
62f4a2713aSLionel Sambuc #undef ABSTRACT_COMMENT
63f4a2713aSLionel Sambuc }
64f4a2713aSLionel Sambuc
65f4a2713aSLionel Sambuc #undef ASSERT_IMPLEMENTS_child_begin
66f4a2713aSLionel Sambuc
67f4a2713aSLionel Sambuc } // end unnamed namespace
68f4a2713aSLionel Sambuc
child_begin() const69f4a2713aSLionel Sambuc Comment::child_iterator Comment::child_begin() const {
70f4a2713aSLionel Sambuc switch (getCommentKind()) {
71f4a2713aSLionel Sambuc case NoCommentKind: llvm_unreachable("comment without a kind");
72f4a2713aSLionel Sambuc #define ABSTRACT_COMMENT(COMMENT)
73f4a2713aSLionel Sambuc #define COMMENT(CLASS, PARENT) \
74f4a2713aSLionel Sambuc case CLASS##Kind: \
75f4a2713aSLionel Sambuc return static_cast<const CLASS *>(this)->child_begin();
76f4a2713aSLionel Sambuc #include "clang/AST/CommentNodes.inc"
77f4a2713aSLionel Sambuc #undef COMMENT
78f4a2713aSLionel Sambuc #undef ABSTRACT_COMMENT
79f4a2713aSLionel Sambuc }
80f4a2713aSLionel Sambuc llvm_unreachable("Unknown comment kind!");
81f4a2713aSLionel Sambuc }
82f4a2713aSLionel Sambuc
child_end() const83f4a2713aSLionel Sambuc Comment::child_iterator Comment::child_end() const {
84f4a2713aSLionel Sambuc switch (getCommentKind()) {
85f4a2713aSLionel Sambuc case NoCommentKind: llvm_unreachable("comment without a kind");
86f4a2713aSLionel Sambuc #define ABSTRACT_COMMENT(COMMENT)
87f4a2713aSLionel Sambuc #define COMMENT(CLASS, PARENT) \
88f4a2713aSLionel Sambuc case CLASS##Kind: \
89f4a2713aSLionel Sambuc return static_cast<const CLASS *>(this)->child_end();
90f4a2713aSLionel Sambuc #include "clang/AST/CommentNodes.inc"
91f4a2713aSLionel Sambuc #undef COMMENT
92f4a2713aSLionel Sambuc #undef ABSTRACT_COMMENT
93f4a2713aSLionel Sambuc }
94f4a2713aSLionel Sambuc llvm_unreachable("Unknown comment kind!");
95f4a2713aSLionel Sambuc }
96f4a2713aSLionel Sambuc
isWhitespaceNoCache() const97f4a2713aSLionel Sambuc bool TextComment::isWhitespaceNoCache() const {
98f4a2713aSLionel Sambuc for (StringRef::const_iterator I = Text.begin(), E = Text.end();
99f4a2713aSLionel Sambuc I != E; ++I) {
100f4a2713aSLionel Sambuc if (!clang::isWhitespace(*I))
101f4a2713aSLionel Sambuc return false;
102f4a2713aSLionel Sambuc }
103f4a2713aSLionel Sambuc return true;
104f4a2713aSLionel Sambuc }
105f4a2713aSLionel Sambuc
isWhitespaceNoCache() const106f4a2713aSLionel Sambuc bool ParagraphComment::isWhitespaceNoCache() const {
107f4a2713aSLionel Sambuc for (child_iterator I = child_begin(), E = child_end(); I != E; ++I) {
108f4a2713aSLionel Sambuc if (const TextComment *TC = dyn_cast<TextComment>(*I)) {
109f4a2713aSLionel Sambuc if (!TC->isWhitespace())
110f4a2713aSLionel Sambuc return false;
111f4a2713aSLionel Sambuc } else
112f4a2713aSLionel Sambuc return false;
113f4a2713aSLionel Sambuc }
114f4a2713aSLionel Sambuc return true;
115f4a2713aSLionel Sambuc }
116f4a2713aSLionel Sambuc
getDirectionAsString(PassDirection D)117f4a2713aSLionel Sambuc const char *ParamCommandComment::getDirectionAsString(PassDirection D) {
118f4a2713aSLionel Sambuc switch (D) {
119f4a2713aSLionel Sambuc case ParamCommandComment::In:
120f4a2713aSLionel Sambuc return "[in]";
121f4a2713aSLionel Sambuc case ParamCommandComment::Out:
122f4a2713aSLionel Sambuc return "[out]";
123f4a2713aSLionel Sambuc case ParamCommandComment::InOut:
124f4a2713aSLionel Sambuc return "[in,out]";
125f4a2713aSLionel Sambuc }
126f4a2713aSLionel Sambuc llvm_unreachable("unknown PassDirection");
127f4a2713aSLionel Sambuc }
128f4a2713aSLionel Sambuc
fill()129f4a2713aSLionel Sambuc void DeclInfo::fill() {
130f4a2713aSLionel Sambuc assert(!IsFilled);
131f4a2713aSLionel Sambuc
132f4a2713aSLionel Sambuc // Set defaults.
133f4a2713aSLionel Sambuc Kind = OtherKind;
134f4a2713aSLionel Sambuc TemplateKind = NotTemplate;
135f4a2713aSLionel Sambuc IsObjCMethod = false;
136f4a2713aSLionel Sambuc IsInstanceMethod = false;
137f4a2713aSLionel Sambuc IsClassMethod = false;
138f4a2713aSLionel Sambuc ParamVars = None;
139*0a6a1f1dSLionel Sambuc TemplateParameters = nullptr;
140f4a2713aSLionel Sambuc
141f4a2713aSLionel Sambuc if (!CommentDecl) {
142f4a2713aSLionel Sambuc // If there is no declaration, the defaults is our only guess.
143f4a2713aSLionel Sambuc IsFilled = true;
144f4a2713aSLionel Sambuc return;
145f4a2713aSLionel Sambuc }
146f4a2713aSLionel Sambuc CurrentDecl = CommentDecl;
147f4a2713aSLionel Sambuc
148f4a2713aSLionel Sambuc Decl::Kind K = CommentDecl->getKind();
149f4a2713aSLionel Sambuc switch (K) {
150f4a2713aSLionel Sambuc default:
151f4a2713aSLionel Sambuc // Defaults are should be good for declarations we don't handle explicitly.
152f4a2713aSLionel Sambuc break;
153f4a2713aSLionel Sambuc case Decl::Function:
154f4a2713aSLionel Sambuc case Decl::CXXMethod:
155f4a2713aSLionel Sambuc case Decl::CXXConstructor:
156f4a2713aSLionel Sambuc case Decl::CXXDestructor:
157f4a2713aSLionel Sambuc case Decl::CXXConversion: {
158f4a2713aSLionel Sambuc const FunctionDecl *FD = cast<FunctionDecl>(CommentDecl);
159f4a2713aSLionel Sambuc Kind = FunctionKind;
160*0a6a1f1dSLionel Sambuc ParamVars = llvm::makeArrayRef(FD->param_begin(), FD->getNumParams());
161*0a6a1f1dSLionel Sambuc ReturnType = FD->getReturnType();
162f4a2713aSLionel Sambuc unsigned NumLists = FD->getNumTemplateParameterLists();
163f4a2713aSLionel Sambuc if (NumLists != 0) {
164f4a2713aSLionel Sambuc TemplateKind = TemplateSpecialization;
165f4a2713aSLionel Sambuc TemplateParameters =
166f4a2713aSLionel Sambuc FD->getTemplateParameterList(NumLists - 1);
167f4a2713aSLionel Sambuc }
168f4a2713aSLionel Sambuc
169f4a2713aSLionel Sambuc if (K == Decl::CXXMethod || K == Decl::CXXConstructor ||
170f4a2713aSLionel Sambuc K == Decl::CXXDestructor || K == Decl::CXXConversion) {
171f4a2713aSLionel Sambuc const CXXMethodDecl *MD = cast<CXXMethodDecl>(CommentDecl);
172f4a2713aSLionel Sambuc IsInstanceMethod = MD->isInstance();
173f4a2713aSLionel Sambuc IsClassMethod = !IsInstanceMethod;
174f4a2713aSLionel Sambuc }
175f4a2713aSLionel Sambuc break;
176f4a2713aSLionel Sambuc }
177f4a2713aSLionel Sambuc case Decl::ObjCMethod: {
178f4a2713aSLionel Sambuc const ObjCMethodDecl *MD = cast<ObjCMethodDecl>(CommentDecl);
179f4a2713aSLionel Sambuc Kind = FunctionKind;
180*0a6a1f1dSLionel Sambuc ParamVars = llvm::makeArrayRef(MD->param_begin(), MD->param_size());
181*0a6a1f1dSLionel Sambuc ReturnType = MD->getReturnType();
182f4a2713aSLionel Sambuc IsObjCMethod = true;
183f4a2713aSLionel Sambuc IsInstanceMethod = MD->isInstanceMethod();
184f4a2713aSLionel Sambuc IsClassMethod = !IsInstanceMethod;
185f4a2713aSLionel Sambuc break;
186f4a2713aSLionel Sambuc }
187f4a2713aSLionel Sambuc case Decl::FunctionTemplate: {
188f4a2713aSLionel Sambuc const FunctionTemplateDecl *FTD = cast<FunctionTemplateDecl>(CommentDecl);
189f4a2713aSLionel Sambuc Kind = FunctionKind;
190f4a2713aSLionel Sambuc TemplateKind = Template;
191f4a2713aSLionel Sambuc const FunctionDecl *FD = FTD->getTemplatedDecl();
192*0a6a1f1dSLionel Sambuc ParamVars = llvm::makeArrayRef(FD->param_begin(), FD->getNumParams());
193*0a6a1f1dSLionel Sambuc ReturnType = FD->getReturnType();
194f4a2713aSLionel Sambuc TemplateParameters = FTD->getTemplateParameters();
195f4a2713aSLionel Sambuc break;
196f4a2713aSLionel Sambuc }
197f4a2713aSLionel Sambuc case Decl::ClassTemplate: {
198f4a2713aSLionel Sambuc const ClassTemplateDecl *CTD = cast<ClassTemplateDecl>(CommentDecl);
199f4a2713aSLionel Sambuc Kind = ClassKind;
200f4a2713aSLionel Sambuc TemplateKind = Template;
201f4a2713aSLionel Sambuc TemplateParameters = CTD->getTemplateParameters();
202f4a2713aSLionel Sambuc break;
203f4a2713aSLionel Sambuc }
204f4a2713aSLionel Sambuc case Decl::ClassTemplatePartialSpecialization: {
205f4a2713aSLionel Sambuc const ClassTemplatePartialSpecializationDecl *CTPSD =
206f4a2713aSLionel Sambuc cast<ClassTemplatePartialSpecializationDecl>(CommentDecl);
207f4a2713aSLionel Sambuc Kind = ClassKind;
208f4a2713aSLionel Sambuc TemplateKind = TemplatePartialSpecialization;
209f4a2713aSLionel Sambuc TemplateParameters = CTPSD->getTemplateParameters();
210f4a2713aSLionel Sambuc break;
211f4a2713aSLionel Sambuc }
212f4a2713aSLionel Sambuc case Decl::ClassTemplateSpecialization:
213f4a2713aSLionel Sambuc Kind = ClassKind;
214f4a2713aSLionel Sambuc TemplateKind = TemplateSpecialization;
215f4a2713aSLionel Sambuc break;
216f4a2713aSLionel Sambuc case Decl::Record:
217f4a2713aSLionel Sambuc case Decl::CXXRecord:
218f4a2713aSLionel Sambuc Kind = ClassKind;
219f4a2713aSLionel Sambuc break;
220f4a2713aSLionel Sambuc case Decl::Var:
221f4a2713aSLionel Sambuc case Decl::Field:
222f4a2713aSLionel Sambuc case Decl::EnumConstant:
223f4a2713aSLionel Sambuc case Decl::ObjCIvar:
224f4a2713aSLionel Sambuc case Decl::ObjCAtDefsField:
225f4a2713aSLionel Sambuc Kind = VariableKind;
226f4a2713aSLionel Sambuc break;
227f4a2713aSLionel Sambuc case Decl::Namespace:
228f4a2713aSLionel Sambuc Kind = NamespaceKind;
229f4a2713aSLionel Sambuc break;
230f4a2713aSLionel Sambuc case Decl::Typedef: {
231f4a2713aSLionel Sambuc Kind = TypedefKind;
232f4a2713aSLionel Sambuc // If this is a typedef to something we consider a function, extract
233f4a2713aSLionel Sambuc // arguments and return type.
234f4a2713aSLionel Sambuc const TypedefDecl *TD = cast<TypedefDecl>(CommentDecl);
235f4a2713aSLionel Sambuc const TypeSourceInfo *TSI = TD->getTypeSourceInfo();
236f4a2713aSLionel Sambuc if (!TSI)
237f4a2713aSLionel Sambuc break;
238f4a2713aSLionel Sambuc TypeLoc TL = TSI->getTypeLoc().getUnqualifiedLoc();
239f4a2713aSLionel Sambuc while (true) {
240f4a2713aSLionel Sambuc TL = TL.IgnoreParens();
241f4a2713aSLionel Sambuc // Look through qualified types.
242f4a2713aSLionel Sambuc if (QualifiedTypeLoc QualifiedTL = TL.getAs<QualifiedTypeLoc>()) {
243f4a2713aSLionel Sambuc TL = QualifiedTL.getUnqualifiedLoc();
244f4a2713aSLionel Sambuc continue;
245f4a2713aSLionel Sambuc }
246f4a2713aSLionel Sambuc // Look through pointer types.
247f4a2713aSLionel Sambuc if (PointerTypeLoc PointerTL = TL.getAs<PointerTypeLoc>()) {
248f4a2713aSLionel Sambuc TL = PointerTL.getPointeeLoc().getUnqualifiedLoc();
249f4a2713aSLionel Sambuc continue;
250f4a2713aSLionel Sambuc }
251*0a6a1f1dSLionel Sambuc // Look through reference types.
252*0a6a1f1dSLionel Sambuc if (ReferenceTypeLoc ReferenceTL = TL.getAs<ReferenceTypeLoc>()) {
253*0a6a1f1dSLionel Sambuc TL = ReferenceTL.getPointeeLoc().getUnqualifiedLoc();
254*0a6a1f1dSLionel Sambuc continue;
255*0a6a1f1dSLionel Sambuc }
256*0a6a1f1dSLionel Sambuc // Look through adjusted types.
257*0a6a1f1dSLionel Sambuc if (AdjustedTypeLoc ATL = TL.getAs<AdjustedTypeLoc>()) {
258*0a6a1f1dSLionel Sambuc TL = ATL.getOriginalLoc();
259*0a6a1f1dSLionel Sambuc continue;
260*0a6a1f1dSLionel Sambuc }
261f4a2713aSLionel Sambuc if (BlockPointerTypeLoc BlockPointerTL =
262f4a2713aSLionel Sambuc TL.getAs<BlockPointerTypeLoc>()) {
263f4a2713aSLionel Sambuc TL = BlockPointerTL.getPointeeLoc().getUnqualifiedLoc();
264f4a2713aSLionel Sambuc continue;
265f4a2713aSLionel Sambuc }
266f4a2713aSLionel Sambuc if (MemberPointerTypeLoc MemberPointerTL =
267f4a2713aSLionel Sambuc TL.getAs<MemberPointerTypeLoc>()) {
268f4a2713aSLionel Sambuc TL = MemberPointerTL.getPointeeLoc().getUnqualifiedLoc();
269f4a2713aSLionel Sambuc continue;
270f4a2713aSLionel Sambuc }
271*0a6a1f1dSLionel Sambuc if (ElaboratedTypeLoc ETL = TL.getAs<ElaboratedTypeLoc>()) {
272*0a6a1f1dSLionel Sambuc TL = ETL.getNamedTypeLoc();
273*0a6a1f1dSLionel Sambuc continue;
274*0a6a1f1dSLionel Sambuc }
275f4a2713aSLionel Sambuc // Is this a typedef for a function type?
276f4a2713aSLionel Sambuc if (FunctionTypeLoc FTL = TL.getAs<FunctionTypeLoc>()) {
277f4a2713aSLionel Sambuc Kind = FunctionKind;
278*0a6a1f1dSLionel Sambuc ParamVars = FTL.getParams();
279*0a6a1f1dSLionel Sambuc ReturnType = FTL.getReturnLoc().getType();
280*0a6a1f1dSLionel Sambuc break;
281*0a6a1f1dSLionel Sambuc }
282*0a6a1f1dSLionel Sambuc if (TemplateSpecializationTypeLoc STL =
283*0a6a1f1dSLionel Sambuc TL.getAs<TemplateSpecializationTypeLoc>()) {
284*0a6a1f1dSLionel Sambuc // If we have a typedef to a template specialization with exactly one
285*0a6a1f1dSLionel Sambuc // template argument of a function type, this looks like std::function,
286*0a6a1f1dSLionel Sambuc // boost::function, or other function wrapper. Treat these typedefs as
287*0a6a1f1dSLionel Sambuc // functions.
288*0a6a1f1dSLionel Sambuc if (STL.getNumArgs() != 1)
289*0a6a1f1dSLionel Sambuc break;
290*0a6a1f1dSLionel Sambuc TemplateArgumentLoc MaybeFunction = STL.getArgLoc(0);
291*0a6a1f1dSLionel Sambuc if (MaybeFunction.getArgument().getKind() != TemplateArgument::Type)
292*0a6a1f1dSLionel Sambuc break;
293*0a6a1f1dSLionel Sambuc TypeSourceInfo *MaybeFunctionTSI = MaybeFunction.getTypeSourceInfo();
294*0a6a1f1dSLionel Sambuc TypeLoc TL = MaybeFunctionTSI->getTypeLoc().getUnqualifiedLoc();
295*0a6a1f1dSLionel Sambuc if (FunctionTypeLoc FTL = TL.getAs<FunctionTypeLoc>()) {
296*0a6a1f1dSLionel Sambuc Kind = FunctionKind;
297*0a6a1f1dSLionel Sambuc ParamVars = FTL.getParams();
298*0a6a1f1dSLionel Sambuc ReturnType = FTL.getReturnLoc().getType();
299*0a6a1f1dSLionel Sambuc }
300f4a2713aSLionel Sambuc break;
301f4a2713aSLionel Sambuc }
302f4a2713aSLionel Sambuc break;
303f4a2713aSLionel Sambuc }
304f4a2713aSLionel Sambuc break;
305f4a2713aSLionel Sambuc }
306f4a2713aSLionel Sambuc case Decl::TypeAlias:
307f4a2713aSLionel Sambuc Kind = TypedefKind;
308f4a2713aSLionel Sambuc break;
309f4a2713aSLionel Sambuc case Decl::TypeAliasTemplate: {
310f4a2713aSLionel Sambuc const TypeAliasTemplateDecl *TAT = cast<TypeAliasTemplateDecl>(CommentDecl);
311f4a2713aSLionel Sambuc Kind = TypedefKind;
312f4a2713aSLionel Sambuc TemplateKind = Template;
313f4a2713aSLionel Sambuc TemplateParameters = TAT->getTemplateParameters();
314f4a2713aSLionel Sambuc break;
315f4a2713aSLionel Sambuc }
316f4a2713aSLionel Sambuc case Decl::Enum:
317f4a2713aSLionel Sambuc Kind = EnumKind;
318f4a2713aSLionel Sambuc break;
319f4a2713aSLionel Sambuc }
320f4a2713aSLionel Sambuc
321f4a2713aSLionel Sambuc IsFilled = true;
322f4a2713aSLionel Sambuc }
323f4a2713aSLionel Sambuc
getParamName(const FullComment * FC) const324f4a2713aSLionel Sambuc StringRef ParamCommandComment::getParamName(const FullComment *FC) const {
325f4a2713aSLionel Sambuc assert(isParamIndexValid());
326f4a2713aSLionel Sambuc if (isVarArgParam())
327f4a2713aSLionel Sambuc return "...";
328f4a2713aSLionel Sambuc return FC->getDeclInfo()->ParamVars[getParamIndex()]->getName();
329f4a2713aSLionel Sambuc }
330f4a2713aSLionel Sambuc
getParamName(const FullComment * FC) const331f4a2713aSLionel Sambuc StringRef TParamCommandComment::getParamName(const FullComment *FC) const {
332f4a2713aSLionel Sambuc assert(isPositionValid());
333f4a2713aSLionel Sambuc const TemplateParameterList *TPL = FC->getDeclInfo()->TemplateParameters;
334f4a2713aSLionel Sambuc for (unsigned i = 0, e = getDepth(); i != e; ++i) {
335f4a2713aSLionel Sambuc if (i == e-1)
336f4a2713aSLionel Sambuc return TPL->getParam(getIndex(i))->getName();
337f4a2713aSLionel Sambuc const NamedDecl *Param = TPL->getParam(getIndex(i));
338f4a2713aSLionel Sambuc if (const TemplateTemplateParmDecl *TTP =
339f4a2713aSLionel Sambuc dyn_cast<TemplateTemplateParmDecl>(Param))
340f4a2713aSLionel Sambuc TPL = TTP->getTemplateParameters();
341f4a2713aSLionel Sambuc }
342f4a2713aSLionel Sambuc return "";
343f4a2713aSLionel Sambuc }
344f4a2713aSLionel Sambuc
345f4a2713aSLionel Sambuc } // end namespace comments
346f4a2713aSLionel Sambuc } // end namespace clang
347f4a2713aSLionel Sambuc
348