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