clang: include/clang/AST/Comment.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef LLVM_CLANG_AST_COMMENT_H
14#define LLVM_CLANG_AST_COMMENT_H
15
20#include "llvm/ADT/ArrayRef.h"
21#include "llvm/ADT/StringRef.h"
22
25class ParmVarDecl;
26class TemplateParameterList;
27
28namespace comments {
29class FullComment;
32
33
34
35
36
37
39
40
41
42
44
45
46
47
48
51
54#define COMMENT(CLASS, PARENT) CLASS,
55#define COMMENT_RANGE(BASE, FIRST, LAST) \
56 First##BASE##Constant = FIRST, Last##BASE##Constant = LAST,
57#define LAST_COMMENT_RANGE(BASE, FIRST, LAST) \
58 First##BASE##Constant = FIRST, Last##BASE##Constant = LAST
59#define ABSTRACT_COMMENT(COMMENT)
60#include "clang/AST/CommentNodes.inc"
61};
62
63
64
66protected:
67
69
70
72
75
76
78 unsigned Kind : 8;
79 };
81
84
87
88
89
90 LLVM_PREFERRED_TYPE(bool)
91 unsigned HasTrailingNewline : 1;
92 };
94
97
100
101
102 LLVM_PREFERRED_TYPE(bool)
103 mutable unsigned IsWhitespaceValid : 1;
104
105
106 LLVM_PREFERRED_TYPE(bool)
107 mutable unsigned IsWhitespace : 1;
108 };
110
113
116
118 unsigned RenderKind : 3;
119
122 };
125
128
131
132
133 LLVM_PREFERRED_TYPE(bool)
134 unsigned IsMalformed : 1;
135 };
137
140
143
144
145
146 LLVM_PREFERRED_TYPE(bool)
147 unsigned IsSelfClosing : 1;
148 };
150
153
156
157
158 LLVM_PREFERRED_TYPE(bool)
159 mutable unsigned IsWhitespaceValid : 1;
160
161
162 LLVM_PREFERRED_TYPE(bool)
163 mutable unsigned IsWhitespace : 1;
164 };
166
169
172
175
176
177
179 unsigned CommandMarker : 1;
180 };
183
186
189
190
192 unsigned Direction : 2;
193
194
195 LLVM_PREFERRED_TYPE(bool)
196 unsigned IsDirectionExplicit : 1;
197 };
199
200 union {
210 };
211
214 }
215
218 }
219
220public:
224 };
225
230 CommentBits.Kind = llvm::to_underlying(K);
231 }
232
235 }
236
238
239 void dump() const;
241 void dump(raw_ostream &OS, const ASTContext &Context) const;
242
244
246
248
250
252
255
256
257
260 }
261};
262
263
264
266protected:
270 Comment(K, LocBegin, LocEnd) {
272 }
273
274public:
276 return C->getCommentKind() >=
277 CommentKind::FirstInlineContentCommentConstant &&
278 C->getCommentKind() <= CommentKind::LastInlineContentCommentConstant;
279 }
280
283 }
284
287 }
288};
289
290
292 StringRef Text;
293
294public:
299 }
300
302 return C->getCommentKind() == CommentKind::TextComment;
303 }
304
306
308
309 StringRef getText() const LLVM_READONLY { return Text; }
310
314
318 }
319
320private:
321 bool isWhitespaceNoCache() const;
322};
323
324
325
332};
333
334
336protected:
337
339
340public:
345 LocEnd),
349 }
350
352 return C->getCommentKind() == CommentKind::InlineCommandComment;
353 }
354
356
358
361 }
362
365 }
366
369 }
370
374 }
375
377 return Args.size();
378 }
379
381 return Args[Idx].Text;
382 }
383
385 return Args[Idx].Range;
386 }
387};
388
389
390
392protected:
395
407 }
408
409public:
411 return C->getCommentKind() >= CommentKind::FirstHTMLTagCommentConstant &&
412 C->getCommentKind() <= CommentKind::LastHTMLTagCommentConstant;
413 }
414
416
421 }
422
425 }
426
429 }
430};
431
432
434public:
436 public:
439
441
444
446
449
454
457 }
458
461 }
462 };
463
464private:
466
467public:
470 LocBegin.getLocWithOffset(1 + TagName.size()), TagName,
471 LocBegin.getLocWithOffset(1),
472 LocBegin.getLocWithOffset(1 + TagName.size())) {
474 }
475
477 return C->getCommentKind() == CommentKind::HTMLStartTagComment;
478 }
479
481
483
485 return Attributes.size();
486 }
487
489 return Attributes[Idx];
490 }
491
493 Attributes = Attrs;
494 if (!Attrs.empty()) {
499 else {
501 }
502 }
503 }
504
507 }
508
511 }
512
515 }
516};
517
518
520public:
524 TagName, LocBegin.getLocWithOffset(2),
525 LocBegin.getLocWithOffset(2 + TagName.size())) {}
526
528 return C->getCommentKind() == CommentKind::HTMLEndTagComment;
529 }
530
532
534};
535
536
537
539protected:
543 Comment(K, LocBegin, LocEnd)
544 { }
545
546public:
548 return C->getCommentKind() >=
549 CommentKind::FirstBlockContentCommentConstant &&
550 C->getCommentKind() <= CommentKind::LastBlockContentCommentConstant;
551 }
552};
553
554
557
558public:
562 Content(Content) {
563 if (Content.empty()) {
566 return;
567 }
568
570
572 Content.back()->getEndLoc()));
573 setLocation(Content.front()->getBeginLoc());
574 }
575
577 return C->getCommentKind() == CommentKind::ParagraphComment;
578 }
579
581 return reinterpret_cast<child_iterator>(Content.begin());
582 }
583
585 return reinterpret_cast<child_iterator>(Content.end());
586 }
587
591
595 }
596
597private:
598 bool isWhitespaceNoCache() const;
599};
600
601
602
603
605protected:
606
608
609
611
615 unsigned CommandID,
622 }
623
624public:
632 }
633
635 return C->getCommentKind() >=
636 CommentKind::FirstBlockCommandCommentConstant &&
637 C->getCommentKind() <= CommentKind::LastBlockCommandCommentConstant;
638 }
639
642 }
643
646 }
647
650 }
651
654 }
655
658 }
659
663 getBeginLoc().getLocWithOffset(1 + Name.size()));
664 }
665
667 return Args.size();
668 }
669
671 return Args[Idx].Text;
672 }
673
675 return Args[Idx].Range;
676 }
677
680 if (Args.size() > 0) {
684 }
685 }
686
689 }
690
693 }
694
700 }
701
705 }
706};
707
709
710
712private:
713
714 unsigned ParamIndex;
715
716public:
717 enum : unsigned {
721
725 CommandID, CommandMarker),
730 }
731
733 return C->getCommentKind() == CommentKind::ParamCommandComment;
734 }
735
737
741 }
742
745 }
746
750 }
751
754 }
755
757
759 return Args[0].Text;
760 }
761
763 return Args[0].Range;
764 }
765
768 }
769
772 }
773
777 }
778
782 return ParamIndex;
783 }
784
786 ParamIndex = Index;
789 }
790};
791
792
794private:
795
796
797
798
799
800
801
802
803
804
805
806
808
809public:
813 CommandID, CommandMarker) {}
814
816 return C->getCommentKind() == CommentKind::TParamCommandComment;
817 }
818
821 }
822
824
826 return Args[0].Text;
827 }
828
830 return Args[0].Range;
831 }
832
834 return !Position.empty();
835 }
836
839 return Position.size();
840 }
841
842 unsigned getIndex(unsigned Depth) const {
844 return Position[Depth];
845 }
846
848 Position = NewPosition;
850 }
851};
852
853
855 StringRef Text;
856
857public:
860 LocBegin.getLocWithOffset(Text.size())),
862
864 return C->getCommentKind() == CommentKind::VerbatimBlockLineComment;
865 }
866
868
870
871 StringRef getText() const LLVM_READONLY {
873 }
874};
875
876
877
878
880protected:
884
885public:
887 unsigned CommandID)
889 CommandID,
890 CMK_At)
891 {}
892
894 return C->getCommentKind() == CommentKind::VerbatimBlockComment;
895 }
896
899 }
900
903 }
904
908 }
909
912 }
913
916 }
917
919 return Lines.size();
920 }
921
922 StringRef getText(unsigned LineIdx) const {
923 return Lines[LineIdx]->getText();
924 }
925};
926
927
928
929
931protected:
934
935public:
938 StringRef Text)
940 CommandID,
941 CMK_At),
943
945 return C->getCommentKind() == CommentKind::VerbatimLineComment;
946 }
947
949
951
954 }
955
958 }
959};
960
961
963
964
966
967
968
969
970
971
972
973
974
976
977
978
980
981
982
984
985
986
987
989
990
991
993
995
996
997
998
999
1000
1001
1002
1003
1005
1006
1007
1008
1009
1011
1012
1013
1014
1015
1017
1018
1020
1021
1022
1024
1025
1028
1029
1036
1037
1038 LLVM_PREFERRED_TYPE(bool)
1040
1041
1042 LLVM_PREFERRED_TYPE(DeclKind)
1044
1045
1048
1049
1050 LLVM_PREFERRED_TYPE(bool)
1052
1053
1054
1055
1056 LLVM_PREFERRED_TYPE(bool)
1058
1059
1060
1061
1062 LLVM_PREFERRED_TYPE(bool)
1064
1065
1066 LLVM_PREFERRED_TYPE(bool)
1068
1069 void fill();
1070
1073 }
1074
1077 }
1078
1080};
1081
1082
1086
1087public:
1090 Blocks(Blocks), ThisDeclInfo(D) {
1091 if (Blocks.empty())
1092 return;
1093
1095 SourceRange(Blocks.front()->getBeginLoc(), Blocks.back()->getEndLoc()));
1096 setLocation(Blocks.front()->getBeginLoc());
1097 }
1098
1100 return C->getCommentKind() == CommentKind::FullComment;
1101 }
1102
1104 return reinterpret_cast<child_iterator>(Blocks.begin());
1105 }
1106
1108 return reinterpret_cast<child_iterator>(Blocks.end());
1109 }
1110
1113 }
1114
1116 if (!ThisDeclInfo->IsFilled)
1117 ThisDeclInfo->fill();
1118 return ThisDeclInfo;
1119 }
1120
1122
1123};
1124}
1125}
1126
1127#endif
1128
enum clang::sema::@1725::IndirectLocalPathEntry::EntryKind Kind
Defines the clang::SourceLocation class and associated facilities.
C Language Family Type Representation.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Attr - This represents one attribute.
Decl - This represents one declaration (or definition), e.g.
A (possibly-)qualified type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
void setEnd(SourceLocation e)
Stores a list of template parameters for a TemplateDecl and its derived classes.
Block content (contains inline content).
BlockContentComment(CommentKind K, SourceLocation LocBegin, SourceLocation LocEnd)
static bool classof(const Comment *C)
Inline content (contained within a block).
InlineContentComment(CommentKind K, SourceLocation LocBegin, SourceLocation LocEnd)
bool hasTrailingNewline() const
static bool classof(const Comment *C)
void addTrailingNewline()
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
The JSON file list parser is used to communicate input to InstallAPI.