Dmitri Gribenko | 8d3ba23 | 2012-07-06 00:28:32 +0000 | [diff] [blame] | 1 | //===--- Comment.cpp - Comment AST node implementation --------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
Dmitri Gribenko | e4330a3 | 2012-09-10 20:32:42 +0000 | [diff] [blame] | 10 | #include "clang/AST/ASTContext.h" |
Dmitri Gribenko | 8d3ba23 | 2012-07-06 00:28:32 +0000 | [diff] [blame] | 11 | #include "clang/AST/Comment.h" |
Dmitri Gribenko | 1ca7ecc | 2012-08-01 23:08:09 +0000 | [diff] [blame] | 12 | #include "clang/AST/Decl.h" |
| 13 | #include "clang/AST/DeclObjC.h" |
| 14 | #include "clang/AST/DeclTemplate.h" |
Dmitri Gribenko | 3520868 | 2013-08-23 17:45:43 +0000 | [diff] [blame^] | 15 | #include "clang/Basic/CharInfo.h" |
Dmitri Gribenko | 8d3ba23 | 2012-07-06 00:28:32 +0000 | [diff] [blame] | 16 | #include "llvm/Support/ErrorHandling.h" |
Dmitri Gribenko | fb3643a | 2012-07-18 16:30:42 +0000 | [diff] [blame] | 17 | #include "llvm/Support/raw_ostream.h" |
Dmitri Gribenko | 8d3ba23 | 2012-07-06 00:28:32 +0000 | [diff] [blame] | 18 | |
| 19 | namespace clang { |
| 20 | namespace comments { |
| 21 | |
| 22 | const char *Comment::getCommentKindName() const { |
| 23 | switch (getCommentKind()) { |
| 24 | case NoCommentKind: return "NoCommentKind"; |
| 25 | #define ABSTRACT_COMMENT(COMMENT) |
| 26 | #define COMMENT(CLASS, PARENT) \ |
| 27 | case CLASS##Kind: \ |
| 28 | return #CLASS; |
| 29 | #include "clang/AST/CommentNodes.inc" |
| 30 | #undef COMMENT |
| 31 | #undef ABSTRACT_COMMENT |
| 32 | } |
| 33 | llvm_unreachable("Unknown comment kind!"); |
| 34 | } |
| 35 | |
| 36 | namespace { |
| 37 | struct good {}; |
| 38 | struct bad {}; |
| 39 | |
| 40 | template <typename T> |
| 41 | good implements_child_begin_end(Comment::child_iterator (T::*)() const) { |
| 42 | return good(); |
| 43 | } |
| 44 | |
| 45 | static inline bad implements_child_begin_end( |
| 46 | Comment::child_iterator (Comment::*)() const) { |
| 47 | return bad(); |
| 48 | } |
| 49 | |
| 50 | #define ASSERT_IMPLEMENTS_child_begin(function) \ |
| 51 | (void) sizeof(good(implements_child_begin_end(function))) |
| 52 | |
| 53 | static inline void CheckCommentASTNodes() { |
| 54 | #define ABSTRACT_COMMENT(COMMENT) |
| 55 | #define COMMENT(CLASS, PARENT) \ |
| 56 | ASSERT_IMPLEMENTS_child_begin(&CLASS::child_begin); \ |
| 57 | ASSERT_IMPLEMENTS_child_begin(&CLASS::child_end); |
| 58 | #include "clang/AST/CommentNodes.inc" |
| 59 | #undef COMMENT |
| 60 | #undef ABSTRACT_COMMENT |
| 61 | } |
| 62 | |
| 63 | #undef ASSERT_IMPLEMENTS_child_begin |
| 64 | |
| 65 | } // end unnamed namespace |
| 66 | |
| 67 | Comment::child_iterator Comment::child_begin() const { |
| 68 | switch (getCommentKind()) { |
| 69 | case NoCommentKind: llvm_unreachable("comment without a kind"); |
| 70 | #define ABSTRACT_COMMENT(COMMENT) |
| 71 | #define COMMENT(CLASS, PARENT) \ |
| 72 | case CLASS##Kind: \ |
| 73 | return static_cast<const CLASS *>(this)->child_begin(); |
| 74 | #include "clang/AST/CommentNodes.inc" |
| 75 | #undef COMMENT |
| 76 | #undef ABSTRACT_COMMENT |
| 77 | } |
Matt Beaumont-Gay | 4d48b5c | 2012-07-06 21:13:09 +0000 | [diff] [blame] | 78 | llvm_unreachable("Unknown comment kind!"); |
Dmitri Gribenko | 8d3ba23 | 2012-07-06 00:28:32 +0000 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | Comment::child_iterator Comment::child_end() const { |
| 82 | switch (getCommentKind()) { |
| 83 | case NoCommentKind: llvm_unreachable("comment without a kind"); |
| 84 | #define ABSTRACT_COMMENT(COMMENT) |
| 85 | #define COMMENT(CLASS, PARENT) \ |
| 86 | case CLASS##Kind: \ |
| 87 | return static_cast<const CLASS *>(this)->child_end(); |
| 88 | #include "clang/AST/CommentNodes.inc" |
| 89 | #undef COMMENT |
| 90 | #undef ABSTRACT_COMMENT |
| 91 | } |
Matt Beaumont-Gay | 4d48b5c | 2012-07-06 21:13:09 +0000 | [diff] [blame] | 92 | llvm_unreachable("Unknown comment kind!"); |
Dmitri Gribenko | 8d3ba23 | 2012-07-06 00:28:32 +0000 | [diff] [blame] | 93 | } |
| 94 | |
Dmitri Gribenko | 0f7f10b | 2012-07-18 20:54:32 +0000 | [diff] [blame] | 95 | bool TextComment::isWhitespaceNoCache() const { |
Dmitri Gribenko | a5ef44f | 2012-07-11 21:38:39 +0000 | [diff] [blame] | 96 | for (StringRef::const_iterator I = Text.begin(), E = Text.end(); |
| 97 | I != E; ++I) { |
Dmitri Gribenko | 3520868 | 2013-08-23 17:45:43 +0000 | [diff] [blame^] | 98 | if (!clang::isWhitespace(*I)) |
Dmitri Gribenko | a5ef44f | 2012-07-11 21:38:39 +0000 | [diff] [blame] | 99 | return false; |
| 100 | } |
| 101 | return true; |
| 102 | } |
| 103 | |
Dmitri Gribenko | 0f7f10b | 2012-07-18 20:54:32 +0000 | [diff] [blame] | 104 | bool ParagraphComment::isWhitespaceNoCache() const { |
Dmitri Gribenko | a5ef44f | 2012-07-11 21:38:39 +0000 | [diff] [blame] | 105 | for (child_iterator I = child_begin(), E = child_end(); I != E; ++I) { |
| 106 | if (const TextComment *TC = dyn_cast<TextComment>(*I)) { |
| 107 | if (!TC->isWhitespace()) |
| 108 | return false; |
Dmitri Gribenko | 858e69f | 2012-07-19 00:01:56 +0000 | [diff] [blame] | 109 | } else |
| 110 | return false; |
Dmitri Gribenko | a5ef44f | 2012-07-11 21:38:39 +0000 | [diff] [blame] | 111 | } |
| 112 | return true; |
| 113 | } |
| 114 | |
| 115 | const char *ParamCommandComment::getDirectionAsString(PassDirection D) { |
| 116 | switch (D) { |
| 117 | case ParamCommandComment::In: |
| 118 | return "[in]"; |
| 119 | case ParamCommandComment::Out: |
| 120 | return "[out]"; |
| 121 | case ParamCommandComment::InOut: |
| 122 | return "[in,out]"; |
| 123 | } |
| 124 | llvm_unreachable("unknown PassDirection"); |
| 125 | } |
Dmitri Gribenko | 8d3ba23 | 2012-07-06 00:28:32 +0000 | [diff] [blame] | 126 | |
Dmitri Gribenko | 1ca7ecc | 2012-08-01 23:08:09 +0000 | [diff] [blame] | 127 | void DeclInfo::fill() { |
| 128 | assert(!IsFilled); |
| 129 | |
| 130 | // Set defaults. |
Dmitri Gribenko | 89ab7d0 | 2012-08-03 21:15:32 +0000 | [diff] [blame] | 131 | Kind = OtherKind; |
Dmitri Gribenko | 04bf29e | 2012-08-06 21:31:15 +0000 | [diff] [blame] | 132 | TemplateKind = NotTemplate; |
Dmitri Gribenko | 88815f3 | 2012-08-06 16:29:26 +0000 | [diff] [blame] | 133 | IsObjCMethod = false; |
Dmitri Gribenko | 1ca7ecc | 2012-08-01 23:08:09 +0000 | [diff] [blame] | 134 | IsInstanceMethod = false; |
| 135 | IsClassMethod = false; |
Dmitri Gribenko | 5543169 | 2013-05-05 00:41:58 +0000 | [diff] [blame] | 136 | ParamVars = None; |
Dmitri Gribenko | 1ca7ecc | 2012-08-01 23:08:09 +0000 | [diff] [blame] | 137 | TemplateParameters = NULL; |
| 138 | |
Fariborz Jahanian | bf967be | 2012-10-10 18:34:52 +0000 | [diff] [blame] | 139 | if (!CommentDecl) { |
Dmitri Gribenko | 5b32a08 | 2012-08-03 00:01:01 +0000 | [diff] [blame] | 140 | // If there is no declaration, the defaults is our only guess. |
| 141 | IsFilled = true; |
| 142 | return; |
| 143 | } |
Fariborz Jahanian | 1bfb00d | 2012-10-17 21:58:03 +0000 | [diff] [blame] | 144 | CurrentDecl = CommentDecl; |
Fariborz Jahanian | 88d285c | 2012-10-15 20:57:52 +0000 | [diff] [blame] | 145 | |
Fariborz Jahanian | bf967be | 2012-10-10 18:34:52 +0000 | [diff] [blame] | 146 | Decl::Kind K = CommentDecl->getKind(); |
Dmitri Gribenko | 5b32a08 | 2012-08-03 00:01:01 +0000 | [diff] [blame] | 147 | switch (K) { |
| 148 | default: |
| 149 | // Defaults are should be good for declarations we don't handle explicitly. |
| 150 | break; |
| 151 | case Decl::Function: |
| 152 | case Decl::CXXMethod: |
| 153 | case Decl::CXXConstructor: |
| 154 | case Decl::CXXDestructor: |
| 155 | case Decl::CXXConversion: { |
Fariborz Jahanian | bf967be | 2012-10-10 18:34:52 +0000 | [diff] [blame] | 156 | const FunctionDecl *FD = cast<FunctionDecl>(CommentDecl); |
Dmitri Gribenko | af19a6a | 2012-08-02 21:45:39 +0000 | [diff] [blame] | 157 | Kind = FunctionKind; |
Dmitri Gribenko | 1ca7ecc | 2012-08-01 23:08:09 +0000 | [diff] [blame] | 158 | ParamVars = ArrayRef<const ParmVarDecl *>(FD->param_begin(), |
| 159 | FD->getNumParams()); |
Dmitri Gribenko | 89ab7d0 | 2012-08-03 21:15:32 +0000 | [diff] [blame] | 160 | ResultType = FD->getResultType(); |
Dmitri Gribenko | 1ca7ecc | 2012-08-01 23:08:09 +0000 | [diff] [blame] | 161 | unsigned NumLists = FD->getNumTemplateParameterLists(); |
| 162 | if (NumLists != 0) { |
Dmitri Gribenko | 04bf29e | 2012-08-06 21:31:15 +0000 | [diff] [blame] | 163 | TemplateKind = TemplateSpecialization; |
Dmitri Gribenko | 1ca7ecc | 2012-08-01 23:08:09 +0000 | [diff] [blame] | 164 | TemplateParameters = |
| 165 | FD->getTemplateParameterList(NumLists - 1); |
| 166 | } |
| 167 | |
Dmitri Gribenko | 89ab7d0 | 2012-08-03 21:15:32 +0000 | [diff] [blame] | 168 | if (K == Decl::CXXMethod || K == Decl::CXXConstructor || |
| 169 | K == Decl::CXXDestructor || K == Decl::CXXConversion) { |
Fariborz Jahanian | bf967be | 2012-10-10 18:34:52 +0000 | [diff] [blame] | 170 | const CXXMethodDecl *MD = cast<CXXMethodDecl>(CommentDecl); |
Dmitri Gribenko | 1ca7ecc | 2012-08-01 23:08:09 +0000 | [diff] [blame] | 171 | IsInstanceMethod = MD->isInstance(); |
| 172 | IsClassMethod = !IsInstanceMethod; |
| 173 | } |
Dmitri Gribenko | 5b32a08 | 2012-08-03 00:01:01 +0000 | [diff] [blame] | 174 | break; |
| 175 | } |
| 176 | case Decl::ObjCMethod: { |
Fariborz Jahanian | bf967be | 2012-10-10 18:34:52 +0000 | [diff] [blame] | 177 | const ObjCMethodDecl *MD = cast<ObjCMethodDecl>(CommentDecl); |
Dmitri Gribenko | af19a6a | 2012-08-02 21:45:39 +0000 | [diff] [blame] | 178 | Kind = FunctionKind; |
Dmitri Gribenko | 1ca7ecc | 2012-08-01 23:08:09 +0000 | [diff] [blame] | 179 | ParamVars = ArrayRef<const ParmVarDecl *>(MD->param_begin(), |
| 180 | MD->param_size()); |
Dmitri Gribenko | 89ab7d0 | 2012-08-03 21:15:32 +0000 | [diff] [blame] | 181 | ResultType = MD->getResultType(); |
Dmitri Gribenko | 88815f3 | 2012-08-06 16:29:26 +0000 | [diff] [blame] | 182 | IsObjCMethod = true; |
Dmitri Gribenko | 1ca7ecc | 2012-08-01 23:08:09 +0000 | [diff] [blame] | 183 | IsInstanceMethod = MD->isInstanceMethod(); |
| 184 | IsClassMethod = !IsInstanceMethod; |
Dmitri Gribenko | 5b32a08 | 2012-08-03 00:01:01 +0000 | [diff] [blame] | 185 | break; |
| 186 | } |
| 187 | case Decl::FunctionTemplate: { |
Fariborz Jahanian | bf967be | 2012-10-10 18:34:52 +0000 | [diff] [blame] | 188 | const FunctionTemplateDecl *FTD = cast<FunctionTemplateDecl>(CommentDecl); |
Dmitri Gribenko | af19a6a | 2012-08-02 21:45:39 +0000 | [diff] [blame] | 189 | Kind = FunctionKind; |
Dmitri Gribenko | 04bf29e | 2012-08-06 21:31:15 +0000 | [diff] [blame] | 190 | TemplateKind = Template; |
Dmitri Gribenko | 1ca7ecc | 2012-08-01 23:08:09 +0000 | [diff] [blame] | 191 | const FunctionDecl *FD = FTD->getTemplatedDecl(); |
| 192 | ParamVars = ArrayRef<const ParmVarDecl *>(FD->param_begin(), |
| 193 | FD->getNumParams()); |
Dmitri Gribenko | 89ab7d0 | 2012-08-03 21:15:32 +0000 | [diff] [blame] | 194 | ResultType = FD->getResultType(); |
Dmitri Gribenko | 1ca7ecc | 2012-08-01 23:08:09 +0000 | [diff] [blame] | 195 | TemplateParameters = FTD->getTemplateParameters(); |
Dmitri Gribenko | 5b32a08 | 2012-08-03 00:01:01 +0000 | [diff] [blame] | 196 | break; |
| 197 | } |
| 198 | case Decl::ClassTemplate: { |
Fariborz Jahanian | bf967be | 2012-10-10 18:34:52 +0000 | [diff] [blame] | 199 | const ClassTemplateDecl *CTD = cast<ClassTemplateDecl>(CommentDecl); |
Dmitri Gribenko | af19a6a | 2012-08-02 21:45:39 +0000 | [diff] [blame] | 200 | Kind = ClassKind; |
Dmitri Gribenko | 04bf29e | 2012-08-06 21:31:15 +0000 | [diff] [blame] | 201 | TemplateKind = Template; |
Dmitri Gribenko | 1ca7ecc | 2012-08-01 23:08:09 +0000 | [diff] [blame] | 202 | TemplateParameters = CTD->getTemplateParameters(); |
Dmitri Gribenko | 5b32a08 | 2012-08-03 00:01:01 +0000 | [diff] [blame] | 203 | break; |
| 204 | } |
| 205 | case Decl::ClassTemplatePartialSpecialization: { |
| 206 | const ClassTemplatePartialSpecializationDecl *CTPSD = |
Fariborz Jahanian | bf967be | 2012-10-10 18:34:52 +0000 | [diff] [blame] | 207 | cast<ClassTemplatePartialSpecializationDecl>(CommentDecl); |
Dmitri Gribenko | af19a6a | 2012-08-02 21:45:39 +0000 | [diff] [blame] | 208 | Kind = ClassKind; |
Dmitri Gribenko | 04bf29e | 2012-08-06 21:31:15 +0000 | [diff] [blame] | 209 | TemplateKind = TemplatePartialSpecialization; |
Dmitri Gribenko | 1ca7ecc | 2012-08-01 23:08:09 +0000 | [diff] [blame] | 210 | TemplateParameters = CTPSD->getTemplateParameters(); |
Dmitri Gribenko | 5b32a08 | 2012-08-03 00:01:01 +0000 | [diff] [blame] | 211 | break; |
| 212 | } |
| 213 | case Decl::ClassTemplateSpecialization: |
Dmitri Gribenko | af19a6a | 2012-08-02 21:45:39 +0000 | [diff] [blame] | 214 | Kind = ClassKind; |
Dmitri Gribenko | 04bf29e | 2012-08-06 21:31:15 +0000 | [diff] [blame] | 215 | TemplateKind = TemplateSpecialization; |
Dmitri Gribenko | 5b32a08 | 2012-08-03 00:01:01 +0000 | [diff] [blame] | 216 | break; |
| 217 | case Decl::Record: |
Dmitri Gribenko | 89ab7d0 | 2012-08-03 21:15:32 +0000 | [diff] [blame] | 218 | case Decl::CXXRecord: |
Dmitri Gribenko | af19a6a | 2012-08-02 21:45:39 +0000 | [diff] [blame] | 219 | Kind = ClassKind; |
Dmitri Gribenko | 5b32a08 | 2012-08-03 00:01:01 +0000 | [diff] [blame] | 220 | break; |
| 221 | case Decl::Var: |
| 222 | case Decl::Field: |
Dmitri Gribenko | dd7b803 | 2012-08-07 18:12:22 +0000 | [diff] [blame] | 223 | case Decl::EnumConstant: |
Dmitri Gribenko | 5b32a08 | 2012-08-03 00:01:01 +0000 | [diff] [blame] | 224 | case Decl::ObjCIvar: |
| 225 | case Decl::ObjCAtDefsField: |
Dmitri Gribenko | af19a6a | 2012-08-02 21:45:39 +0000 | [diff] [blame] | 226 | Kind = VariableKind; |
Dmitri Gribenko | 5b32a08 | 2012-08-03 00:01:01 +0000 | [diff] [blame] | 227 | break; |
| 228 | case Decl::Namespace: |
Dmitri Gribenko | af19a6a | 2012-08-02 21:45:39 +0000 | [diff] [blame] | 229 | Kind = NamespaceKind; |
Dmitri Gribenko | 5b32a08 | 2012-08-03 00:01:01 +0000 | [diff] [blame] | 230 | break; |
Dmitri Gribenko | 70ff109 | 2012-08-24 00:05:30 +0000 | [diff] [blame] | 231 | case Decl::Typedef: { |
| 232 | Kind = TypedefKind; |
| 233 | // If this is a typedef to something we consider a function, extract |
| 234 | // arguments and return type. |
Fariborz Jahanian | bf967be | 2012-10-10 18:34:52 +0000 | [diff] [blame] | 235 | const TypedefDecl *TD = cast<TypedefDecl>(CommentDecl); |
Dmitri Gribenko | 70ff109 | 2012-08-24 00:05:30 +0000 | [diff] [blame] | 236 | const TypeSourceInfo *TSI = TD->getTypeSourceInfo(); |
| 237 | if (!TSI) |
| 238 | break; |
| 239 | TypeLoc TL = TSI->getTypeLoc().getUnqualifiedLoc(); |
| 240 | while (true) { |
| 241 | TL = TL.IgnoreParens(); |
Dmitri Gribenko | 70ff109 | 2012-08-24 00:05:30 +0000 | [diff] [blame] | 242 | // Look through qualified types. |
David Blaikie | 39e6ab4 | 2013-02-18 22:06:02 +0000 | [diff] [blame] | 243 | if (QualifiedTypeLoc QualifiedTL = TL.getAs<QualifiedTypeLoc>()) { |
| 244 | TL = QualifiedTL.getUnqualifiedLoc(); |
Dmitri Gribenko | 70ff109 | 2012-08-24 00:05:30 +0000 | [diff] [blame] | 245 | continue; |
| 246 | } |
| 247 | // Look through pointer types. |
David Blaikie | 39e6ab4 | 2013-02-18 22:06:02 +0000 | [diff] [blame] | 248 | if (PointerTypeLoc PointerTL = TL.getAs<PointerTypeLoc>()) { |
| 249 | TL = PointerTL.getPointeeLoc().getUnqualifiedLoc(); |
Dmitri Gribenko | 70ff109 | 2012-08-24 00:05:30 +0000 | [diff] [blame] | 250 | continue; |
| 251 | } |
David Blaikie | 39e6ab4 | 2013-02-18 22:06:02 +0000 | [diff] [blame] | 252 | if (BlockPointerTypeLoc BlockPointerTL = |
| 253 | TL.getAs<BlockPointerTypeLoc>()) { |
| 254 | TL = BlockPointerTL.getPointeeLoc().getUnqualifiedLoc(); |
Dmitri Gribenko | 70ff109 | 2012-08-24 00:05:30 +0000 | [diff] [blame] | 255 | continue; |
| 256 | } |
David Blaikie | 39e6ab4 | 2013-02-18 22:06:02 +0000 | [diff] [blame] | 257 | if (MemberPointerTypeLoc MemberPointerTL = |
| 258 | TL.getAs<MemberPointerTypeLoc>()) { |
| 259 | TL = MemberPointerTL.getPointeeLoc().getUnqualifiedLoc(); |
Dmitri Gribenko | 70ff109 | 2012-08-24 00:05:30 +0000 | [diff] [blame] | 260 | continue; |
| 261 | } |
| 262 | // Is this a typedef for a function type? |
David Blaikie | 39e6ab4 | 2013-02-18 22:06:02 +0000 | [diff] [blame] | 263 | if (FunctionTypeLoc FTL = TL.getAs<FunctionTypeLoc>()) { |
Dmitri Gribenko | 70ff109 | 2012-08-24 00:05:30 +0000 | [diff] [blame] | 264 | Kind = FunctionKind; |
David Blaikie | 39e6ab4 | 2013-02-18 22:06:02 +0000 | [diff] [blame] | 265 | ArrayRef<ParmVarDecl *> Params = FTL.getParams(); |
Dmitri Gribenko | 70ff109 | 2012-08-24 00:05:30 +0000 | [diff] [blame] | 266 | ParamVars = ArrayRef<const ParmVarDecl *>(Params.data(), |
| 267 | Params.size()); |
David Blaikie | 39e6ab4 | 2013-02-18 22:06:02 +0000 | [diff] [blame] | 268 | ResultType = FTL.getResultLoc().getType(); |
Dmitri Gribenko | 70ff109 | 2012-08-24 00:05:30 +0000 | [diff] [blame] | 269 | break; |
| 270 | } |
| 271 | break; |
| 272 | } |
| 273 | break; |
| 274 | } |
Dmitri Gribenko | 5b32a08 | 2012-08-03 00:01:01 +0000 | [diff] [blame] | 275 | case Decl::TypeAlias: |
Dmitri Gribenko | af19a6a | 2012-08-02 21:45:39 +0000 | [diff] [blame] | 276 | Kind = TypedefKind; |
Dmitri Gribenko | 5b32a08 | 2012-08-03 00:01:01 +0000 | [diff] [blame] | 277 | break; |
| 278 | case Decl::TypeAliasTemplate: { |
Fariborz Jahanian | bf967be | 2012-10-10 18:34:52 +0000 | [diff] [blame] | 279 | const TypeAliasTemplateDecl *TAT = cast<TypeAliasTemplateDecl>(CommentDecl); |
Dmitri Gribenko | af19a6a | 2012-08-02 21:45:39 +0000 | [diff] [blame] | 280 | Kind = TypedefKind; |
Dmitri Gribenko | 04bf29e | 2012-08-06 21:31:15 +0000 | [diff] [blame] | 281 | TemplateKind = Template; |
Dmitri Gribenko | 967e5d7 | 2012-08-02 21:36:57 +0000 | [diff] [blame] | 282 | TemplateParameters = TAT->getTemplateParameters(); |
Dmitri Gribenko | 5b32a08 | 2012-08-03 00:01:01 +0000 | [diff] [blame] | 283 | break; |
Dmitri Gribenko | 1ca7ecc | 2012-08-01 23:08:09 +0000 | [diff] [blame] | 284 | } |
Dmitri Gribenko | cff339a | 2012-08-07 18:59:04 +0000 | [diff] [blame] | 285 | case Decl::Enum: |
| 286 | Kind = EnumKind; |
| 287 | break; |
Dmitri Gribenko | 5b32a08 | 2012-08-03 00:01:01 +0000 | [diff] [blame] | 288 | } |
| 289 | |
Dmitri Gribenko | 1ca7ecc | 2012-08-01 23:08:09 +0000 | [diff] [blame] | 290 | IsFilled = true; |
| 291 | } |
| 292 | |
Dmitri Gribenko | 8cfabf2 | 2012-10-19 16:51:38 +0000 | [diff] [blame] | 293 | StringRef ParamCommandComment::getParamName(const FullComment *FC) const { |
Fariborz Jahanian | 262e60c | 2012-10-18 21:42:42 +0000 | [diff] [blame] | 294 | assert(isParamIndexValid()); |
Dmitri Gribenko | c5b0054 | 2013-06-24 04:41:32 +0000 | [diff] [blame] | 295 | if (isVarArgParam()) |
| 296 | return "..."; |
Fariborz Jahanian | eb9c55f | 2013-07-05 23:20:55 +0000 | [diff] [blame] | 297 | return FC->getDeclInfo()->ParamVars[getParamIndex()]->getName(); |
Fariborz Jahanian | 749ace6 | 2012-10-11 23:52:50 +0000 | [diff] [blame] | 298 | } |
| 299 | |
Dmitri Gribenko | 8cfabf2 | 2012-10-19 16:51:38 +0000 | [diff] [blame] | 300 | StringRef TParamCommandComment::getParamName(const FullComment *FC) const { |
Fariborz Jahanian | 262e60c | 2012-10-18 21:42:42 +0000 | [diff] [blame] | 301 | assert(isPositionValid()); |
Fariborz Jahanian | eb9c55f | 2013-07-05 23:20:55 +0000 | [diff] [blame] | 302 | const TemplateParameterList *TPL = FC->getDeclInfo()->TemplateParameters; |
Fariborz Jahanian | 262e60c | 2012-10-18 21:42:42 +0000 | [diff] [blame] | 303 | for (unsigned i = 0, e = getDepth(); i != e; ++i) { |
| 304 | if (i == e-1) |
| 305 | return TPL->getParam(getIndex(i))->getName(); |
| 306 | const NamedDecl *Param = TPL->getParam(getIndex(i)); |
| 307 | if (const TemplateTemplateParmDecl *TTP = |
Fariborz Jahanian | 6553c68 | 2012-10-15 18:58:50 +0000 | [diff] [blame] | 308 | dyn_cast<TemplateTemplateParmDecl>(Param)) |
Fariborz Jahanian | 262e60c | 2012-10-18 21:42:42 +0000 | [diff] [blame] | 309 | TPL = TTP->getTemplateParameters(); |
Fariborz Jahanian | 6553c68 | 2012-10-15 18:58:50 +0000 | [diff] [blame] | 310 | } |
Fariborz Jahanian | 262e60c | 2012-10-18 21:42:42 +0000 | [diff] [blame] | 311 | return ""; |
Fariborz Jahanian | 6553c68 | 2012-10-15 18:58:50 +0000 | [diff] [blame] | 312 | } |
Dmitri Gribenko | 8cfabf2 | 2012-10-19 16:51:38 +0000 | [diff] [blame] | 313 | |
Dmitri Gribenko | 8d3ba23 | 2012-07-06 00:28:32 +0000 | [diff] [blame] | 314 | } // end namespace comments |
| 315 | } // end namespace clang |
Dmitri Gribenko | af19a6a | 2012-08-02 21:45:39 +0000 | [diff] [blame] | 316 | |