2012-07-06 08:28:32 +08:00
|
|
|
//===--- Comment.cpp - Comment AST node implementation --------------------===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2012-07-06 08:28:32 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "clang/AST/Comment.h"
|
2016-07-19 03:02:11 +08:00
|
|
|
#include "clang/AST/ASTContext.h"
|
2012-08-02 07:08:09 +08:00
|
|
|
#include "clang/AST/Decl.h"
|
|
|
|
#include "clang/AST/DeclObjC.h"
|
|
|
|
#include "clang/AST/DeclTemplate.h"
|
2013-08-24 01:45:43 +08:00
|
|
|
#include "clang/Basic/CharInfo.h"
|
2012-07-06 08:28:32 +08:00
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
|
|
|
|
|
|
|
namespace clang {
|
|
|
|
namespace comments {
|
|
|
|
|
|
|
|
const char *Comment::getCommentKindName() const {
|
|
|
|
switch (getCommentKind()) {
|
|
|
|
case NoCommentKind: return "NoCommentKind";
|
|
|
|
#define ABSTRACT_COMMENT(COMMENT)
|
|
|
|
#define COMMENT(CLASS, PARENT) \
|
|
|
|
case CLASS##Kind: \
|
|
|
|
return #CLASS;
|
|
|
|
#include "clang/AST/CommentNodes.inc"
|
|
|
|
#undef COMMENT
|
|
|
|
#undef ABSTRACT_COMMENT
|
|
|
|
}
|
|
|
|
llvm_unreachable("Unknown comment kind!");
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
struct good {};
|
|
|
|
struct bad {};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
good implements_child_begin_end(Comment::child_iterator (T::*)() const) {
|
|
|
|
return good();
|
|
|
|
}
|
|
|
|
|
2013-09-11 06:57:15 +08:00
|
|
|
LLVM_ATTRIBUTE_UNUSED
|
2012-07-06 08:28:32 +08:00
|
|
|
static inline bad implements_child_begin_end(
|
|
|
|
Comment::child_iterator (Comment::*)() const) {
|
|
|
|
return bad();
|
|
|
|
}
|
|
|
|
|
|
|
|
#define ASSERT_IMPLEMENTS_child_begin(function) \
|
2013-09-11 06:57:15 +08:00
|
|
|
(void) good(implements_child_begin_end(function))
|
2012-07-06 08:28:32 +08:00
|
|
|
|
2013-09-11 06:57:15 +08:00
|
|
|
LLVM_ATTRIBUTE_UNUSED
|
2012-07-06 08:28:32 +08:00
|
|
|
static inline void CheckCommentASTNodes() {
|
|
|
|
#define ABSTRACT_COMMENT(COMMENT)
|
|
|
|
#define COMMENT(CLASS, PARENT) \
|
|
|
|
ASSERT_IMPLEMENTS_child_begin(&CLASS::child_begin); \
|
|
|
|
ASSERT_IMPLEMENTS_child_begin(&CLASS::child_end);
|
|
|
|
#include "clang/AST/CommentNodes.inc"
|
|
|
|
#undef COMMENT
|
|
|
|
#undef ABSTRACT_COMMENT
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef ASSERT_IMPLEMENTS_child_begin
|
|
|
|
|
|
|
|
} // end unnamed namespace
|
|
|
|
|
|
|
|
Comment::child_iterator Comment::child_begin() const {
|
|
|
|
switch (getCommentKind()) {
|
|
|
|
case NoCommentKind: llvm_unreachable("comment without a kind");
|
|
|
|
#define ABSTRACT_COMMENT(COMMENT)
|
|
|
|
#define COMMENT(CLASS, PARENT) \
|
|
|
|
case CLASS##Kind: \
|
|
|
|
return static_cast<const CLASS *>(this)->child_begin();
|
|
|
|
#include "clang/AST/CommentNodes.inc"
|
|
|
|
#undef COMMENT
|
|
|
|
#undef ABSTRACT_COMMENT
|
|
|
|
}
|
2012-07-07 05:13:09 +08:00
|
|
|
llvm_unreachable("Unknown comment kind!");
|
2012-07-06 08:28:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Comment::child_iterator Comment::child_end() const {
|
|
|
|
switch (getCommentKind()) {
|
|
|
|
case NoCommentKind: llvm_unreachable("comment without a kind");
|
|
|
|
#define ABSTRACT_COMMENT(COMMENT)
|
|
|
|
#define COMMENT(CLASS, PARENT) \
|
|
|
|
case CLASS##Kind: \
|
|
|
|
return static_cast<const CLASS *>(this)->child_end();
|
|
|
|
#include "clang/AST/CommentNodes.inc"
|
|
|
|
#undef COMMENT
|
|
|
|
#undef ABSTRACT_COMMENT
|
|
|
|
}
|
2012-07-07 05:13:09 +08:00
|
|
|
llvm_unreachable("Unknown comment kind!");
|
2012-07-06 08:28:32 +08:00
|
|
|
}
|
|
|
|
|
2012-07-19 04:54:32 +08:00
|
|
|
bool TextComment::isWhitespaceNoCache() const {
|
2012-07-12 05:38:39 +08:00
|
|
|
for (StringRef::const_iterator I = Text.begin(), E = Text.end();
|
|
|
|
I != E; ++I) {
|
2013-08-24 01:45:43 +08:00
|
|
|
if (!clang::isWhitespace(*I))
|
2012-07-12 05:38:39 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-19 04:54:32 +08:00
|
|
|
bool ParagraphComment::isWhitespaceNoCache() const {
|
2012-07-12 05:38:39 +08:00
|
|
|
for (child_iterator I = child_begin(), E = child_end(); I != E; ++I) {
|
|
|
|
if (const TextComment *TC = dyn_cast<TextComment>(*I)) {
|
|
|
|
if (!TC->isWhitespace())
|
|
|
|
return false;
|
2012-07-19 08:01:56 +08:00
|
|
|
} else
|
|
|
|
return false;
|
2012-07-12 05:38:39 +08:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-08-25 08:22:08 +08:00
|
|
|
static TypeLoc lookThroughTypedefOrTypeAliasLocs(TypeLoc &SrcTL) {
|
|
|
|
TypeLoc TL = SrcTL.IgnoreParens();
|
|
|
|
|
2017-04-26 20:46:27 +08:00
|
|
|
// Look through attribute types.
|
|
|
|
if (AttributedTypeLoc AttributeTL = TL.getAs<AttributedTypeLoc>())
|
|
|
|
return AttributeTL.getModifiedLoc();
|
2016-08-25 08:22:08 +08:00
|
|
|
// Look through qualified types.
|
|
|
|
if (QualifiedTypeLoc QualifiedTL = TL.getAs<QualifiedTypeLoc>())
|
|
|
|
return QualifiedTL.getUnqualifiedLoc();
|
|
|
|
// Look through pointer types.
|
|
|
|
if (PointerTypeLoc PointerTL = TL.getAs<PointerTypeLoc>())
|
|
|
|
return PointerTL.getPointeeLoc().getUnqualifiedLoc();
|
|
|
|
// Look through reference types.
|
|
|
|
if (ReferenceTypeLoc ReferenceTL = TL.getAs<ReferenceTypeLoc>())
|
|
|
|
return ReferenceTL.getPointeeLoc().getUnqualifiedLoc();
|
|
|
|
// Look through adjusted types.
|
|
|
|
if (AdjustedTypeLoc ATL = TL.getAs<AdjustedTypeLoc>())
|
|
|
|
return ATL.getOriginalLoc();
|
|
|
|
if (BlockPointerTypeLoc BlockPointerTL = TL.getAs<BlockPointerTypeLoc>())
|
|
|
|
return BlockPointerTL.getPointeeLoc().getUnqualifiedLoc();
|
|
|
|
if (MemberPointerTypeLoc MemberPointerTL = TL.getAs<MemberPointerTypeLoc>())
|
|
|
|
return MemberPointerTL.getPointeeLoc().getUnqualifiedLoc();
|
|
|
|
if (ElaboratedTypeLoc ETL = TL.getAs<ElaboratedTypeLoc>())
|
|
|
|
return ETL.getNamedTypeLoc();
|
|
|
|
|
|
|
|
return TL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool getFunctionTypeLoc(TypeLoc TL, FunctionTypeLoc &ResFTL) {
|
|
|
|
TypeLoc PrevTL;
|
|
|
|
while (PrevTL != TL) {
|
|
|
|
PrevTL = TL;
|
|
|
|
TL = lookThroughTypedefOrTypeAliasLocs(TL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FunctionTypeLoc FTL = TL.getAs<FunctionTypeLoc>()) {
|
|
|
|
ResFTL = FTL;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TemplateSpecializationTypeLoc STL =
|
|
|
|
TL.getAs<TemplateSpecializationTypeLoc>()) {
|
|
|
|
// If we have a typedef to a template specialization with exactly one
|
|
|
|
// template argument of a function type, this looks like std::function,
|
|
|
|
// boost::function, or other function wrapper. Treat these typedefs as
|
|
|
|
// functions.
|
|
|
|
if (STL.getNumArgs() != 1)
|
|
|
|
return false;
|
|
|
|
TemplateArgumentLoc MaybeFunction = STL.getArgLoc(0);
|
|
|
|
if (MaybeFunction.getArgument().getKind() != TemplateArgument::Type)
|
|
|
|
return false;
|
|
|
|
TypeSourceInfo *MaybeFunctionTSI = MaybeFunction.getTypeSourceInfo();
|
|
|
|
TypeLoc TL = MaybeFunctionTSI->getTypeLoc().getUnqualifiedLoc();
|
|
|
|
if (FunctionTypeLoc FTL = TL.getAs<FunctionTypeLoc>()) {
|
|
|
|
ResFTL = FTL;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-07-12 05:38:39 +08:00
|
|
|
const char *ParamCommandComment::getDirectionAsString(PassDirection D) {
|
|
|
|
switch (D) {
|
|
|
|
case ParamCommandComment::In:
|
|
|
|
return "[in]";
|
|
|
|
case ParamCommandComment::Out:
|
|
|
|
return "[out]";
|
|
|
|
case ParamCommandComment::InOut:
|
|
|
|
return "[in,out]";
|
|
|
|
}
|
|
|
|
llvm_unreachable("unknown PassDirection");
|
|
|
|
}
|
2012-07-06 08:28:32 +08:00
|
|
|
|
2012-08-02 07:08:09 +08:00
|
|
|
void DeclInfo::fill() {
|
|
|
|
assert(!IsFilled);
|
|
|
|
|
|
|
|
// Set defaults.
|
2012-08-04 05:15:32 +08:00
|
|
|
Kind = OtherKind;
|
2012-08-07 05:31:15 +08:00
|
|
|
TemplateKind = NotTemplate;
|
2012-08-07 00:29:26 +08:00
|
|
|
IsObjCMethod = false;
|
2012-08-02 07:08:09 +08:00
|
|
|
IsInstanceMethod = false;
|
|
|
|
IsClassMethod = false;
|
2013-05-05 08:41:58 +08:00
|
|
|
ParamVars = None;
|
2014-05-12 13:36:57 +08:00
|
|
|
TemplateParameters = nullptr;
|
2012-08-02 07:08:09 +08:00
|
|
|
|
2012-10-11 02:34:52 +08:00
|
|
|
if (!CommentDecl) {
|
2012-08-03 08:01:01 +08:00
|
|
|
// If there is no declaration, the defaults is our only guess.
|
|
|
|
IsFilled = true;
|
|
|
|
return;
|
|
|
|
}
|
2012-10-18 05:58:03 +08:00
|
|
|
CurrentDecl = CommentDecl;
|
2018-07-31 03:24:48 +08:00
|
|
|
|
2012-10-11 02:34:52 +08:00
|
|
|
Decl::Kind K = CommentDecl->getKind();
|
2012-08-03 08:01:01 +08:00
|
|
|
switch (K) {
|
|
|
|
default:
|
|
|
|
// Defaults are should be good for declarations we don't handle explicitly.
|
|
|
|
break;
|
|
|
|
case Decl::Function:
|
|
|
|
case Decl::CXXMethod:
|
|
|
|
case Decl::CXXConstructor:
|
|
|
|
case Decl::CXXDestructor:
|
|
|
|
case Decl::CXXConversion: {
|
2012-10-11 02:34:52 +08:00
|
|
|
const FunctionDecl *FD = cast<FunctionDecl>(CommentDecl);
|
2012-08-03 05:45:39 +08:00
|
|
|
Kind = FunctionKind;
|
2016-06-24 12:05:48 +08:00
|
|
|
ParamVars = FD->parameters();
|
2014-01-26 00:55:45 +08:00
|
|
|
ReturnType = FD->getReturnType();
|
2012-08-02 07:08:09 +08:00
|
|
|
unsigned NumLists = FD->getNumTemplateParameterLists();
|
|
|
|
if (NumLists != 0) {
|
2012-08-07 05:31:15 +08:00
|
|
|
TemplateKind = TemplateSpecialization;
|
2012-08-02 07:08:09 +08:00
|
|
|
TemplateParameters =
|
|
|
|
FD->getTemplateParameterList(NumLists - 1);
|
|
|
|
}
|
|
|
|
|
2012-08-04 05:15:32 +08:00
|
|
|
if (K == Decl::CXXMethod || K == Decl::CXXConstructor ||
|
|
|
|
K == Decl::CXXDestructor || K == Decl::CXXConversion) {
|
2012-10-11 02:34:52 +08:00
|
|
|
const CXXMethodDecl *MD = cast<CXXMethodDecl>(CommentDecl);
|
2012-08-02 07:08:09 +08:00
|
|
|
IsInstanceMethod = MD->isInstance();
|
|
|
|
IsClassMethod = !IsInstanceMethod;
|
|
|
|
}
|
2012-08-03 08:01:01 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Decl::ObjCMethod: {
|
2012-10-11 02:34:52 +08:00
|
|
|
const ObjCMethodDecl *MD = cast<ObjCMethodDecl>(CommentDecl);
|
2012-08-03 05:45:39 +08:00
|
|
|
Kind = FunctionKind;
|
2016-06-24 12:05:48 +08:00
|
|
|
ParamVars = MD->parameters();
|
2014-01-26 00:55:45 +08:00
|
|
|
ReturnType = MD->getReturnType();
|
2012-08-07 00:29:26 +08:00
|
|
|
IsObjCMethod = true;
|
2012-08-02 07:08:09 +08:00
|
|
|
IsInstanceMethod = MD->isInstanceMethod();
|
|
|
|
IsClassMethod = !IsInstanceMethod;
|
2012-08-03 08:01:01 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Decl::FunctionTemplate: {
|
2012-10-11 02:34:52 +08:00
|
|
|
const FunctionTemplateDecl *FTD = cast<FunctionTemplateDecl>(CommentDecl);
|
2012-08-03 05:45:39 +08:00
|
|
|
Kind = FunctionKind;
|
2012-08-07 05:31:15 +08:00
|
|
|
TemplateKind = Template;
|
2012-08-02 07:08:09 +08:00
|
|
|
const FunctionDecl *FD = FTD->getTemplatedDecl();
|
2016-06-24 12:05:48 +08:00
|
|
|
ParamVars = FD->parameters();
|
2014-01-26 00:55:45 +08:00
|
|
|
ReturnType = FD->getReturnType();
|
2012-08-02 07:08:09 +08:00
|
|
|
TemplateParameters = FTD->getTemplateParameters();
|
2012-08-03 08:01:01 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Decl::ClassTemplate: {
|
2012-10-11 02:34:52 +08:00
|
|
|
const ClassTemplateDecl *CTD = cast<ClassTemplateDecl>(CommentDecl);
|
2012-08-03 05:45:39 +08:00
|
|
|
Kind = ClassKind;
|
2012-08-07 05:31:15 +08:00
|
|
|
TemplateKind = Template;
|
2012-08-02 07:08:09 +08:00
|
|
|
TemplateParameters = CTD->getTemplateParameters();
|
2012-08-03 08:01:01 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Decl::ClassTemplatePartialSpecialization: {
|
|
|
|
const ClassTemplatePartialSpecializationDecl *CTPSD =
|
2012-10-11 02:34:52 +08:00
|
|
|
cast<ClassTemplatePartialSpecializationDecl>(CommentDecl);
|
2012-08-03 05:45:39 +08:00
|
|
|
Kind = ClassKind;
|
2012-08-07 05:31:15 +08:00
|
|
|
TemplateKind = TemplatePartialSpecialization;
|
2012-08-02 07:08:09 +08:00
|
|
|
TemplateParameters = CTPSD->getTemplateParameters();
|
2012-08-03 08:01:01 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Decl::ClassTemplateSpecialization:
|
2012-08-03 05:45:39 +08:00
|
|
|
Kind = ClassKind;
|
2012-08-07 05:31:15 +08:00
|
|
|
TemplateKind = TemplateSpecialization;
|
2012-08-03 08:01:01 +08:00
|
|
|
break;
|
|
|
|
case Decl::Record:
|
2012-08-04 05:15:32 +08:00
|
|
|
case Decl::CXXRecord:
|
2012-08-03 05:45:39 +08:00
|
|
|
Kind = ClassKind;
|
2012-08-03 08:01:01 +08:00
|
|
|
break;
|
|
|
|
case Decl::Var:
|
|
|
|
case Decl::Field:
|
2012-08-08 02:12:22 +08:00
|
|
|
case Decl::EnumConstant:
|
2012-08-03 08:01:01 +08:00
|
|
|
case Decl::ObjCIvar:
|
|
|
|
case Decl::ObjCAtDefsField:
|
2017-04-21 22:17:49 +08:00
|
|
|
case Decl::ObjCProperty: {
|
|
|
|
const TypeSourceInfo *TSI;
|
|
|
|
if (const auto *VD = dyn_cast<DeclaratorDecl>(CommentDecl))
|
|
|
|
TSI = VD->getTypeSourceInfo();
|
|
|
|
else if (const auto *PD = dyn_cast<ObjCPropertyDecl>(CommentDecl))
|
|
|
|
TSI = PD->getTypeSourceInfo();
|
|
|
|
else
|
|
|
|
TSI = nullptr;
|
|
|
|
if (TSI) {
|
|
|
|
TypeLoc TL = TSI->getTypeLoc().getUnqualifiedLoc();
|
|
|
|
FunctionTypeLoc FTL;
|
|
|
|
if (getFunctionTypeLoc(TL, FTL)) {
|
|
|
|
ParamVars = FTL.getParams();
|
|
|
|
ReturnType = FTL.getReturnLoc().getType();
|
|
|
|
}
|
|
|
|
}
|
2012-08-03 05:45:39 +08:00
|
|
|
Kind = VariableKind;
|
2012-08-03 08:01:01 +08:00
|
|
|
break;
|
2017-04-21 22:17:49 +08:00
|
|
|
}
|
2012-08-03 08:01:01 +08:00
|
|
|
case Decl::Namespace:
|
2012-08-03 05:45:39 +08:00
|
|
|
Kind = NamespaceKind;
|
2012-08-03 08:01:01 +08:00
|
|
|
break;
|
2016-08-25 05:11:43 +08:00
|
|
|
case Decl::TypeAlias:
|
2012-08-24 08:05:30 +08:00
|
|
|
case Decl::Typedef: {
|
|
|
|
Kind = TypedefKind;
|
2016-08-25 05:11:43 +08:00
|
|
|
// If this is a typedef / using to something we consider a function, extract
|
2012-08-24 08:05:30 +08:00
|
|
|
// arguments and return type.
|
2016-08-25 05:11:43 +08:00
|
|
|
const TypeSourceInfo *TSI =
|
|
|
|
K == Decl::Typedef
|
|
|
|
? cast<TypedefDecl>(CommentDecl)->getTypeSourceInfo()
|
|
|
|
: cast<TypeAliasDecl>(CommentDecl)->getTypeSourceInfo();
|
2012-08-24 08:05:30 +08:00
|
|
|
if (!TSI)
|
|
|
|
break;
|
|
|
|
TypeLoc TL = TSI->getTypeLoc().getUnqualifiedLoc();
|
2016-08-25 08:22:08 +08:00
|
|
|
FunctionTypeLoc FTL;
|
|
|
|
if (getFunctionTypeLoc(TL, FTL)) {
|
|
|
|
Kind = FunctionKind;
|
|
|
|
ParamVars = FTL.getParams();
|
|
|
|
ReturnType = FTL.getReturnLoc().getType();
|
2012-08-24 08:05:30 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-08-03 08:01:01 +08:00
|
|
|
case Decl::TypeAliasTemplate: {
|
2012-10-11 02:34:52 +08:00
|
|
|
const TypeAliasTemplateDecl *TAT = cast<TypeAliasTemplateDecl>(CommentDecl);
|
2012-08-03 05:45:39 +08:00
|
|
|
Kind = TypedefKind;
|
2012-08-07 05:31:15 +08:00
|
|
|
TemplateKind = Template;
|
2012-08-03 05:36:57 +08:00
|
|
|
TemplateParameters = TAT->getTemplateParameters();
|
2016-08-26 01:09:33 +08:00
|
|
|
TypeAliasDecl *TAD = TAT->getTemplatedDecl();
|
|
|
|
if (!TAD)
|
|
|
|
break;
|
|
|
|
|
|
|
|
const TypeSourceInfo *TSI = TAD->getTypeSourceInfo();
|
|
|
|
if (!TSI)
|
|
|
|
break;
|
|
|
|
TypeLoc TL = TSI->getTypeLoc().getUnqualifiedLoc();
|
|
|
|
FunctionTypeLoc FTL;
|
|
|
|
if (getFunctionTypeLoc(TL, FTL)) {
|
|
|
|
Kind = FunctionKind;
|
|
|
|
ParamVars = FTL.getParams();
|
|
|
|
ReturnType = FTL.getReturnLoc().getType();
|
|
|
|
}
|
2012-08-03 08:01:01 +08:00
|
|
|
break;
|
2012-08-02 07:08:09 +08:00
|
|
|
}
|
2012-08-08 02:59:04 +08:00
|
|
|
case Decl::Enum:
|
|
|
|
Kind = EnumKind;
|
|
|
|
break;
|
2012-08-03 08:01:01 +08:00
|
|
|
}
|
|
|
|
|
2012-08-02 07:08:09 +08:00
|
|
|
IsFilled = true;
|
|
|
|
}
|
|
|
|
|
2012-10-20 00:51:38 +08:00
|
|
|
StringRef ParamCommandComment::getParamName(const FullComment *FC) const {
|
2012-10-19 05:42:42 +08:00
|
|
|
assert(isParamIndexValid());
|
2013-06-24 12:41:32 +08:00
|
|
|
if (isVarArgParam())
|
|
|
|
return "...";
|
2013-07-06 07:20:55 +08:00
|
|
|
return FC->getDeclInfo()->ParamVars[getParamIndex()]->getName();
|
2012-10-12 07:52:50 +08:00
|
|
|
}
|
|
|
|
|
2012-10-20 00:51:38 +08:00
|
|
|
StringRef TParamCommandComment::getParamName(const FullComment *FC) const {
|
2012-10-19 05:42:42 +08:00
|
|
|
assert(isPositionValid());
|
2013-07-06 07:20:55 +08:00
|
|
|
const TemplateParameterList *TPL = FC->getDeclInfo()->TemplateParameters;
|
2012-10-19 05:42:42 +08:00
|
|
|
for (unsigned i = 0, e = getDepth(); i != e; ++i) {
|
|
|
|
if (i == e-1)
|
|
|
|
return TPL->getParam(getIndex(i))->getName();
|
|
|
|
const NamedDecl *Param = TPL->getParam(getIndex(i));
|
|
|
|
if (const TemplateTemplateParmDecl *TTP =
|
2012-10-16 02:58:50 +08:00
|
|
|
dyn_cast<TemplateTemplateParmDecl>(Param))
|
2012-10-19 05:42:42 +08:00
|
|
|
TPL = TTP->getTemplateParameters();
|
2012-10-16 02:58:50 +08:00
|
|
|
}
|
2012-10-19 05:42:42 +08:00
|
|
|
return "";
|
2012-10-16 02:58:50 +08:00
|
|
|
}
|
2012-10-20 00:51:38 +08:00
|
|
|
|
2012-07-06 08:28:32 +08:00
|
|
|
} // end namespace comments
|
|
|
|
} // end namespace clang
|
2012-08-03 05:45:39 +08:00
|
|
|
|