clang: lib/AST/Comment.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

15#include "llvm/Support/ErrorHandling.h"

16#include <type_traits>

17

20

21

22

23#define ABSTRACT_COMMENT(COMMENT)

24#define COMMENT(CLASS, PARENT) \

25 static_assert(std::is_trivially_destructible::value, \

26 #CLASS " should be trivially destructible!");

27#include "clang/AST/CommentNodes.inc"

28#undef COMMENT

29#undef ABSTRACT_COMMENT

30

31

32static_assert(std::is_trivially_destructible_v,

33 "DeclInfo should be trivially destructible!");

34

38 return "None";

39#define ABSTRACT_COMMENT(COMMENT)

40#define COMMENT(CLASS, PARENT) \

41 case CommentKind::CLASS: \

42 return #CLASS;

43#include "clang/AST/CommentNodes.inc"

44#undef COMMENT

45#undef ABSTRACT_COMMENT

46 }

47 llvm_unreachable("Unknown comment kind!");

48}

49

50namespace {

51struct good {};

52struct bad {};

53

54template

56 return good();

57}

58

59[[maybe_unused]]

60static inline bad

62 return bad();

63}

64

65#define ASSERT_IMPLEMENTS_child_begin(function) \

66 (void) good(implements_child_begin_end(function))

67

68[[maybe_unused]]

69static inline void CheckCommentASTNodes() {

70#define ABSTRACT_COMMENT(COMMENT)

71#define COMMENT(CLASS, PARENT) \

72 ASSERT_IMPLEMENTS_child_begin(&CLASS::child_begin); \

73 ASSERT_IMPLEMENTS_child_begin(&CLASS::child_end);

74#include "clang/AST/CommentNodes.inc"

75#undef COMMENT

76#undef ABSTRACT_COMMENT

77}

78

79#undef ASSERT_IMPLEMENTS_child_begin

80

81}

82

86 llvm_unreachable("comment without a kind");

87#define ABSTRACT_COMMENT(COMMENT)

88#define COMMENT(CLASS, PARENT) \

89 case CommentKind::CLASS: \

90 return static_cast<const CLASS *>(this)->child_begin();

91#include "clang/AST/CommentNodes.inc"

92#undef COMMENT

93#undef ABSTRACT_COMMENT

94 }

95 llvm_unreachable("Unknown comment kind!");

96}

97

101 llvm_unreachable("comment without a kind");

102#define ABSTRACT_COMMENT(COMMENT)

103#define COMMENT(CLASS, PARENT) \

104 case CommentKind::CLASS: \

105 return static_cast<const CLASS *>(this)->child_end();

106#include "clang/AST/CommentNodes.inc"

107#undef COMMENT

108#undef ABSTRACT_COMMENT

109 }

110 llvm_unreachable("Unknown comment kind!");

111}

112

113bool TextComment::isWhitespaceNoCache() const {

115}

116

117bool ParagraphComment::isWhitespaceNoCache() const {

119 if (const TextComment *TC = dyn_cast(*I)) {

120 if (!TC->isWhitespace())

121 return false;

122 } else

123 return false;

124 }

125 return true;

126}

127

130

131

133 return AttributeTL.getModifiedLoc();

134

137

140

143

145 return ATL.getOriginalLoc();

150

151 return TL;

152}

153

156 while (PrevTL != TL) {

157 PrevTL = TL;

159 }

160

162 ResFTL = FTL;

163 return true;

164 }

165

168

169

170

171

172 if (STL.getNumArgs() != 1)

173 return false;

176 return false;

180 ResFTL = FTL;

181 return true;

182 }

183 }

184

185 return false;

186}

187

188const char *

190 switch (D) {

192 return "[in]";

194 return "[out]";

196 return "[in,out]";

197 }

198 llvm_unreachable("unknown PassDirection");

199}

200

203

204

213

215

217 return;

218 }

220

223 switch (K) {

224 default:

225

226 break;

227 case Decl::Function:

228 case Decl::CXXMethod:

229 case Decl::CXXConstructor:

230 case Decl::CXXDestructor:

231 case Decl::CXXConversion: {

237 if (NumLists != 0) {

241 }

242

243 if (K == Decl::CXXMethod || K == Decl::CXXConstructor ||

244 K == Decl::CXXDestructor || K == Decl::CXXConversion) {

248 }

251 break;

252 }

253 case Decl::ObjCMethod: {

263 break;

264 }

265 case Decl::FunctionTemplate: {

275 break;

276 }

277 case Decl::ClassTemplate: {

282 break;

283 }

284 case Decl::ClassTemplatePartialSpecialization: {

290 break;

291 }

292 case Decl::VarTemplatePartialSpecialization: {

297 break;

298 }

299 case Decl::ClassTemplateSpecialization:

302 break;

303 case Decl::Record:

304 case Decl::CXXRecord:

306 break;

307 case Decl::Var:

312 }

313 [[fallthrough]];

314 case Decl::Field:

315 case Decl::EnumConstant:

316 case Decl::ObjCIvar:

317 case Decl::ObjCAtDefsField:

318 case Decl::ObjCProperty:

319 if (const auto *VD = dyn_cast(CommentDecl))

320 TSI = VD->getTypeSourceInfo();

321 else if (const auto *PD = dyn_cast(CommentDecl))

322 TSI = PD->getTypeSourceInfo();

324 break;

325 case Decl::VarTemplate: {

331 TSI = VD->getTypeSourceInfo();

332 break;

333 }

334 case Decl::Namespace:

336 break;

337 case Decl::TypeAlias:

338 case Decl::Typedef:

341 break;

342 case Decl::TypeAliasTemplate: {

348 TSI = TAD->getTypeSourceInfo();

349 break;

350 }

351 case Decl::Enum:

353 break;

354 }

355

356

357

358 if (TSI) {

364 if (const auto *FPT = dyn_cast(FTL.getTypePtr()))

367 }

368 }

369

371}

372

379

383 for (unsigned i = 0, e = getDepth(); i != e; ++i) {

384 assert(TPL && "Unknown TemplateParameterList");

385 if (i == e - 1)

388 if (auto *TTP = dyn_cast(Param))

389 TPL = TTP->getTemplateParameters();

390 }

391 return "";

392}

393

394}

395}

396

Defines the clang::ASTContext interface.

Defines the C++ template declaration subclasses.

Type source information for an attributed type.

Wrapper for source info for block pointers.

Represents a static or instance method of a struct/union/class.

Declaration of a class template.

TemplateParameterList * getTemplateParameters() const

Get the list of template parameters.

const TypeClass * getTypePtr() const

Kind

Lists the kind of concrete classes of Decl.

TemplateParameterList * getTemplateParameterList(unsigned index) const

unsigned getNumTemplateParameterLists() const

Represents a function declaration or definition.

QualType getReturnType() const

ArrayRef< ParmVarDecl * > parameters() const

bool isVariadic() const

Whether this function is variadic.

Declaration of a template function.

FunctionDecl * getTemplatedDecl() const

Get the underlying function declaration of the template.

Wrapper for source info for functions.

ArrayRef< ParmVarDecl * > getParams() const

TypeLoc getReturnLoc() const

Wrapper for source info for member pointers.

This represents a decl that may have a name.

StringRef getName() const

Get the name of identifier for this declaration as a StringRef.

ObjCMethodDecl - Represents an instance or class method declaration.

ArrayRef< ParmVarDecl * > parameters() const

bool isInstanceMethod() const

QualType getReturnType() const

Wrapper for source info for pointers.

Wrapper of type source information for a type with non-trivial direct qualifiers.

Location wrapper for a TemplateArgument.

const TemplateArgument & getArgument() const

TypeSourceInfo * getTypeSourceInfo() const

@ Type

The template argument is a type.

ArgKind getKind() const

Return the kind of stored template argument.

TemplateParameterList * getTemplateParameters() const

Get the list of template parameters.

Stores a list of template parameters for a TemplateDecl and its derived classes.

NamedDecl * getParam(unsigned Idx)

Represents the declaration of a typedef-name via a C++11 alias-declaration.

Declaration of an alias template.

TypeAliasDecl * getTemplatedDecl() const

Get the underlying function declaration of the template.

Base wrapper for a particular "section" of type source info.

UnqualTypeLoc getUnqualifiedLoc() const

Skips past any qualifiers, if this is qualified.

QualType getType() const

Get the type for which this source info wrapper provides information.

T getAs() const

Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...

TypeLoc IgnoreParens() const

A container of type source information.

TypeLoc getTypeLoc() const

Return the TypeLoc wrapper for the type source info.

Represents a variable declaration or definition.

Declaration of a variable template.

VarDecl * getTemplatedDecl() const

Get the underlying variable declarations of the template.

The JSON file list parser is used to communicate input to InstallAPI.

LLVM_READONLY bool isWhitespace(unsigned char c)

Return true if this character is horizontal or vertical ASCII whitespace: ' ', '\t',...

U cast(CodeGen::Address addr)