| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | #ifndef LLVM_CLANG_AST_DECLOBJC_H |
| 14 | #define LLVM_CLANG_AST_DECLOBJC_H |
| 15 | |
| 16 | #include "clang/AST/Decl.h" |
| 17 | #include "clang/AST/DeclBase.h" |
| 18 | #include "clang/AST/ExternalASTSource.h" |
| 19 | #include "clang/AST/Redeclarable.h" |
| 20 | #include "clang/AST/SelectorLocationsKind.h" |
| 21 | #include "clang/AST/Type.h" |
| 22 | #include "clang/Basic/IdentifierTable.h" |
| 23 | #include "clang/Basic/LLVM.h" |
| 24 | #include "clang/Basic/SourceLocation.h" |
| 25 | #include "clang/Basic/Specifiers.h" |
| 26 | #include "llvm/ADT/ArrayRef.h" |
| 27 | #include "llvm/ADT/DenseMap.h" |
| 28 | #include "llvm/ADT/DenseSet.h" |
| 29 | #include "llvm/ADT/None.h" |
| 30 | #include "llvm/ADT/PointerIntPair.h" |
| 31 | #include "llvm/ADT/STLExtras.h" |
| 32 | #include "llvm/ADT/StringRef.h" |
| 33 | #include "llvm/ADT/iterator_range.h" |
| 34 | #include "llvm/Support/Compiler.h" |
| 35 | #include "llvm/Support/TrailingObjects.h" |
| 36 | #include <cassert> |
| 37 | #include <cstddef> |
| 38 | #include <cstdint> |
| 39 | #include <iterator> |
| 40 | #include <string> |
| 41 | #include <utility> |
| 42 | |
| 43 | namespace clang { |
| 44 | |
| 45 | class ASTContext; |
| 46 | class CompoundStmt; |
| 47 | class CXXCtorInitializer; |
| 48 | class Expr; |
| 49 | class ObjCCategoryDecl; |
| 50 | class ObjCCategoryImplDecl; |
| 51 | class ObjCImplementationDecl; |
| 52 | class ObjCInterfaceDecl; |
| 53 | class ObjCIvarDecl; |
| 54 | class ObjCPropertyDecl; |
| 55 | class ObjCPropertyImplDecl; |
| 56 | class ObjCProtocolDecl; |
| 57 | class Stmt; |
| 58 | |
| 59 | class ObjCListBase { |
| 60 | protected: |
| 61 | |
| 62 | void **List = nullptr; |
| 63 | unsigned NumElts = 0; |
| 64 | |
| 65 | public: |
| 66 | ObjCListBase() = default; |
| 67 | ObjCListBase(const ObjCListBase &) = delete; |
| 68 | ObjCListBase &operator=(const ObjCListBase &) = delete; |
| 69 | |
| 70 | unsigned size() const { return NumElts; } |
| 71 | bool empty() const { return NumElts == 0; } |
| 72 | |
| 73 | protected: |
| 74 | void set(void *const* InList, unsigned Elts, ASTContext &Ctx); |
| 75 | }; |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | template <typename T> |
| 82 | class ObjCList : public ObjCListBase { |
| 83 | public: |
| 84 | void set(T* const* InList, unsigned Elts, ASTContext &Ctx) { |
| 85 | ObjCListBase::set(reinterpret_cast<void*const*>(InList), Elts, Ctx); |
| 86 | } |
| 87 | |
| 88 | using iterator = T* const *; |
| 89 | |
| 90 | iterator begin() const { return (iterator)List; } |
| 91 | iterator end() const { return (iterator)List+NumElts; } |
| 92 | |
| 93 | T* operator[](unsigned Idx) const { |
| 94 | (0) . __assert_fail ("Idx < NumElts && \"Invalid access\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/DeclObjC.h", 94, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(Idx < NumElts && "Invalid access"); |
| 95 | return (T*)List[Idx]; |
| 96 | } |
| 97 | }; |
| 98 | |
| 99 | |
| 100 | |
| 101 | class ObjCProtocolList : public ObjCList<ObjCProtocolDecl> { |
| 102 | SourceLocation *Locations = nullptr; |
| 103 | |
| 104 | using ObjCList<ObjCProtocolDecl>::set; |
| 105 | |
| 106 | public: |
| 107 | ObjCProtocolList() = default; |
| 108 | |
| 109 | using loc_iterator = const SourceLocation *; |
| 110 | |
| 111 | loc_iterator loc_begin() const { return Locations; } |
| 112 | loc_iterator loc_end() const { return Locations + size(); } |
| 113 | |
| 114 | void set(ObjCProtocolDecl* const* InList, unsigned Elts, |
| 115 | const SourceLocation *Locs, ASTContext &Ctx); |
| 116 | }; |
| 117 | |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 126 | |
| 127 | |
| 128 | |
| 129 | |
| 130 | |
| 131 | |
| 132 | |
| 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 | class ObjCMethodDecl : public NamedDecl, public DeclContext { |
| 139 | |
| 140 | |
| 141 | |
| 142 | public: |
| 143 | enum ImplementationControl { None, Required, Optional }; |
| 144 | |
| 145 | private: |
| 146 | |
| 147 | QualType MethodDeclType; |
| 148 | |
| 149 | |
| 150 | TypeSourceInfo *ReturnTInfo; |
| 151 | |
| 152 | |
| 153 | |
| 154 | void *ParamsAndSelLocs = nullptr; |
| 155 | unsigned NumParams = 0; |
| 156 | |
| 157 | |
| 158 | SourceLocation DeclEndLoc; |
| 159 | |
| 160 | |
| 161 | LazyDeclStmtPtr Body; |
| 162 | |
| 163 | |
| 164 | |
| 165 | ImplicitParamDecl *SelfDecl = nullptr; |
| 166 | |
| 167 | |
| 168 | |
| 169 | ImplicitParamDecl *CmdDecl = nullptr; |
| 170 | |
| 171 | ObjCMethodDecl(SourceLocation beginLoc, SourceLocation endLoc, |
| 172 | Selector SelInfo, QualType T, TypeSourceInfo *ReturnTInfo, |
| 173 | DeclContext *contextDecl, bool isInstance = true, |
| 174 | bool isVariadic = false, bool isPropertyAccessor = false, |
| 175 | bool isImplicitlyDeclared = false, bool isDefined = false, |
| 176 | ImplementationControl impControl = None, |
| 177 | bool HasRelatedResultType = false); |
| 178 | |
| 179 | SelectorLocationsKind getSelLocsKind() const { |
| 180 | return static_cast<SelectorLocationsKind>(ObjCMethodDeclBits.SelLocsKind); |
| 181 | } |
| 182 | |
| 183 | void setSelLocsKind(SelectorLocationsKind Kind) { |
| 184 | ObjCMethodDeclBits.SelLocsKind = Kind; |
| 185 | } |
| 186 | |
| 187 | bool hasStandardSelLocs() const { |
| 188 | return getSelLocsKind() != SelLoc_NonStandard; |
| 189 | } |
| 190 | |
| 191 | |
| 192 | |
| 193 | SourceLocation *getStoredSelLocs() { |
| 194 | return reinterpret_cast<SourceLocation *>(getParams() + NumParams); |
| 195 | } |
| 196 | const SourceLocation *getStoredSelLocs() const { |
| 197 | return reinterpret_cast<const SourceLocation *>(getParams() + NumParams); |
| 198 | } |
| 199 | |
| 200 | |
| 201 | |
| 202 | ParmVarDecl **getParams() { |
| 203 | return reinterpret_cast<ParmVarDecl **>(ParamsAndSelLocs); |
| 204 | } |
| 205 | const ParmVarDecl *const *getParams() const { |
| 206 | return reinterpret_cast<const ParmVarDecl *const *>(ParamsAndSelLocs); |
| 207 | } |
| 208 | |
| 209 | |
| 210 | |
| 211 | unsigned getNumStoredSelLocs() const { |
| 212 | if (hasStandardSelLocs()) |
| 213 | return 0; |
| 214 | return getNumSelectorLocs(); |
| 215 | } |
| 216 | |
| 217 | void setParamsAndSelLocs(ASTContext &C, |
| 218 | ArrayRef<ParmVarDecl*> Params, |
| 219 | ArrayRef<SourceLocation> SelLocs); |
| 220 | |
| 221 | |
| 222 | |
| 223 | |
| 224 | ObjCMethodDecl *getNextRedeclarationImpl() override; |
| 225 | |
| 226 | public: |
| 227 | friend class ASTDeclReader; |
| 228 | friend class ASTDeclWriter; |
| 229 | |
| 230 | static ObjCMethodDecl * |
| 231 | Create(ASTContext &C, SourceLocation beginLoc, SourceLocation endLoc, |
| 232 | Selector SelInfo, QualType T, TypeSourceInfo *ReturnTInfo, |
| 233 | DeclContext *contextDecl, bool isInstance = true, |
| 234 | bool isVariadic = false, bool isPropertyAccessor = false, |
| 235 | bool isImplicitlyDeclared = false, bool isDefined = false, |
| 236 | ImplementationControl impControl = None, |
| 237 | bool HasRelatedResultType = false); |
| 238 | |
| 239 | static ObjCMethodDecl *CreateDeserialized(ASTContext &C, unsigned ID); |
| 240 | |
| 241 | ObjCMethodDecl *getCanonicalDecl() override; |
| 242 | const ObjCMethodDecl *getCanonicalDecl() const { |
| 243 | return const_cast<ObjCMethodDecl*>(this)->getCanonicalDecl(); |
| 244 | } |
| 245 | |
| 246 | ObjCDeclQualifier getObjCDeclQualifier() const { |
| 247 | return static_cast<ObjCDeclQualifier>(ObjCMethodDeclBits.objcDeclQualifier); |
| 248 | } |
| 249 | |
| 250 | void setObjCDeclQualifier(ObjCDeclQualifier QV) { |
| 251 | ObjCMethodDeclBits.objcDeclQualifier = QV; |
| 252 | } |
| 253 | |
| 254 | |
| 255 | |
| 256 | bool hasRelatedResultType() const { |
| 257 | return ObjCMethodDeclBits.RelatedResultType; |
| 258 | } |
| 259 | |
| 260 | |
| 261 | void setRelatedResultType(bool RRT = true) { |
| 262 | ObjCMethodDeclBits.RelatedResultType = RRT; |
| 263 | } |
| 264 | |
| 265 | |
| 266 | bool isRedeclaration() const { return ObjCMethodDeclBits.IsRedeclaration; } |
| 267 | void setIsRedeclaration(bool RD) { ObjCMethodDeclBits.IsRedeclaration = RD; } |
| 268 | void setAsRedeclaration(const ObjCMethodDecl *PrevMethod); |
| 269 | |
| 270 | |
| 271 | bool hasRedeclaration() const { return ObjCMethodDeclBits.HasRedeclaration; } |
| 272 | void setHasRedeclaration(bool HRD) const { |
| 273 | ObjCMethodDeclBits.HasRedeclaration = HRD; |
| 274 | } |
| 275 | |
| 276 | |
| 277 | |
| 278 | |
| 279 | SourceLocation getDeclaratorEndLoc() const { return DeclEndLoc; } |
| 280 | |
| 281 | |
| 282 | SourceLocation getBeginLoc() const LLVM_READONLY { return getLocation(); } |
| 283 | SourceLocation getEndLoc() const LLVM_READONLY; |
| 284 | SourceRange getSourceRange() const override LLVM_READONLY { |
| 285 | return SourceRange(getLocation(), getEndLoc()); |
| 286 | } |
| 287 | |
| 288 | SourceLocation getSelectorStartLoc() const { |
| 289 | if (isImplicit()) |
| 290 | return getBeginLoc(); |
| 291 | return getSelectorLoc(0); |
| 292 | } |
| 293 | |
| 294 | SourceLocation getSelectorLoc(unsigned Index) const { |
| 295 | (0) . __assert_fail ("Index < getNumSelectorLocs() && \"Index out of range!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/DeclObjC.h", 295, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(Index < getNumSelectorLocs() && "Index out of range!"); |
| 296 | if (hasStandardSelLocs()) |
| 297 | return getStandardSelectorLoc(Index, getSelector(), |
| 298 | getSelLocsKind() == SelLoc_StandardWithSpace, |
| 299 | parameters(), |
| 300 | DeclEndLoc); |
| 301 | return getStoredSelLocs()[Index]; |
| 302 | } |
| 303 | |
| 304 | void getSelectorLocs(SmallVectorImpl<SourceLocation> &SelLocs) const; |
| 305 | |
| 306 | unsigned getNumSelectorLocs() const { |
| 307 | if (isImplicit()) |
| 308 | return 0; |
| 309 | Selector Sel = getSelector(); |
| 310 | if (Sel.isUnarySelector()) |
| 311 | return 1; |
| 312 | return Sel.getNumArgs(); |
| 313 | } |
| 314 | |
| 315 | ObjCInterfaceDecl *getClassInterface(); |
| 316 | const ObjCInterfaceDecl *getClassInterface() const { |
| 317 | return const_cast<ObjCMethodDecl*>(this)->getClassInterface(); |
| 318 | } |
| 319 | |
| 320 | Selector getSelector() const { return getDeclName().getObjCSelector(); } |
| 321 | |
| 322 | QualType getReturnType() const { return MethodDeclType; } |
| 323 | void setReturnType(QualType T) { MethodDeclType = T; } |
| 324 | SourceRange getReturnTypeSourceRange() const; |
| 325 | |
| 326 | |
| 327 | |
| 328 | |
| 329 | |
| 330 | QualType getSendResultType() const; |
| 331 | |
| 332 | |
| 333 | |
| 334 | QualType getSendResultType(QualType receiverType) const; |
| 335 | |
| 336 | TypeSourceInfo *getReturnTypeSourceInfo() const { return ReturnTInfo; } |
| 337 | void setReturnTypeSourceInfo(TypeSourceInfo *TInfo) { ReturnTInfo = TInfo; } |
| 338 | |
| 339 | |
| 340 | unsigned param_size() const { return NumParams; } |
| 341 | |
| 342 | using param_const_iterator = const ParmVarDecl *const *; |
| 343 | using param_iterator = ParmVarDecl *const *; |
| 344 | using param_range = llvm::iterator_range<param_iterator>; |
| 345 | using param_const_range = llvm::iterator_range<param_const_iterator>; |
| 346 | |
| 347 | param_const_iterator param_begin() const { |
| 348 | return param_const_iterator(getParams()); |
| 349 | } |
| 350 | |
| 351 | param_const_iterator param_end() const { |
| 352 | return param_const_iterator(getParams() + NumParams); |
| 353 | } |
| 354 | |
| 355 | param_iterator param_begin() { return param_iterator(getParams()); } |
| 356 | param_iterator param_end() { return param_iterator(getParams() + NumParams); } |
| 357 | |
| 358 | |
| 359 | |
| 360 | param_const_iterator sel_param_end() const { |
| 361 | return param_begin() + getSelector().getNumArgs(); |
| 362 | } |
| 363 | |
| 364 | |
| 365 | |
| 366 | ArrayRef<ParmVarDecl*> parameters() const { |
| 367 | return llvm::makeArrayRef(const_cast<ParmVarDecl**>(getParams()), |
| 368 | NumParams); |
| 369 | } |
| 370 | |
| 371 | ParmVarDecl *getParamDecl(unsigned Idx) { |
| 372 | (0) . __assert_fail ("Idx < NumParams && \"Index out of bounds!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/DeclObjC.h", 372, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(Idx < NumParams && "Index out of bounds!"); |
| 373 | return getParams()[Idx]; |
| 374 | } |
| 375 | const ParmVarDecl *getParamDecl(unsigned Idx) const { |
| 376 | return const_cast<ObjCMethodDecl *>(this)->getParamDecl(Idx); |
| 377 | } |
| 378 | |
| 379 | |
| 380 | |
| 381 | |
| 382 | void setMethodParams(ASTContext &C, |
| 383 | ArrayRef<ParmVarDecl*> Params, |
| 384 | ArrayRef<SourceLocation> SelLocs = llvm::None); |
| 385 | |
| 386 | |
| 387 | struct GetTypeFn { |
| 388 | QualType operator()(const ParmVarDecl *PD) const { return PD->getType(); } |
| 389 | }; |
| 390 | |
| 391 | using param_type_iterator = |
| 392 | llvm::mapped_iterator<param_const_iterator, GetTypeFn>; |
| 393 | |
| 394 | param_type_iterator param_type_begin() const { |
| 395 | return llvm::map_iterator(param_begin(), GetTypeFn()); |
| 396 | } |
| 397 | |
| 398 | param_type_iterator param_type_end() const { |
| 399 | return llvm::map_iterator(param_end(), GetTypeFn()); |
| 400 | } |
| 401 | |
| 402 | |
| 403 | |
| 404 | |
| 405 | |
| 406 | void createImplicitParams(ASTContext &Context, const ObjCInterfaceDecl *ID); |
| 407 | |
| 408 | |
| 409 | |
| 410 | QualType getSelfType(ASTContext &Context, const ObjCInterfaceDecl *OID, |
| 411 | bool &selfIsPseudoStrong, bool &selfIsConsumed); |
| 412 | |
| 413 | ImplicitParamDecl * getSelfDecl() const { return SelfDecl; } |
| 414 | void setSelfDecl(ImplicitParamDecl *SD) { SelfDecl = SD; } |
| 415 | ImplicitParamDecl * getCmdDecl() const { return CmdDecl; } |
| 416 | void setCmdDecl(ImplicitParamDecl *CD) { CmdDecl = CD; } |
| 417 | |
| 418 | |
| 419 | ObjCMethodFamily getMethodFamily() const; |
| 420 | |
| 421 | bool isInstanceMethod() const { return ObjCMethodDeclBits.IsInstance; } |
| 422 | void setInstanceMethod(bool isInst) { |
| 423 | ObjCMethodDeclBits.IsInstance = isInst; |
| 424 | } |
| 425 | |
| 426 | bool isVariadic() const { return ObjCMethodDeclBits.IsVariadic; } |
| 427 | void setVariadic(bool isVar) { ObjCMethodDeclBits.IsVariadic = isVar; } |
| 428 | |
| 429 | bool isClassMethod() const { return !isInstanceMethod(); } |
| 430 | |
| 431 | bool isPropertyAccessor() const { |
| 432 | return ObjCMethodDeclBits.IsPropertyAccessor; |
| 433 | } |
| 434 | |
| 435 | void setPropertyAccessor(bool isAccessor) { |
| 436 | ObjCMethodDeclBits.IsPropertyAccessor = isAccessor; |
| 437 | } |
| 438 | |
| 439 | bool isDefined() const { return ObjCMethodDeclBits.IsDefined; } |
| 440 | void setDefined(bool isDefined) { ObjCMethodDeclBits.IsDefined = isDefined; } |
| 441 | |
| 442 | |
| 443 | |
| 444 | |
| 445 | |
| 446 | |
| 447 | |
| 448 | |
| 449 | bool isOverriding() const { return ObjCMethodDeclBits.IsOverriding; } |
| 450 | void setOverriding(bool IsOver) { ObjCMethodDeclBits.IsOverriding = IsOver; } |
| 451 | |
| 452 | |
| 453 | |
| 454 | |
| 455 | |
| 456 | |
| 457 | |
| 458 | |
| 459 | |
| 460 | void getOverriddenMethods( |
| 461 | SmallVectorImpl<const ObjCMethodDecl *> &Overridden) const; |
| 462 | |
| 463 | |
| 464 | bool hasSkippedBody() const { return ObjCMethodDeclBits.HasSkippedBody; } |
| 465 | void setHasSkippedBody(bool Skipped = true) { |
| 466 | ObjCMethodDeclBits.HasSkippedBody = Skipped; |
| 467 | } |
| 468 | |
| 469 | |
| 470 | |
| 471 | |
| 472 | |
| 473 | |
| 474 | const ObjCPropertyDecl *findPropertyDecl(bool CheckOverrides = true) const; |
| 475 | |
| 476 | |
| 477 | void setDeclImplementation(ImplementationControl ic) { |
| 478 | ObjCMethodDeclBits.DeclImplementation = ic; |
| 479 | } |
| 480 | |
| 481 | ImplementationControl getImplementationControl() const { |
| 482 | return ImplementationControl(ObjCMethodDeclBits.DeclImplementation); |
| 483 | } |
| 484 | |
| 485 | bool isOptional() const { |
| 486 | return getImplementationControl() == Optional; |
| 487 | } |
| 488 | |
| 489 | |
| 490 | |
| 491 | bool isThisDeclarationADesignatedInitializer() const; |
| 492 | |
| 493 | |
| 494 | |
| 495 | |
| 496 | |
| 497 | |
| 498 | |
| 499 | bool isDesignatedInitializerForTheInterface( |
| 500 | const ObjCMethodDecl **InitMethod = nullptr) const; |
| 501 | |
| 502 | |
| 503 | bool hasBody() const override { return Body.isValid(); } |
| 504 | |
| 505 | |
| 506 | Stmt *getBody() const override; |
| 507 | |
| 508 | void setLazyBody(uint64_t Offset) { Body = Offset; } |
| 509 | |
| 510 | CompoundStmt *getCompoundBody() { return (CompoundStmt*)getBody(); } |
| 511 | void setBody(Stmt *B) { Body = B; } |
| 512 | |
| 513 | |
| 514 | bool isThisDeclarationADefinition() const { return hasBody(); } |
| 515 | |
| 516 | |
| 517 | bool definedInNSObject(const ASTContext &) const; |
| 518 | |
| 519 | |
| 520 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
| 521 | static bool classofKind(Kind K) { return K == ObjCMethod; } |
| 522 | |
| 523 | static DeclContext *castToDeclContext(const ObjCMethodDecl *D) { |
| 524 | return static_cast<DeclContext *>(const_cast<ObjCMethodDecl*>(D)); |
| 525 | } |
| 526 | |
| 527 | static ObjCMethodDecl *castFromDeclContext(const DeclContext *DC) { |
| 528 | return static_cast<ObjCMethodDecl *>(const_cast<DeclContext*>(DC)); |
| 529 | } |
| 530 | }; |
| 531 | |
| 532 | |
| 533 | enum class ObjCTypeParamVariance : uint8_t { |
| 534 | |
| 535 | Invariant, |
| 536 | |
| 537 | |
| 538 | |
| 539 | Covariant, |
| 540 | |
| 541 | |
| 542 | |
| 543 | Contravariant, |
| 544 | }; |
| 545 | |
| 546 | |
| 547 | |
| 548 | |
| 549 | |
| 550 | |
| 551 | |
| 552 | |
| 553 | |
| 554 | |
| 555 | |
| 556 | |
| 557 | |
| 558 | class ObjCTypeParamDecl : public TypedefNameDecl { |
| 559 | |
| 560 | unsigned Index : 14; |
| 561 | |
| 562 | |
| 563 | unsigned Variance : 2; |
| 564 | |
| 565 | |
| 566 | SourceLocation VarianceLoc; |
| 567 | |
| 568 | |
| 569 | |
| 570 | SourceLocation ColonLoc; |
| 571 | |
| 572 | ObjCTypeParamDecl(ASTContext &ctx, DeclContext *dc, |
| 573 | ObjCTypeParamVariance variance, SourceLocation varianceLoc, |
| 574 | unsigned index, |
| 575 | SourceLocation nameLoc, IdentifierInfo *name, |
| 576 | SourceLocation colonLoc, TypeSourceInfo *boundInfo) |
| 577 | : TypedefNameDecl(ObjCTypeParam, ctx, dc, nameLoc, nameLoc, name, |
| 578 | boundInfo), |
| 579 | Index(index), Variance(static_cast<unsigned>(variance)), |
| 580 | VarianceLoc(varianceLoc), ColonLoc(colonLoc) {} |
| 581 | |
| 582 | void anchor() override; |
| 583 | |
| 584 | public: |
| 585 | friend class ASTDeclReader; |
| 586 | friend class ASTDeclWriter; |
| 587 | |
| 588 | static ObjCTypeParamDecl *Create(ASTContext &ctx, DeclContext *dc, |
| 589 | ObjCTypeParamVariance variance, |
| 590 | SourceLocation varianceLoc, |
| 591 | unsigned index, |
| 592 | SourceLocation nameLoc, |
| 593 | IdentifierInfo *name, |
| 594 | SourceLocation colonLoc, |
| 595 | TypeSourceInfo *boundInfo); |
| 596 | static ObjCTypeParamDecl *CreateDeserialized(ASTContext &ctx, unsigned ID); |
| 597 | |
| 598 | SourceRange getSourceRange() const override LLVM_READONLY; |
| 599 | |
| 600 | |
| 601 | ObjCTypeParamVariance getVariance() const { |
| 602 | return static_cast<ObjCTypeParamVariance>(Variance); |
| 603 | } |
| 604 | |
| 605 | |
| 606 | void setVariance(ObjCTypeParamVariance variance) { |
| 607 | Variance = static_cast<unsigned>(variance); |
| 608 | } |
| 609 | |
| 610 | |
| 611 | SourceLocation getVarianceLoc() const { return VarianceLoc; } |
| 612 | |
| 613 | |
| 614 | unsigned getIndex() const { return Index; } |
| 615 | |
| 616 | |
| 617 | |
| 618 | bool hasExplicitBound() const { return ColonLoc.isValid(); } |
| 619 | |
| 620 | |
| 621 | |
| 622 | SourceLocation getColonLoc() const { return ColonLoc; } |
| 623 | |
| 624 | |
| 625 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
| 626 | static bool classofKind(Kind K) { return K == ObjCTypeParam; } |
| 627 | }; |
| 628 | |
| 629 | |
| 630 | |
| 631 | |
| 632 | |
| 633 | |
| 634 | |
| 635 | |
| 636 | class ObjCTypeParamList final |
| 637 | : private llvm::TrailingObjects<ObjCTypeParamList, ObjCTypeParamDecl *> { |
| 638 | |
| 639 | struct PODSourceRange { |
| 640 | unsigned Begin; |
| 641 | unsigned End; |
| 642 | }; |
| 643 | |
| 644 | union { |
| 645 | |
| 646 | PODSourceRange Brackets; |
| 647 | |
| 648 | |
| 649 | ObjCTypeParamDecl *AlignmentHack; |
| 650 | }; |
| 651 | |
| 652 | |
| 653 | unsigned NumParams; |
| 654 | |
| 655 | ObjCTypeParamList(SourceLocation lAngleLoc, |
| 656 | ArrayRef<ObjCTypeParamDecl *> typeParams, |
| 657 | SourceLocation rAngleLoc); |
| 658 | |
| 659 | public: |
| 660 | friend TrailingObjects; |
| 661 | |
| 662 | |
| 663 | static ObjCTypeParamList *create(ASTContext &ctx, |
| 664 | SourceLocation lAngleLoc, |
| 665 | ArrayRef<ObjCTypeParamDecl *> typeParams, |
| 666 | SourceLocation rAngleLoc); |
| 667 | |
| 668 | |
| 669 | using iterator = ObjCTypeParamDecl **; |
| 670 | |
| 671 | iterator begin() { return getTrailingObjects<ObjCTypeParamDecl *>(); } |
| 672 | |
| 673 | iterator end() { return begin() + size(); } |
| 674 | |
| 675 | |
| 676 | unsigned size() const { return NumParams; } |
| 677 | |
| 678 | |
| 679 | using const_iterator = ObjCTypeParamDecl * const *; |
| 680 | |
| 681 | const_iterator begin() const { |
| 682 | return getTrailingObjects<ObjCTypeParamDecl *>(); |
| 683 | } |
| 684 | |
| 685 | const_iterator end() const { |
| 686 | return begin() + size(); |
| 687 | } |
| 688 | |
| 689 | ObjCTypeParamDecl *front() const { |
| 690 | (0) . __assert_fail ("size() > 0 && \"empty Objective-C type parameter list\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/DeclObjC.h", 690, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(size() > 0 && "empty Objective-C type parameter list"); |
| 691 | return *begin(); |
| 692 | } |
| 693 | |
| 694 | ObjCTypeParamDecl *back() const { |
| 695 | (0) . __assert_fail ("size() > 0 && \"empty Objective-C type parameter list\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/DeclObjC.h", 695, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(size() > 0 && "empty Objective-C type parameter list"); |
| 696 | return *(end() - 1); |
| 697 | } |
| 698 | |
| 699 | SourceLocation getLAngleLoc() const { |
| 700 | return SourceLocation::getFromRawEncoding(Brackets.Begin); |
| 701 | } |
| 702 | |
| 703 | SourceLocation getRAngleLoc() const { |
| 704 | return SourceLocation::getFromRawEncoding(Brackets.End); |
| 705 | } |
| 706 | |
| 707 | SourceRange getSourceRange() const { |
| 708 | return SourceRange(getLAngleLoc(), getRAngleLoc()); |
| 709 | } |
| 710 | |
| 711 | |
| 712 | |
| 713 | void gatherDefaultTypeArgs(SmallVectorImpl<QualType> &typeArgs) const; |
| 714 | }; |
| 715 | |
| 716 | enum class ObjCPropertyQueryKind : uint8_t { |
| 717 | OBJC_PR_query_unknown = 0x00, |
| 718 | OBJC_PR_query_instance, |
| 719 | OBJC_PR_query_class |
| 720 | }; |
| 721 | |
| 722 | |
| 723 | |
| 724 | |
| 725 | |
| 726 | |
| 727 | |
| 728 | class ObjCPropertyDecl : public NamedDecl { |
| 729 | void anchor() override; |
| 730 | |
| 731 | public: |
| 732 | enum PropertyAttributeKind { |
| 733 | OBJC_PR_noattr = 0x00, |
| 734 | OBJC_PR_readonly = 0x01, |
| 735 | OBJC_PR_getter = 0x02, |
| 736 | OBJC_PR_assign = 0x04, |
| 737 | OBJC_PR_readwrite = 0x08, |
| 738 | OBJC_PR_retain = 0x10, |
| 739 | OBJC_PR_copy = 0x20, |
| 740 | OBJC_PR_nonatomic = 0x40, |
| 741 | OBJC_PR_setter = 0x80, |
| 742 | OBJC_PR_atomic = 0x100, |
| 743 | OBJC_PR_weak = 0x200, |
| 744 | OBJC_PR_strong = 0x400, |
| 745 | OBJC_PR_unsafe_unretained = 0x800, |
| 746 | |
| 747 | |
| 748 | OBJC_PR_nullability = 0x1000, |
| 749 | OBJC_PR_null_resettable = 0x2000, |
| 750 | OBJC_PR_class = 0x4000 |
| 751 | |
| 752 | }; |
| 753 | |
| 754 | enum { |
| 755 | |
| 756 | NumPropertyAttrsBits = 15 |
| 757 | }; |
| 758 | |
| 759 | enum SetterKind { Assign, Retain, Copy, Weak }; |
| 760 | enum PropertyControl { None, Required, Optional }; |
| 761 | |
| 762 | private: |
| 763 | |
| 764 | SourceLocation AtLoc; |
| 765 | |
| 766 | |
| 767 | SourceLocation LParenLoc; |
| 768 | |
| 769 | QualType DeclType; |
| 770 | TypeSourceInfo *DeclTypeSourceInfo; |
| 771 | unsigned PropertyAttributes : NumPropertyAttrsBits; |
| 772 | unsigned PropertyAttributesAsWritten : NumPropertyAttrsBits; |
| 773 | |
| 774 | |
| 775 | unsigned PropertyImplementation : 2; |
| 776 | |
| 777 | |
| 778 | Selector GetterName; |
| 779 | |
| 780 | |
| 781 | Selector SetterName; |
| 782 | |
| 783 | |
| 784 | SourceLocation GetterNameLoc; |
| 785 | |
| 786 | |
| 787 | SourceLocation SetterNameLoc; |
| 788 | |
| 789 | |
| 790 | ObjCMethodDecl *GetterMethodDecl = nullptr; |
| 791 | |
| 792 | |
| 793 | ObjCMethodDecl *SetterMethodDecl = nullptr; |
| 794 | |
| 795 | |
| 796 | ObjCIvarDecl *PropertyIvarDecl = nullptr; |
| 797 | |
| 798 | ObjCPropertyDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id, |
| 799 | SourceLocation AtLocation, SourceLocation LParenLocation, |
| 800 | QualType T, TypeSourceInfo *TSI, |
| 801 | PropertyControl propControl) |
| 802 | : NamedDecl(ObjCProperty, DC, L, Id), AtLoc(AtLocation), |
| 803 | LParenLoc(LParenLocation), DeclType(T), DeclTypeSourceInfo(TSI), |
| 804 | PropertyAttributes(OBJC_PR_noattr), |
| 805 | PropertyAttributesAsWritten(OBJC_PR_noattr), |
| 806 | PropertyImplementation(propControl), GetterName(Selector()), |
| 807 | SetterName(Selector()) {} |
| 808 | |
| 809 | public: |
| 810 | static ObjCPropertyDecl *Create(ASTContext &C, DeclContext *DC, |
| 811 | SourceLocation L, |
| 812 | IdentifierInfo *Id, SourceLocation AtLocation, |
| 813 | SourceLocation LParenLocation, |
| 814 | QualType T, |
| 815 | TypeSourceInfo *TSI, |
| 816 | PropertyControl propControl = None); |
| 817 | |
| 818 | static ObjCPropertyDecl *CreateDeserialized(ASTContext &C, unsigned ID); |
| 819 | |
| 820 | SourceLocation getAtLoc() const { return AtLoc; } |
| 821 | void setAtLoc(SourceLocation L) { AtLoc = L; } |
| 822 | |
| 823 | SourceLocation getLParenLoc() const { return LParenLoc; } |
| 824 | void setLParenLoc(SourceLocation L) { LParenLoc = L; } |
| 825 | |
| 826 | TypeSourceInfo *getTypeSourceInfo() const { return DeclTypeSourceInfo; } |
| 827 | |
| 828 | QualType getType() const { return DeclType; } |
| 829 | |
| 830 | void setType(QualType T, TypeSourceInfo *TSI) { |
| 831 | DeclType = T; |
| 832 | DeclTypeSourceInfo = TSI; |
| 833 | } |
| 834 | |
| 835 | |
| 836 | |
| 837 | QualType getUsageType(QualType objectType) const; |
| 838 | |
| 839 | PropertyAttributeKind getPropertyAttributes() const { |
| 840 | return PropertyAttributeKind(PropertyAttributes); |
| 841 | } |
| 842 | |
| 843 | void setPropertyAttributes(PropertyAttributeKind PRVal) { |
| 844 | PropertyAttributes |= PRVal; |
| 845 | } |
| 846 | |
| 847 | void overwritePropertyAttributes(unsigned PRVal) { |
| 848 | PropertyAttributes = PRVal; |
| 849 | } |
| 850 | |
| 851 | PropertyAttributeKind getPropertyAttributesAsWritten() const { |
| 852 | return PropertyAttributeKind(PropertyAttributesAsWritten); |
| 853 | } |
| 854 | |
| 855 | void setPropertyAttributesAsWritten(PropertyAttributeKind PRVal) { |
| 856 | PropertyAttributesAsWritten = PRVal; |
| 857 | } |
| 858 | |
| 859 | |
| 860 | |
| 861 | |
| 862 | bool isReadOnly() const { |
| 863 | return (PropertyAttributes & OBJC_PR_readonly); |
| 864 | } |
| 865 | |
| 866 | |
| 867 | bool isAtomic() const { |
| 868 | return (PropertyAttributes & OBJC_PR_atomic); |
| 869 | } |
| 870 | |
| 871 | |
| 872 | bool isRetaining() const { |
| 873 | return (PropertyAttributes & |
| 874 | (OBJC_PR_retain | OBJC_PR_strong | OBJC_PR_copy)); |
| 875 | } |
| 876 | |
| 877 | bool isInstanceProperty() const { return !isClassProperty(); } |
| 878 | bool isClassProperty() const { return PropertyAttributes & OBJC_PR_class; } |
| 879 | |
| 880 | ObjCPropertyQueryKind getQueryKind() const { |
| 881 | return isClassProperty() ? ObjCPropertyQueryKind::OBJC_PR_query_class : |
| 882 | ObjCPropertyQueryKind::OBJC_PR_query_instance; |
| 883 | } |
| 884 | |
| 885 | static ObjCPropertyQueryKind getQueryKind(bool isClassProperty) { |
| 886 | return isClassProperty ? ObjCPropertyQueryKind::OBJC_PR_query_class : |
| 887 | ObjCPropertyQueryKind::OBJC_PR_query_instance; |
| 888 | } |
| 889 | |
| 890 | |
| 891 | |
| 892 | |
| 893 | SetterKind getSetterKind() const { |
| 894 | if (PropertyAttributes & OBJC_PR_strong) |
| 895 | return getType()->isBlockPointerType() ? Copy : Retain; |
| 896 | if (PropertyAttributes & OBJC_PR_retain) |
| 897 | return Retain; |
| 898 | if (PropertyAttributes & OBJC_PR_copy) |
| 899 | return Copy; |
| 900 | if (PropertyAttributes & OBJC_PR_weak) |
| 901 | return Weak; |
| 902 | return Assign; |
| 903 | } |
| 904 | |
| 905 | Selector getGetterName() const { return GetterName; } |
| 906 | SourceLocation getGetterNameLoc() const { return GetterNameLoc; } |
| 907 | |
| 908 | void setGetterName(Selector Sel, SourceLocation Loc = SourceLocation()) { |
| 909 | GetterName = Sel; |
| 910 | GetterNameLoc = Loc; |
| 911 | } |
| 912 | |
| 913 | Selector getSetterName() const { return SetterName; } |
| 914 | SourceLocation getSetterNameLoc() const { return SetterNameLoc; } |
| 915 | |
| 916 | void setSetterName(Selector Sel, SourceLocation Loc = SourceLocation()) { |
| 917 | SetterName = Sel; |
| 918 | SetterNameLoc = Loc; |
| 919 | } |
| 920 | |
| 921 | ObjCMethodDecl *getGetterMethodDecl() const { return GetterMethodDecl; } |
| 922 | void setGetterMethodDecl(ObjCMethodDecl *gDecl) { GetterMethodDecl = gDecl; } |
| 923 | |
| 924 | ObjCMethodDecl *getSetterMethodDecl() const { return SetterMethodDecl; } |
| 925 | void setSetterMethodDecl(ObjCMethodDecl *gDecl) { SetterMethodDecl = gDecl; } |
| 926 | |
| 927 | |
| 928 | void setPropertyImplementation(PropertyControl pc) { |
| 929 | PropertyImplementation = pc; |
| 930 | } |
| 931 | |
| 932 | PropertyControl getPropertyImplementation() const { |
| 933 | return PropertyControl(PropertyImplementation); |
| 934 | } |
| 935 | |
| 936 | bool isOptional() const { |
| 937 | return getPropertyImplementation() == PropertyControl::Optional; |
| 938 | } |
| 939 | |
| 940 | void setPropertyIvarDecl(ObjCIvarDecl *Ivar) { |
| 941 | PropertyIvarDecl = Ivar; |
| 942 | } |
| 943 | |
| 944 | ObjCIvarDecl *getPropertyIvarDecl() const { |
| 945 | return PropertyIvarDecl; |
| 946 | } |
| 947 | |
| 948 | SourceRange getSourceRange() const override LLVM_READONLY { |
| 949 | return SourceRange(AtLoc, getLocation()); |
| 950 | } |
| 951 | |
| 952 | |
| 953 | IdentifierInfo *getDefaultSynthIvarName(ASTContext &Ctx) const; |
| 954 | |
| 955 | |
| 956 | static ObjCPropertyDecl *findPropertyDecl(const DeclContext *DC, |
| 957 | const IdentifierInfo *propertyID, |
| 958 | ObjCPropertyQueryKind queryKind); |
| 959 | |
| 960 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
| 961 | static bool classofKind(Kind K) { return K == ObjCProperty; } |
| 962 | }; |
| 963 | |
| 964 | |
| 965 | |
| 966 | |
| 967 | |
| 968 | class ObjCContainerDecl : public NamedDecl, public DeclContext { |
| 969 | |
| 970 | |
| 971 | |
| 972 | |
| 973 | |
| 974 | SourceRange AtEnd; |
| 975 | |
| 976 | void anchor() override; |
| 977 | |
| 978 | public: |
| 979 | ObjCContainerDecl(Kind DK, DeclContext *DC, IdentifierInfo *Id, |
| 980 | SourceLocation nameLoc, SourceLocation atStartLoc); |
| 981 | |
| 982 | |
| 983 | using prop_iterator = specific_decl_iterator<ObjCPropertyDecl>; |
| 984 | using prop_range = |
| 985 | llvm::iterator_range<specific_decl_iterator<ObjCPropertyDecl>>; |
| 986 | |
| 987 | prop_range properties() const { return prop_range(prop_begin(), prop_end()); } |
| 988 | |
| 989 | prop_iterator prop_begin() const { |
| 990 | return prop_iterator(decls_begin()); |
| 991 | } |
| 992 | |
| 993 | prop_iterator prop_end() const { |
| 994 | return prop_iterator(decls_end()); |
| 995 | } |
| 996 | |
| 997 | using instprop_iterator = |
| 998 | filtered_decl_iterator<ObjCPropertyDecl, |
| 999 | &ObjCPropertyDecl::isInstanceProperty>; |
| 1000 | using instprop_range = llvm::iterator_range<instprop_iterator>; |
| 1001 | |
| 1002 | instprop_range instance_properties() const { |
| 1003 | return instprop_range(instprop_begin(), instprop_end()); |
| 1004 | } |
| 1005 | |
| 1006 | instprop_iterator instprop_begin() const { |
| 1007 | return instprop_iterator(decls_begin()); |
| 1008 | } |
| 1009 | |
| 1010 | instprop_iterator instprop_end() const { |
| 1011 | return instprop_iterator(decls_end()); |
| 1012 | } |
| 1013 | |
| 1014 | using classprop_iterator = |
| 1015 | filtered_decl_iterator<ObjCPropertyDecl, |
| 1016 | &ObjCPropertyDecl::isClassProperty>; |
| 1017 | using classprop_range = llvm::iterator_range<classprop_iterator>; |
| 1018 | |
| 1019 | classprop_range class_properties() const { |
| 1020 | return classprop_range(classprop_begin(), classprop_end()); |
| 1021 | } |
| 1022 | |
| 1023 | classprop_iterator classprop_begin() const { |
| 1024 | return classprop_iterator(decls_begin()); |
| 1025 | } |
| 1026 | |
| 1027 | classprop_iterator classprop_end() const { |
| 1028 | return classprop_iterator(decls_end()); |
| 1029 | } |
| 1030 | |
| 1031 | |
| 1032 | using method_iterator = specific_decl_iterator<ObjCMethodDecl>; |
| 1033 | using method_range = |
| 1034 | llvm::iterator_range<specific_decl_iterator<ObjCMethodDecl>>; |
| 1035 | |
| 1036 | method_range methods() const { |
| 1037 | return method_range(meth_begin(), meth_end()); |
| 1038 | } |
| 1039 | |
| 1040 | method_iterator meth_begin() const { |
| 1041 | return method_iterator(decls_begin()); |
| 1042 | } |
| 1043 | |
| 1044 | method_iterator meth_end() const { |
| 1045 | return method_iterator(decls_end()); |
| 1046 | } |
| 1047 | |
| 1048 | using instmeth_iterator = |
| 1049 | filtered_decl_iterator<ObjCMethodDecl, |
| 1050 | &ObjCMethodDecl::isInstanceMethod>; |
| 1051 | using instmeth_range = llvm::iterator_range<instmeth_iterator>; |
| 1052 | |
| 1053 | instmeth_range instance_methods() const { |
| 1054 | return instmeth_range(instmeth_begin(), instmeth_end()); |
| 1055 | } |
| 1056 | |
| 1057 | instmeth_iterator instmeth_begin() const { |
| 1058 | return instmeth_iterator(decls_begin()); |
| 1059 | } |
| 1060 | |
| 1061 | instmeth_iterator instmeth_end() const { |
| 1062 | return instmeth_iterator(decls_end()); |
| 1063 | } |
| 1064 | |
| 1065 | using classmeth_iterator = |
| 1066 | filtered_decl_iterator<ObjCMethodDecl, |
| 1067 | &ObjCMethodDecl::isClassMethod>; |
| 1068 | using classmeth_range = llvm::iterator_range<classmeth_iterator>; |
| 1069 | |
| 1070 | classmeth_range class_methods() const { |
| 1071 | return classmeth_range(classmeth_begin(), classmeth_end()); |
| 1072 | } |
| 1073 | |
| 1074 | classmeth_iterator classmeth_begin() const { |
| 1075 | return classmeth_iterator(decls_begin()); |
| 1076 | } |
| 1077 | |
| 1078 | classmeth_iterator classmeth_end() const { |
| 1079 | return classmeth_iterator(decls_end()); |
| 1080 | } |
| 1081 | |
| 1082 | |
| 1083 | ObjCMethodDecl *getMethod(Selector Sel, bool isInstance, |
| 1084 | bool AllowHidden = false) const; |
| 1085 | |
| 1086 | ObjCMethodDecl *getInstanceMethod(Selector Sel, |
| 1087 | bool AllowHidden = false) const { |
| 1088 | return getMethod(Sel, true, AllowHidden); |
| 1089 | } |
| 1090 | |
| 1091 | ObjCMethodDecl *getClassMethod(Selector Sel, bool AllowHidden = false) const { |
| 1092 | return getMethod(Sel, false, AllowHidden); |
| 1093 | } |
| 1094 | |
| 1095 | bool HasUserDeclaredSetterMethod(const ObjCPropertyDecl *P) const; |
| 1096 | ObjCIvarDecl *getIvarDecl(IdentifierInfo *Id) const; |
| 1097 | |
| 1098 | ObjCPropertyDecl * |
| 1099 | FindPropertyDeclaration(const IdentifierInfo *PropertyId, |
| 1100 | ObjCPropertyQueryKind QueryKind) const; |
| 1101 | |
| 1102 | using PropertyMap = |
| 1103 | llvm::DenseMap<std::pair<IdentifierInfo *, unsigned>, |
| 1104 | ObjCPropertyDecl *>; |
| 1105 | using ProtocolPropertySet = llvm::SmallDenseSet<const ObjCProtocolDecl *, 8>; |
| 1106 | using PropertyDeclOrder = llvm::SmallVector<ObjCPropertyDecl *, 8>; |
| 1107 | |
| 1108 | |
| 1109 | |
| 1110 | |
| 1111 | virtual void collectPropertiesToImplement(PropertyMap &PM, |
| 1112 | PropertyDeclOrder &PO) const {} |
| 1113 | |
| 1114 | SourceLocation getAtStartLoc() const { return ObjCContainerDeclBits.AtStart; } |
| 1115 | |
| 1116 | void setAtStartLoc(SourceLocation Loc) { |
| 1117 | ObjCContainerDeclBits.AtStart = Loc; |
| 1118 | } |
| 1119 | |
| 1120 | |
| 1121 | SourceRange getAtEndRange() const { return AtEnd; } |
| 1122 | |
| 1123 | void setAtEndRange(SourceRange atEnd) { AtEnd = atEnd; } |
| 1124 | |
| 1125 | SourceRange getSourceRange() const override LLVM_READONLY { |
| 1126 | return SourceRange(getAtStartLoc(), getAtEndRange().getEnd()); |
| 1127 | } |
| 1128 | |
| 1129 | |
| 1130 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
| 1131 | |
| 1132 | static bool classofKind(Kind K) { |
| 1133 | return K >= firstObjCContainer && |
| 1134 | K <= lastObjCContainer; |
| 1135 | } |
| 1136 | |
| 1137 | static DeclContext *castToDeclContext(const ObjCContainerDecl *D) { |
| 1138 | return static_cast<DeclContext *>(const_cast<ObjCContainerDecl*>(D)); |
| 1139 | } |
| 1140 | |
| 1141 | static ObjCContainerDecl *castFromDeclContext(const DeclContext *DC) { |
| 1142 | return static_cast<ObjCContainerDecl *>(const_cast<DeclContext*>(DC)); |
| 1143 | } |
| 1144 | }; |
| 1145 | |
| 1146 | |
| 1147 | |
| 1148 | |
| 1149 | |
| 1150 | |
| 1151 | |
| 1152 | |
| 1153 | |
| 1154 | |
| 1155 | |
| 1156 | |
| 1157 | |
| 1158 | |
| 1159 | |
| 1160 | |
| 1161 | |
| 1162 | |
| 1163 | |
| 1164 | |
| 1165 | |
| 1166 | |
| 1167 | |
| 1168 | |
| 1169 | |
| 1170 | |
| 1171 | class ObjCInterfaceDecl : public ObjCContainerDecl |
| 1172 | , public Redeclarable<ObjCInterfaceDecl> { |
| 1173 | friend class ASTContext; |
| 1174 | |
| 1175 | |
| 1176 | |
| 1177 | mutable const Type *TypeForDecl = nullptr; |
| 1178 | |
| 1179 | struct DefinitionData { |
| 1180 | |
| 1181 | |
| 1182 | ObjCInterfaceDecl *Definition = nullptr; |
| 1183 | |
| 1184 | |
| 1185 | TypeSourceInfo *SuperClassTInfo = nullptr; |
| 1186 | |
| 1187 | |
| 1188 | ObjCProtocolList ReferencedProtocols; |
| 1189 | |
| 1190 | |
| 1191 | ObjCList<ObjCProtocolDecl> AllReferencedProtocols; |
| 1192 | |
| 1193 | |
| 1194 | |
| 1195 | |
| 1196 | |
| 1197 | |
| 1198 | ObjCCategoryDecl *CategoryList = nullptr; |
| 1199 | |
| 1200 | |
| 1201 | |
| 1202 | ObjCIvarDecl *IvarList = nullptr; |
| 1203 | |
| 1204 | |
| 1205 | |
| 1206 | mutable unsigned ExternallyCompleted : 1; |
| 1207 | |
| 1208 | |
| 1209 | |
| 1210 | mutable unsigned IvarListMissingImplementation : 1; |
| 1211 | |
| 1212 | |
| 1213 | |
| 1214 | unsigned HasDesignatedInitializers : 1; |
| 1215 | |
| 1216 | enum { |
| 1217 | |
| 1218 | |
| 1219 | IDI_Unknown = 0, |
| 1220 | |
| 1221 | |
| 1222 | IDI_Inherited = 1, |
| 1223 | |
| 1224 | |
| 1225 | IDI_NotInherited = 2 |
| 1226 | }; |
| 1227 | |
| 1228 | |
| 1229 | mutable unsigned InheritedDesignatedInitializers : 2; |
| 1230 | |
| 1231 | |
| 1232 | |
| 1233 | |
| 1234 | SourceLocation EndLoc; |
| 1235 | |
| 1236 | DefinitionData() |
| 1237 | : ExternallyCompleted(false), IvarListMissingImplementation(true), |
| 1238 | HasDesignatedInitializers(false), |
| 1239 | InheritedDesignatedInitializers(IDI_Unknown) {} |
| 1240 | }; |
| 1241 | |
| 1242 | |
| 1243 | ObjCTypeParamList *TypeParamList = nullptr; |
| 1244 | |
| 1245 | |
| 1246 | |
| 1247 | |
| 1248 | |
| 1249 | |
| 1250 | llvm::PointerIntPair<DefinitionData *, 1, bool> Data; |
| 1251 | |
| 1252 | ObjCInterfaceDecl(const ASTContext &C, DeclContext *DC, SourceLocation AtLoc, |
| 1253 | IdentifierInfo *Id, ObjCTypeParamList *typeParamList, |
| 1254 | SourceLocation CLoc, ObjCInterfaceDecl *PrevDecl, |
| 1255 | bool IsInternal); |
| 1256 | |
| 1257 | void anchor() override; |
| 1258 | |
| 1259 | void LoadExternalDefinition() const; |
| 1260 | |
| 1261 | DefinitionData &data() const { |
| 1262 | (0) . __assert_fail ("Data.getPointer() && \"Declaration has no definition!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/DeclObjC.h", 1262, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(Data.getPointer() && "Declaration has no definition!"); |
| 1263 | return *Data.getPointer(); |
| 1264 | } |
| 1265 | |
| 1266 | |
| 1267 | void allocateDefinitionData(); |
| 1268 | |
| 1269 | using redeclarable_base = Redeclarable<ObjCInterfaceDecl>; |
| 1270 | |
| 1271 | ObjCInterfaceDecl *getNextRedeclarationImpl() override { |
| 1272 | return getNextRedeclaration(); |
| 1273 | } |
| 1274 | |
| 1275 | ObjCInterfaceDecl *getPreviousDeclImpl() override { |
| 1276 | return getPreviousDecl(); |
| 1277 | } |
| 1278 | |
| 1279 | ObjCInterfaceDecl *getMostRecentDeclImpl() override { |
| 1280 | return getMostRecentDecl(); |
| 1281 | } |
| 1282 | |
| 1283 | public: |
| 1284 | static ObjCInterfaceDecl *Create(const ASTContext &C, DeclContext *DC, |
| 1285 | SourceLocation atLoc, |
| 1286 | IdentifierInfo *Id, |
| 1287 | ObjCTypeParamList *typeParamList, |
| 1288 | ObjCInterfaceDecl *PrevDecl, |
| 1289 | SourceLocation ClassLoc = SourceLocation(), |
| 1290 | bool isInternal = false); |
| 1291 | |
| 1292 | static ObjCInterfaceDecl *CreateDeserialized(const ASTContext &C, unsigned ID); |
| 1293 | |
| 1294 | |
| 1295 | |
| 1296 | |
| 1297 | |
| 1298 | |
| 1299 | |
| 1300 | ObjCTypeParamList *getTypeParamList() const; |
| 1301 | |
| 1302 | |
| 1303 | |
| 1304 | |
| 1305 | |
| 1306 | void setTypeParamList(ObjCTypeParamList *TPL); |
| 1307 | |
| 1308 | |
| 1309 | |
| 1310 | ObjCTypeParamList *getTypeParamListAsWritten() const { |
| 1311 | return TypeParamList; |
| 1312 | } |
| 1313 | |
| 1314 | SourceRange getSourceRange() const override LLVM_READONLY { |
| 1315 | if (isThisDeclarationADefinition()) |
| 1316 | return ObjCContainerDecl::getSourceRange(); |
| 1317 | |
| 1318 | return SourceRange(getAtStartLoc(), getLocation()); |
| 1319 | } |
| 1320 | |
| 1321 | |
| 1322 | |
| 1323 | |
| 1324 | void setExternallyCompleted(); |
| 1325 | |
| 1326 | |
| 1327 | |
| 1328 | void setHasDesignatedInitializers(); |
| 1329 | |
| 1330 | |
| 1331 | |
| 1332 | bool hasDesignatedInitializers() const; |
| 1333 | |
| 1334 | |
| 1335 | |
| 1336 | bool declaresOrInheritsDesignatedInitializers() const { |
| 1337 | return hasDesignatedInitializers() || inheritsDesignatedInitializers(); |
| 1338 | } |
| 1339 | |
| 1340 | const ObjCProtocolList &getReferencedProtocols() const { |
| 1341 | (0) . __assert_fail ("hasDefinition() && \"Caller did not check for forward reference!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/DeclObjC.h", 1341, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(hasDefinition() && "Caller did not check for forward reference!"); |
| 1342 | if (data().ExternallyCompleted) |
| 1343 | LoadExternalDefinition(); |
| 1344 | |
| 1345 | return data().ReferencedProtocols; |
| 1346 | } |
| 1347 | |
| 1348 | ObjCImplementationDecl *getImplementation() const; |
| 1349 | void setImplementation(ObjCImplementationDecl *ImplD); |
| 1350 | |
| 1351 | ObjCCategoryDecl *FindCategoryDeclaration(IdentifierInfo *CategoryId) const; |
| 1352 | |
| 1353 | |
| 1354 | ObjCMethodDecl *getCategoryInstanceMethod(Selector Sel) const; |
| 1355 | ObjCMethodDecl *getCategoryClassMethod(Selector Sel) const; |
| 1356 | |
| 1357 | ObjCMethodDecl *getCategoryMethod(Selector Sel, bool isInstance) const { |
| 1358 | return isInstance ? getCategoryInstanceMethod(Sel) |
| 1359 | : getCategoryClassMethod(Sel); |
| 1360 | } |
| 1361 | |
| 1362 | using protocol_iterator = ObjCProtocolList::iterator; |
| 1363 | using protocol_range = llvm::iterator_range<protocol_iterator>; |
| 1364 | |
| 1365 | protocol_range protocols() const { |
| 1366 | return protocol_range(protocol_begin(), protocol_end()); |
| 1367 | } |
| 1368 | |
| 1369 | protocol_iterator protocol_begin() const { |
| 1370 | |
| 1371 | if (!hasDefinition()) |
| 1372 | return protocol_iterator(); |
| 1373 | |
| 1374 | if (data().ExternallyCompleted) |
| 1375 | LoadExternalDefinition(); |
| 1376 | |
| 1377 | return data().ReferencedProtocols.begin(); |
| 1378 | } |
| 1379 | |
| 1380 | protocol_iterator protocol_end() const { |
| 1381 | |
| 1382 | if (!hasDefinition()) |
| 1383 | return protocol_iterator(); |
| 1384 | |
| 1385 | if (data().ExternallyCompleted) |
| 1386 | LoadExternalDefinition(); |
| 1387 | |
| 1388 | return data().ReferencedProtocols.end(); |
| 1389 | } |
| 1390 | |
| 1391 | using protocol_loc_iterator = ObjCProtocolList::loc_iterator; |
| 1392 | using protocol_loc_range = llvm::iterator_range<protocol_loc_iterator>; |
| 1393 | |
| 1394 | protocol_loc_range protocol_locs() const { |
| 1395 | return protocol_loc_range(protocol_loc_begin(), protocol_loc_end()); |
| 1396 | } |
| 1397 | |
| 1398 | protocol_loc_iterator protocol_loc_begin() const { |
| 1399 | |
| 1400 | if (!hasDefinition()) |
| 1401 | return protocol_loc_iterator(); |
| 1402 | |
| 1403 | if (data().ExternallyCompleted) |
| 1404 | LoadExternalDefinition(); |
| 1405 | |
| 1406 | return data().ReferencedProtocols.loc_begin(); |
| 1407 | } |
| 1408 | |
| 1409 | protocol_loc_iterator protocol_loc_end() const { |
| 1410 | |
| 1411 | if (!hasDefinition()) |
| 1412 | return protocol_loc_iterator(); |
| 1413 | |
| 1414 | if (data().ExternallyCompleted) |
| 1415 | LoadExternalDefinition(); |
| 1416 | |
| 1417 | return data().ReferencedProtocols.loc_end(); |
| 1418 | } |
| 1419 | |
| 1420 | using all_protocol_iterator = ObjCList<ObjCProtocolDecl>::iterator; |
| 1421 | using all_protocol_range = llvm::iterator_range<all_protocol_iterator>; |
| 1422 | |
| 1423 | all_protocol_range all_referenced_protocols() const { |
| 1424 | return all_protocol_range(all_referenced_protocol_begin(), |
| 1425 | all_referenced_protocol_end()); |
| 1426 | } |
| 1427 | |
| 1428 | all_protocol_iterator all_referenced_protocol_begin() const { |
| 1429 | |
| 1430 | if (!hasDefinition()) |
| 1431 | return all_protocol_iterator(); |
| 1432 | |
| 1433 | if (data().ExternallyCompleted) |
| 1434 | LoadExternalDefinition(); |
| 1435 | |
| 1436 | return data().AllReferencedProtocols.empty() |
| 1437 | ? protocol_begin() |
| 1438 | : data().AllReferencedProtocols.begin(); |
| 1439 | } |
| 1440 | |
| 1441 | all_protocol_iterator all_referenced_protocol_end() const { |
| 1442 | |
| 1443 | if (!hasDefinition()) |
| 1444 | return all_protocol_iterator(); |
| 1445 | |
| 1446 | if (data().ExternallyCompleted) |
| 1447 | LoadExternalDefinition(); |
| 1448 | |
| 1449 | return data().AllReferencedProtocols.empty() |
| 1450 | ? protocol_end() |
| 1451 | : data().AllReferencedProtocols.end(); |
| 1452 | } |
| 1453 | |
| 1454 | using ivar_iterator = specific_decl_iterator<ObjCIvarDecl>; |
| 1455 | using ivar_range = llvm::iterator_range<specific_decl_iterator<ObjCIvarDecl>>; |
| 1456 | |
| 1457 | ivar_range ivars() const { return ivar_range(ivar_begin(), ivar_end()); } |
| 1458 | |
| 1459 | ivar_iterator ivar_begin() const { |
| 1460 | if (const ObjCInterfaceDecl *Def = getDefinition()) |
| 1461 | return ivar_iterator(Def->decls_begin()); |
| 1462 | |
| 1463 | |
| 1464 | return ivar_iterator(); |
| 1465 | } |
| 1466 | |
| 1467 | ivar_iterator ivar_end() const { |
| 1468 | if (const ObjCInterfaceDecl *Def = getDefinition()) |
| 1469 | return ivar_iterator(Def->decls_end()); |
| 1470 | |
| 1471 | |
| 1472 | return ivar_iterator(); |
| 1473 | } |
| 1474 | |
| 1475 | unsigned ivar_size() const { |
| 1476 | return std::distance(ivar_begin(), ivar_end()); |
| 1477 | } |
| 1478 | |
| 1479 | bool ivar_empty() const { return ivar_begin() == ivar_end(); } |
| 1480 | |
| 1481 | ObjCIvarDecl *all_declared_ivar_begin(); |
| 1482 | const ObjCIvarDecl *all_declared_ivar_begin() const { |
| 1483 | |
| 1484 | |
| 1485 | return const_cast<ObjCInterfaceDecl *>(this)->all_declared_ivar_begin(); |
| 1486 | } |
| 1487 | void setIvarList(ObjCIvarDecl *ivar) { data().IvarList = ivar; } |
| 1488 | |
| 1489 | |
| 1490 | |
| 1491 | void setProtocolList(ObjCProtocolDecl *const* List, unsigned Num, |
| 1492 | const SourceLocation *Locs, ASTContext &C) { |
| 1493 | data().ReferencedProtocols.set(List, Num, Locs, C); |
| 1494 | } |
| 1495 | |
| 1496 | |
| 1497 | |
| 1498 | void mergeClassExtensionProtocolList(ObjCProtocolDecl *const* List, |
| 1499 | unsigned Num, |
| 1500 | ASTContext &C); |
| 1501 | |
| 1502 | |
| 1503 | |
| 1504 | StringRef getObjCRuntimeNameAsString() const; |
| 1505 | |
| 1506 | |
| 1507 | |
| 1508 | |
| 1509 | |
| 1510 | |
| 1511 | void getDesignatedInitializers( |
| 1512 | llvm::SmallVectorImpl<const ObjCMethodDecl *> &Methods) const; |
| 1513 | |
| 1514 | |
| 1515 | |
| 1516 | |
| 1517 | |
| 1518 | |
| 1519 | |
| 1520 | |
| 1521 | |
| 1522 | |
| 1523 | bool |
| 1524 | isDesignatedInitializer(Selector Sel, |
| 1525 | const ObjCMethodDecl **InitMethod = nullptr) const; |
| 1526 | |
| 1527 | |
| 1528 | |
| 1529 | bool isThisDeclarationADefinition() const { |
| 1530 | return getDefinition() == this; |
| 1531 | } |
| 1532 | |
| 1533 | |
| 1534 | bool hasDefinition() const { |
| 1535 | |
| 1536 | |
| 1537 | |
| 1538 | |
| 1539 | if (!Data.getOpaqueValue()) |
| 1540 | getMostRecentDecl(); |
| 1541 | |
| 1542 | return Data.getPointer(); |
| 1543 | } |
| 1544 | |
| 1545 | |
| 1546 | |
| 1547 | |
| 1548 | ObjCInterfaceDecl *getDefinition() { |
| 1549 | return hasDefinition()? Data.getPointer()->Definition : nullptr; |
| 1550 | } |
| 1551 | |
| 1552 | |
| 1553 | |
| 1554 | |
| 1555 | const ObjCInterfaceDecl *getDefinition() const { |
| 1556 | return hasDefinition()? Data.getPointer()->Definition : nullptr; |
| 1557 | } |
| 1558 | |
| 1559 | |
| 1560 | |
| 1561 | void startDefinition(); |
| 1562 | |
| 1563 | |
| 1564 | const ObjCObjectType *getSuperClassType() const { |
| 1565 | if (TypeSourceInfo *TInfo = getSuperClassTInfo()) |
| 1566 | return TInfo->getType()->castAs<ObjCObjectType>(); |
| 1567 | |
| 1568 | return nullptr; |
| 1569 | } |
| 1570 | |
| 1571 | |
| 1572 | TypeSourceInfo *getSuperClassTInfo() const { |
| 1573 | |
| 1574 | if (!hasDefinition()) |
| 1575 | return nullptr; |
| 1576 | |
| 1577 | if (data().ExternallyCompleted) |
| 1578 | LoadExternalDefinition(); |
| 1579 | |
| 1580 | return data().SuperClassTInfo; |
| 1581 | } |
| 1582 | |
| 1583 | |
| 1584 | |
| 1585 | ObjCInterfaceDecl *getSuperClass() const; |
| 1586 | |
| 1587 | void setSuperClass(TypeSourceInfo *superClass) { |
| 1588 | data().SuperClassTInfo = superClass; |
| 1589 | } |
| 1590 | |
| 1591 | |
| 1592 | |
| 1593 | |
| 1594 | |
| 1595 | |
| 1596 | template<bool (*Filter)(ObjCCategoryDecl *)> |
| 1597 | class filtered_category_iterator { |
| 1598 | ObjCCategoryDecl *Current = nullptr; |
| 1599 | |
| 1600 | void findAcceptableCategory(); |
| 1601 | |
| 1602 | public: |
| 1603 | using value_type = ObjCCategoryDecl *; |
| 1604 | using reference = value_type; |
| 1605 | using pointer = value_type; |
| 1606 | using difference_type = std::ptrdiff_t; |
| 1607 | using iterator_category = std::input_iterator_tag; |
| 1608 | |
| 1609 | filtered_category_iterator() = default; |
| 1610 | explicit filtered_category_iterator(ObjCCategoryDecl *Current) |
| 1611 | : Current(Current) { |
| 1612 | findAcceptableCategory(); |
| 1613 | } |
| 1614 | |
| 1615 | reference operator*() const { return Current; } |
| 1616 | pointer operator->() const { return Current; } |
| 1617 | |
| 1618 | filtered_category_iterator &operator++(); |
| 1619 | |
| 1620 | filtered_category_iterator operator++(int) { |
| 1621 | filtered_category_iterator Tmp = *this; |
| 1622 | ++(*this); |
| 1623 | return Tmp; |
| 1624 | } |
| 1625 | |
| 1626 | friend bool operator==(filtered_category_iterator X, |
| 1627 | filtered_category_iterator Y) { |
| 1628 | return X.Current == Y.Current; |
| 1629 | } |
| 1630 | |
| 1631 | friend bool operator!=(filtered_category_iterator X, |
| 1632 | filtered_category_iterator Y) { |
| 1633 | return X.Current != Y.Current; |
| 1634 | } |
| 1635 | }; |
| 1636 | |
| 1637 | private: |
| 1638 | |
| 1639 | |
| 1640 | |
| 1641 | static bool isVisibleCategory(ObjCCategoryDecl *Cat); |
| 1642 | |
| 1643 | public: |
| 1644 | |
| 1645 | |
| 1646 | using visible_categories_iterator = |
| 1647 | filtered_category_iterator<isVisibleCategory>; |
| 1648 | |
| 1649 | using visible_categories_range = |
| 1650 | llvm::iterator_range<visible_categories_iterator>; |
| 1651 | |
| 1652 | visible_categories_range visible_categories() const { |
| 1653 | return visible_categories_range(visible_categories_begin(), |
| 1654 | visible_categories_end()); |
| 1655 | } |
| 1656 | |
| 1657 | |
| 1658 | |
| 1659 | visible_categories_iterator visible_categories_begin() const { |
| 1660 | return visible_categories_iterator(getCategoryListRaw()); |
| 1661 | } |
| 1662 | |
| 1663 | |
| 1664 | visible_categories_iterator visible_categories_end() const { |
| 1665 | return visible_categories_iterator(); |
| 1666 | } |
| 1667 | |
| 1668 | |
| 1669 | bool visible_categories_empty() const { |
| 1670 | return visible_categories_begin() == visible_categories_end(); |
| 1671 | } |
| 1672 | |
| 1673 | private: |
| 1674 | |
| 1675 | |
| 1676 | |
| 1677 | static bool isKnownCategory(ObjCCategoryDecl *) { return true; } |
| 1678 | |
| 1679 | public: |
| 1680 | |
| 1681 | |
| 1682 | using known_categories_iterator = filtered_category_iterator<isKnownCategory>; |
| 1683 | using known_categories_range = |
| 1684 | llvm::iterator_range<known_categories_iterator>; |
| 1685 | |
| 1686 | known_categories_range known_categories() const { |
| 1687 | return known_categories_range(known_categories_begin(), |
| 1688 | known_categories_end()); |
| 1689 | } |
| 1690 | |
| 1691 | |
| 1692 | |
| 1693 | known_categories_iterator known_categories_begin() const { |
| 1694 | return known_categories_iterator(getCategoryListRaw()); |
| 1695 | } |
| 1696 | |
| 1697 | |
| 1698 | known_categories_iterator known_categories_end() const { |
| 1699 | return known_categories_iterator(); |
| 1700 | } |
| 1701 | |
| 1702 | |
| 1703 | bool known_categories_empty() const { |
| 1704 | return known_categories_begin() == known_categories_end(); |
| 1705 | } |
| 1706 | |
| 1707 | private: |
| 1708 | |
| 1709 | |
| 1710 | |
| 1711 | static bool isVisibleExtension(ObjCCategoryDecl *Cat); |
| 1712 | |
| 1713 | public: |
| 1714 | |
| 1715 | |
| 1716 | using visible_extensions_iterator = |
| 1717 | filtered_category_iterator<isVisibleExtension>; |
| 1718 | |
| 1719 | using visible_extensions_range = |
| 1720 | llvm::iterator_range<visible_extensions_iterator>; |
| 1721 | |
| 1722 | visible_extensions_range visible_extensions() const { |
| 1723 | return visible_extensions_range(visible_extensions_begin(), |
| 1724 | visible_extensions_end()); |
| 1725 | } |
| 1726 | |
| 1727 | |
| 1728 | |
| 1729 | visible_extensions_iterator visible_extensions_begin() const { |
| 1730 | return visible_extensions_iterator(getCategoryListRaw()); |
| 1731 | } |
| 1732 | |
| 1733 | |
| 1734 | visible_extensions_iterator visible_extensions_end() const { |
| 1735 | return visible_extensions_iterator(); |
| 1736 | } |
| 1737 | |
| 1738 | |
| 1739 | bool visible_extensions_empty() const { |
| 1740 | return visible_extensions_begin() == visible_extensions_end(); |
| 1741 | } |
| 1742 | |
| 1743 | private: |
| 1744 | |
| 1745 | |
| 1746 | |
| 1747 | static bool isKnownExtension(ObjCCategoryDecl *Cat); |
| 1748 | |
| 1749 | public: |
| 1750 | friend class ASTDeclReader; |
| 1751 | friend class ASTDeclWriter; |
| 1752 | friend class ASTReader; |
| 1753 | |
| 1754 | |
| 1755 | using known_extensions_iterator = |
| 1756 | filtered_category_iterator<isKnownExtension>; |
| 1757 | using known_extensions_range = |
| 1758 | llvm::iterator_range<known_extensions_iterator>; |
| 1759 | |
| 1760 | known_extensions_range known_extensions() const { |
| 1761 | return known_extensions_range(known_extensions_begin(), |
| 1762 | known_extensions_end()); |
| 1763 | } |
| 1764 | |
| 1765 | |
| 1766 | |
| 1767 | known_extensions_iterator known_extensions_begin() const { |
| 1768 | return known_extensions_iterator(getCategoryListRaw()); |
| 1769 | } |
| 1770 | |
| 1771 | |
| 1772 | known_extensions_iterator known_extensions_end() const { |
| 1773 | return known_extensions_iterator(); |
| 1774 | } |
| 1775 | |
| 1776 | |
| 1777 | bool known_extensions_empty() const { |
| 1778 | return known_extensions_begin() == known_extensions_end(); |
| 1779 | } |
| 1780 | |
| 1781 | |
| 1782 | |
| 1783 | ObjCCategoryDecl* getCategoryListRaw() const { |
| 1784 | |
| 1785 | if (!hasDefinition()) |
| 1786 | return nullptr; |
| 1787 | |
| 1788 | if (data().ExternallyCompleted) |
| 1789 | LoadExternalDefinition(); |
| 1790 | |
| 1791 | return data().CategoryList; |
| 1792 | } |
| 1793 | |
| 1794 | |
| 1795 | |
| 1796 | void setCategoryListRaw(ObjCCategoryDecl *category) { |
| 1797 | data().CategoryList = category; |
| 1798 | } |
| 1799 | |
| 1800 | ObjCPropertyDecl |
| 1801 | *FindPropertyVisibleInPrimaryClass(IdentifierInfo *PropertyId, |
| 1802 | ObjCPropertyQueryKind QueryKind) const; |
| 1803 | |
| 1804 | void collectPropertiesToImplement(PropertyMap &PM, |
| 1805 | PropertyDeclOrder &PO) const override; |
| 1806 | |
| 1807 | |
| 1808 | |
| 1809 | bool isSuperClassOf(const ObjCInterfaceDecl *I) const { |
| 1810 | |
| 1811 | while (I != nullptr) { |
| 1812 | if (declaresSameEntity(this, I)) |
| 1813 | return true; |
| 1814 | |
| 1815 | I = I->getSuperClass(); |
| 1816 | } |
| 1817 | return false; |
| 1818 | } |
| 1819 | |
| 1820 | |
| 1821 | |
| 1822 | bool isArcWeakrefUnavailable() const; |
| 1823 | |
| 1824 | |
| 1825 | |
| 1826 | |
| 1827 | const ObjCInterfaceDecl *isObjCRequiresPropertyDefs() const; |
| 1828 | |
| 1829 | ObjCIvarDecl *lookupInstanceVariable(IdentifierInfo *IVarName, |
| 1830 | ObjCInterfaceDecl *&ClassDeclared); |
| 1831 | ObjCIvarDecl *lookupInstanceVariable(IdentifierInfo *IVarName) { |
| 1832 | ObjCInterfaceDecl *ClassDeclared; |
| 1833 | return lookupInstanceVariable(IVarName, ClassDeclared); |
| 1834 | } |
| 1835 | |
| 1836 | ObjCProtocolDecl *lookupNestedProtocol(IdentifierInfo *Name); |
| 1837 | |
| 1838 | |
| 1839 | |
| 1840 | ObjCMethodDecl *lookupMethod(Selector Sel, bool isInstance, |
| 1841 | bool shallowCategoryLookup = false, |
| 1842 | bool followSuper = true, |
| 1843 | const ObjCCategoryDecl *C = nullptr) const; |
| 1844 | |
| 1845 | |
| 1846 | ObjCMethodDecl *lookupInstanceMethod(Selector Sel) const { |
| 1847 | return lookupMethod(Sel, true); |
| 1848 | } |
| 1849 | |
| 1850 | |
| 1851 | ObjCMethodDecl *lookupClassMethod(Selector Sel) const { |
| 1852 | return lookupMethod(Sel, false); |
| 1853 | } |
| 1854 | |
| 1855 | ObjCInterfaceDecl *lookupInheritedClass(const IdentifierInfo *ICName); |
| 1856 | |
| 1857 | |
| 1858 | ObjCMethodDecl *lookupPrivateMethod(const Selector &Sel, |
| 1859 | bool Instance=true) const; |
| 1860 | |
| 1861 | ObjCMethodDecl *lookupPrivateClassMethod(const Selector &Sel) { |
| 1862 | return lookupPrivateMethod(Sel, false); |
| 1863 | } |
| 1864 | |
| 1865 | |
| 1866 | |
| 1867 | |
| 1868 | ObjCMethodDecl *lookupPropertyAccessor(const Selector Sel, |
| 1869 | const ObjCCategoryDecl *Cat, |
| 1870 | bool IsClassProperty) const { |
| 1871 | return lookupMethod(Sel, !IsClassProperty, |
| 1872 | false, |
| 1873 | true , |
| 1874 | Cat); |
| 1875 | } |
| 1876 | |
| 1877 | SourceLocation getEndOfDefinitionLoc() const { |
| 1878 | if (!hasDefinition()) |
| 1879 | return getLocation(); |
| 1880 | |
| 1881 | return data().EndLoc; |
| 1882 | } |
| 1883 | |
| 1884 | void setEndOfDefinitionLoc(SourceLocation LE) { data().EndLoc = LE; } |
| 1885 | |
| 1886 | |
| 1887 | SourceLocation getSuperClassLoc() const; |
| 1888 | |
| 1889 | |
| 1890 | |
| 1891 | |
| 1892 | bool isImplicitInterfaceDecl() const { |
| 1893 | return hasDefinition() ? data().Definition->isImplicit() : isImplicit(); |
| 1894 | } |
| 1895 | |
| 1896 | |
| 1897 | |
| 1898 | |
| 1899 | bool ClassImplementsProtocol(ObjCProtocolDecl *lProto, |
| 1900 | bool lookupCategory, |
| 1901 | bool RHSIsQualifiedID = false); |
| 1902 | |
| 1903 | using redecl_range = redeclarable_base::redecl_range; |
| 1904 | using redecl_iterator = redeclarable_base::redecl_iterator; |
| 1905 | |
| 1906 | using redeclarable_base::redecls_begin; |
| 1907 | using redeclarable_base::redecls_end; |
| 1908 | using redeclarable_base::redecls; |
| 1909 | using redeclarable_base::getPreviousDecl; |
| 1910 | using redeclarable_base::getMostRecentDecl; |
| 1911 | using redeclarable_base::isFirstDecl; |
| 1912 | |
| 1913 | |
| 1914 | ObjCInterfaceDecl *getCanonicalDecl() override { return getFirstDecl(); } |
| 1915 | const ObjCInterfaceDecl *getCanonicalDecl() const { return getFirstDecl(); } |
| 1916 | |
| 1917 | |
| 1918 | const Type *getTypeForDecl() const { return TypeForDecl; } |
| 1919 | void setTypeForDecl(const Type *TD) const { TypeForDecl = TD; } |
| 1920 | |
| 1921 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
| 1922 | static bool classofKind(Kind K) { return K == ObjCInterface; } |
| 1923 | |
| 1924 | private: |
| 1925 | const ObjCInterfaceDecl *findInterfaceWithDesignatedInitializers() const; |
| 1926 | bool inheritsDesignatedInitializers() const; |
| 1927 | }; |
| 1928 | |
| 1929 | |
| 1930 | |
| 1931 | |
| 1932 | |
| 1933 | |
| 1934 | |
| 1935 | |
| 1936 | |
| 1937 | |
| 1938 | |
| 1939 | |
| 1940 | |
| 1941 | |
| 1942 | |
| 1943 | |
| 1944 | class ObjCIvarDecl : public FieldDecl { |
| 1945 | void anchor() override; |
| 1946 | |
| 1947 | public: |
| 1948 | enum AccessControl { |
| 1949 | None, Private, Protected, Public, Package |
| 1950 | }; |
| 1951 | |
| 1952 | private: |
| 1953 | ObjCIvarDecl(ObjCContainerDecl *DC, SourceLocation StartLoc, |
| 1954 | SourceLocation IdLoc, IdentifierInfo *Id, |
| 1955 | QualType T, TypeSourceInfo *TInfo, AccessControl ac, Expr *BW, |
| 1956 | bool synthesized) |
| 1957 | : FieldDecl(ObjCIvar, DC, StartLoc, IdLoc, Id, T, TInfo, BW, |
| 1958 | , ICIS_NoInit), |
| 1959 | DeclAccess(ac), Synthesized(synthesized) {} |
| 1960 | |
| 1961 | public: |
| 1962 | static ObjCIvarDecl *Create(ASTContext &C, ObjCContainerDecl *DC, |
| 1963 | SourceLocation StartLoc, SourceLocation IdLoc, |
| 1964 | IdentifierInfo *Id, QualType T, |
| 1965 | TypeSourceInfo *TInfo, |
| 1966 | AccessControl ac, Expr *BW = nullptr, |
| 1967 | bool synthesized=false); |
| 1968 | |
| 1969 | static ObjCIvarDecl *CreateDeserialized(ASTContext &C, unsigned ID); |
| 1970 | |
| 1971 | |
| 1972 | |
| 1973 | |
| 1974 | |
| 1975 | const ObjCInterfaceDecl *getContainingInterface() const; |
| 1976 | |
| 1977 | ObjCIvarDecl *getNextIvar() { return NextIvar; } |
| 1978 | const ObjCIvarDecl *getNextIvar() const { return NextIvar; } |
| 1979 | void setNextIvar(ObjCIvarDecl *ivar) { NextIvar = ivar; } |
| 1980 | |
| 1981 | void setAccessControl(AccessControl ac) { DeclAccess = ac; } |
| 1982 | |
| 1983 | AccessControl getAccessControl() const { return AccessControl(DeclAccess); } |
| 1984 | |
| 1985 | AccessControl getCanonicalAccessControl() const { |
| 1986 | return DeclAccess == None ? Protected : AccessControl(DeclAccess); |
| 1987 | } |
| 1988 | |
| 1989 | void setSynthesize(bool synth) { Synthesized = synth; } |
| 1990 | bool getSynthesize() const { return Synthesized; } |
| 1991 | |
| 1992 | |
| 1993 | |
| 1994 | QualType getUsageType(QualType objectType) const; |
| 1995 | |
| 1996 | |
| 1997 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
| 1998 | static bool classofKind(Kind K) { return K == ObjCIvar; } |
| 1999 | |
| 2000 | private: |
| 2001 | |
| 2002 | |
| 2003 | ObjCIvarDecl *NextIvar = nullptr; |
| 2004 | |
| 2005 | |
| 2006 | unsigned DeclAccess : 3; |
| 2007 | unsigned Synthesized : 1; |
| 2008 | }; |
| 2009 | |
| 2010 | |
| 2011 | class ObjCAtDefsFieldDecl : public FieldDecl { |
| 2012 | ObjCAtDefsFieldDecl(DeclContext *DC, SourceLocation StartLoc, |
| 2013 | SourceLocation IdLoc, IdentifierInfo *Id, |
| 2014 | QualType T, Expr *BW) |
| 2015 | : FieldDecl(ObjCAtDefsField, DC, StartLoc, IdLoc, Id, T, |
| 2016 | , |
| 2017 | BW, , ICIS_NoInit) {} |
| 2018 | |
| 2019 | void anchor() override; |
| 2020 | |
| 2021 | public: |
| 2022 | static ObjCAtDefsFieldDecl *Create(ASTContext &C, DeclContext *DC, |
| 2023 | SourceLocation StartLoc, |
| 2024 | SourceLocation IdLoc, IdentifierInfo *Id, |
| 2025 | QualType T, Expr *BW); |
| 2026 | |
| 2027 | static ObjCAtDefsFieldDecl *CreateDeserialized(ASTContext &C, unsigned ID); |
| 2028 | |
| 2029 | |
| 2030 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
| 2031 | static bool classofKind(Kind K) { return K == ObjCAtDefsField; } |
| 2032 | }; |
| 2033 | |
| 2034 | |
| 2035 | |
| 2036 | |
| 2037 | |
| 2038 | |
| 2039 | |
| 2040 | |
| 2041 | |
| 2042 | |
| 2043 | |
| 2044 | |
| 2045 | |
| 2046 | |
| 2047 | |
| 2048 | |
| 2049 | |
| 2050 | |
| 2051 | |
| 2052 | |
| 2053 | |
| 2054 | |
| 2055 | |
| 2056 | |
| 2057 | |
| 2058 | |
| 2059 | |
| 2060 | |
| 2061 | |
| 2062 | |
| 2063 | class ObjCProtocolDecl : public ObjCContainerDecl, |
| 2064 | public Redeclarable<ObjCProtocolDecl> { |
| 2065 | struct DefinitionData { |
| 2066 | |
| 2067 | ObjCProtocolDecl *Definition; |
| 2068 | |
| 2069 | |
| 2070 | ObjCProtocolList ReferencedProtocols; |
| 2071 | }; |
| 2072 | |
| 2073 | |
| 2074 | |
| 2075 | |
| 2076 | |
| 2077 | |
| 2078 | llvm::PointerIntPair<DefinitionData *, 1, bool> Data; |
| 2079 | |
| 2080 | ObjCProtocolDecl(ASTContext &C, DeclContext *DC, IdentifierInfo *Id, |
| 2081 | SourceLocation nameLoc, SourceLocation atStartLoc, |
| 2082 | ObjCProtocolDecl *PrevDecl); |
| 2083 | |
| 2084 | void anchor() override; |
| 2085 | |
| 2086 | DefinitionData &data() const { |
| 2087 | (0) . __assert_fail ("Data.getPointer() && \"Objective-C protocol has no definition!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/DeclObjC.h", 2087, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(Data.getPointer() && "Objective-C protocol has no definition!"); |
| 2088 | return *Data.getPointer(); |
| 2089 | } |
| 2090 | |
| 2091 | void allocateDefinitionData(); |
| 2092 | |
| 2093 | using redeclarable_base = Redeclarable<ObjCProtocolDecl>; |
| 2094 | |
| 2095 | ObjCProtocolDecl *getNextRedeclarationImpl() override { |
| 2096 | return getNextRedeclaration(); |
| 2097 | } |
| 2098 | |
| 2099 | ObjCProtocolDecl *getPreviousDeclImpl() override { |
| 2100 | return getPreviousDecl(); |
| 2101 | } |
| 2102 | |
| 2103 | ObjCProtocolDecl *getMostRecentDeclImpl() override { |
| 2104 | return getMostRecentDecl(); |
| 2105 | } |
| 2106 | |
| 2107 | public: |
| 2108 | friend class ASTDeclReader; |
| 2109 | friend class ASTDeclWriter; |
| 2110 | friend class ASTReader; |
| 2111 | |
| 2112 | static ObjCProtocolDecl *Create(ASTContext &C, DeclContext *DC, |
| 2113 | IdentifierInfo *Id, |
| 2114 | SourceLocation nameLoc, |
| 2115 | SourceLocation atStartLoc, |
| 2116 | ObjCProtocolDecl *PrevDecl); |
| 2117 | |
| 2118 | static ObjCProtocolDecl *CreateDeserialized(ASTContext &C, unsigned ID); |
| 2119 | |
| 2120 | const ObjCProtocolList &getReferencedProtocols() const { |
| 2121 | (0) . __assert_fail ("hasDefinition() && \"No definition available!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/DeclObjC.h", 2121, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(hasDefinition() && "No definition available!"); |
| 2122 | return data().ReferencedProtocols; |
| 2123 | } |
| 2124 | |
| 2125 | using protocol_iterator = ObjCProtocolList::iterator; |
| 2126 | using protocol_range = llvm::iterator_range<protocol_iterator>; |
| 2127 | |
| 2128 | protocol_range protocols() const { |
| 2129 | return protocol_range(protocol_begin(), protocol_end()); |
| 2130 | } |
| 2131 | |
| 2132 | protocol_iterator protocol_begin() const { |
| 2133 | if (!hasDefinition()) |
| 2134 | return protocol_iterator(); |
| 2135 | |
| 2136 | return data().ReferencedProtocols.begin(); |
| 2137 | } |
| 2138 | |
| 2139 | protocol_iterator protocol_end() const { |
| 2140 | if (!hasDefinition()) |
| 2141 | return protocol_iterator(); |
| 2142 | |
| 2143 | return data().ReferencedProtocols.end(); |
| 2144 | } |
| 2145 | |
| 2146 | using protocol_loc_iterator = ObjCProtocolList::loc_iterator; |
| 2147 | using protocol_loc_range = llvm::iterator_range<protocol_loc_iterator>; |
| 2148 | |
| 2149 | protocol_loc_range protocol_locs() const { |
| 2150 | return protocol_loc_range(protocol_loc_begin(), protocol_loc_end()); |
| 2151 | } |
| 2152 | |
| 2153 | protocol_loc_iterator protocol_loc_begin() const { |
| 2154 | if (!hasDefinition()) |
| 2155 | return protocol_loc_iterator(); |
| 2156 | |
| 2157 | return data().ReferencedProtocols.loc_begin(); |
| 2158 | } |
| 2159 | |
| 2160 | protocol_loc_iterator protocol_loc_end() const { |
| 2161 | if (!hasDefinition()) |
| 2162 | return protocol_loc_iterator(); |
| 2163 | |
| 2164 | return data().ReferencedProtocols.loc_end(); |
| 2165 | } |
| 2166 | |
| 2167 | unsigned protocol_size() const { |
| 2168 | if (!hasDefinition()) |
| 2169 | return 0; |
| 2170 | |
| 2171 | return data().ReferencedProtocols.size(); |
| 2172 | } |
| 2173 | |
| 2174 | |
| 2175 | |
| 2176 | void setProtocolList(ObjCProtocolDecl *const*List, unsigned Num, |
| 2177 | const SourceLocation *Locs, ASTContext &C) { |
| 2178 | (0) . __assert_fail ("hasDefinition() && \"Protocol is not defined\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/DeclObjC.h", 2178, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(hasDefinition() && "Protocol is not defined"); |
| 2179 | data().ReferencedProtocols.set(List, Num, Locs, C); |
| 2180 | } |
| 2181 | |
| 2182 | ObjCProtocolDecl *lookupProtocolNamed(IdentifierInfo *PName); |
| 2183 | |
| 2184 | |
| 2185 | |
| 2186 | ObjCMethodDecl *lookupMethod(Selector Sel, bool isInstance) const; |
| 2187 | |
| 2188 | ObjCMethodDecl *lookupInstanceMethod(Selector Sel) const { |
| 2189 | return lookupMethod(Sel, true); |
| 2190 | } |
| 2191 | |
| 2192 | ObjCMethodDecl *lookupClassMethod(Selector Sel) const { |
| 2193 | return lookupMethod(Sel, false); |
| 2194 | } |
| 2195 | |
| 2196 | |
| 2197 | bool hasDefinition() const { |
| 2198 | |
| 2199 | |
| 2200 | |
| 2201 | |
| 2202 | if (!Data.getOpaqueValue()) |
| 2203 | getMostRecentDecl(); |
| 2204 | |
| 2205 | return Data.getPointer(); |
| 2206 | } |
| 2207 | |
| 2208 | |
| 2209 | ObjCProtocolDecl *getDefinition() { |
| 2210 | return hasDefinition()? Data.getPointer()->Definition : nullptr; |
| 2211 | } |
| 2212 | |
| 2213 | |
| 2214 | const ObjCProtocolDecl *getDefinition() const { |
| 2215 | return hasDefinition()? Data.getPointer()->Definition : nullptr; |
| 2216 | } |
| 2217 | |
| 2218 | |
| 2219 | |
| 2220 | bool isThisDeclarationADefinition() const { |
| 2221 | return getDefinition() == this; |
| 2222 | } |
| 2223 | |
| 2224 | |
| 2225 | void startDefinition(); |
| 2226 | |
| 2227 | |
| 2228 | |
| 2229 | StringRef getObjCRuntimeNameAsString() const; |
| 2230 | |
| 2231 | SourceRange getSourceRange() const override LLVM_READONLY { |
| 2232 | if (isThisDeclarationADefinition()) |
| 2233 | return ObjCContainerDecl::getSourceRange(); |
| 2234 | |
| 2235 | return SourceRange(getAtStartLoc(), getLocation()); |
| 2236 | } |
| 2237 | |
| 2238 | using redecl_range = redeclarable_base::redecl_range; |
| 2239 | using redecl_iterator = redeclarable_base::redecl_iterator; |
| 2240 | |
| 2241 | using redeclarable_base::redecls_begin; |
| 2242 | using redeclarable_base::redecls_end; |
| 2243 | using redeclarable_base::redecls; |
| 2244 | using redeclarable_base::getPreviousDecl; |
| 2245 | using redeclarable_base::getMostRecentDecl; |
| 2246 | using redeclarable_base::isFirstDecl; |
| 2247 | |
| 2248 | |
| 2249 | ObjCProtocolDecl *getCanonicalDecl() override { return getFirstDecl(); } |
| 2250 | const ObjCProtocolDecl *getCanonicalDecl() const { return getFirstDecl(); } |
| 2251 | |
| 2252 | void collectPropertiesToImplement(PropertyMap &PM, |
| 2253 | PropertyDeclOrder &PO) const override; |
| 2254 | |
| 2255 | void collectInheritedProtocolProperties(const ObjCPropertyDecl *Property, |
| 2256 | ProtocolPropertySet &PS, |
| 2257 | PropertyDeclOrder &PO) const; |
| 2258 | |
| 2259 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
| 2260 | static bool classofKind(Kind K) { return K == ObjCProtocol; } |
| 2261 | }; |
| 2262 | |
| 2263 | |
| 2264 | |
| 2265 | |
| 2266 | |
| 2267 | |
| 2268 | |
| 2269 | |
| 2270 | |
| 2271 | |
| 2272 | |
| 2273 | |
| 2274 | |
| 2275 | |
| 2276 | |
| 2277 | |
| 2278 | |
| 2279 | class ObjCCategoryDecl : public ObjCContainerDecl { |
| 2280 | |
| 2281 | ObjCInterfaceDecl *ClassInterface; |
| 2282 | |
| 2283 | |
| 2284 | ObjCTypeParamList *TypeParamList = nullptr; |
| 2285 | |
| 2286 | |
| 2287 | ObjCProtocolList ReferencedProtocols; |
| 2288 | |
| 2289 | |
| 2290 | |
| 2291 | ObjCCategoryDecl *NextClassCategory = nullptr; |
| 2292 | |
| 2293 | |
| 2294 | SourceLocation CategoryNameLoc; |
| 2295 | |
| 2296 | |
| 2297 | SourceLocation IvarLBraceLoc; |
| 2298 | SourceLocation IvarRBraceLoc; |
| 2299 | |
| 2300 | ObjCCategoryDecl(DeclContext *DC, SourceLocation AtLoc, |
| 2301 | SourceLocation ClassNameLoc, SourceLocation CategoryNameLoc, |
| 2302 | IdentifierInfo *Id, ObjCInterfaceDecl *IDecl, |
| 2303 | ObjCTypeParamList *typeParamList, |
| 2304 | SourceLocation IvarLBraceLoc = SourceLocation(), |
| 2305 | SourceLocation IvarRBraceLoc = SourceLocation()); |
| 2306 | |
| 2307 | void anchor() override; |
| 2308 | |
| 2309 | public: |
| 2310 | friend class ASTDeclReader; |
| 2311 | friend class ASTDeclWriter; |
| 2312 | |
| 2313 | static ObjCCategoryDecl *Create(ASTContext &C, DeclContext *DC, |
| 2314 | SourceLocation AtLoc, |
| 2315 | SourceLocation ClassNameLoc, |
| 2316 | SourceLocation CategoryNameLoc, |
| 2317 | IdentifierInfo *Id, |
| 2318 | ObjCInterfaceDecl *IDecl, |
| 2319 | ObjCTypeParamList *typeParamList, |
| 2320 | SourceLocation IvarLBraceLoc=SourceLocation(), |
| 2321 | SourceLocation IvarRBraceLoc=SourceLocation()); |
| 2322 | static ObjCCategoryDecl *CreateDeserialized(ASTContext &C, unsigned ID); |
| 2323 | |
| 2324 | ObjCInterfaceDecl *getClassInterface() { return ClassInterface; } |
| 2325 | const ObjCInterfaceDecl *getClassInterface() const { return ClassInterface; } |
| 2326 | |
| 2327 | |
| 2328 | |
| 2329 | ObjCTypeParamList *getTypeParamList() const { return TypeParamList; } |
| 2330 | |
| 2331 | |
| 2332 | |
| 2333 | |
| 2334 | |
| 2335 | void setTypeParamList(ObjCTypeParamList *TPL); |
| 2336 | |
| 2337 | |
| 2338 | ObjCCategoryImplDecl *getImplementation() const; |
| 2339 | void setImplementation(ObjCCategoryImplDecl *ImplD); |
| 2340 | |
| 2341 | |
| 2342 | |
| 2343 | void setProtocolList(ObjCProtocolDecl *const*List, unsigned Num, |
| 2344 | const SourceLocation *Locs, ASTContext &C) { |
| 2345 | ReferencedProtocols.set(List, Num, Locs, C); |
| 2346 | } |
| 2347 | |
| 2348 | const ObjCProtocolList &getReferencedProtocols() const { |
| 2349 | return ReferencedProtocols; |
| 2350 | } |
| 2351 | |
| 2352 | using protocol_iterator = ObjCProtocolList::iterator; |
| 2353 | using protocol_range = llvm::iterator_range<protocol_iterator>; |
| 2354 | |
| 2355 | protocol_range protocols() const { |
| 2356 | return protocol_range(protocol_begin(), protocol_end()); |
| 2357 | } |
| 2358 | |
| 2359 | protocol_iterator protocol_begin() const { |
| 2360 | return ReferencedProtocols.begin(); |
| 2361 | } |
| 2362 | |
| 2363 | protocol_iterator protocol_end() const { return ReferencedProtocols.end(); } |
| 2364 | unsigned protocol_size() const { return ReferencedProtocols.size(); } |
| 2365 | |
| 2366 | using protocol_loc_iterator = ObjCProtocolList::loc_iterator; |
| 2367 | using protocol_loc_range = llvm::iterator_range<protocol_loc_iterator>; |
| 2368 | |
| 2369 | protocol_loc_range protocol_locs() const { |
| 2370 | return protocol_loc_range(protocol_loc_begin(), protocol_loc_end()); |
| 2371 | } |
| 2372 | |
| 2373 | protocol_loc_iterator protocol_loc_begin() const { |
| 2374 | return ReferencedProtocols.loc_begin(); |
| 2375 | } |
| 2376 | |
| 2377 | protocol_loc_iterator protocol_loc_end() const { |
| 2378 | return ReferencedProtocols.loc_end(); |
| 2379 | } |
| 2380 | |
| 2381 | ObjCCategoryDecl *getNextClassCategory() const { return NextClassCategory; } |
| 2382 | |
| 2383 | |
| 2384 | |
| 2385 | ObjCCategoryDecl *getNextClassCategoryRaw() const { |
| 2386 | return NextClassCategory; |
| 2387 | } |
| 2388 | |
| 2389 | bool IsClassExtension() const { return getIdentifier() == nullptr; } |
| 2390 | |
| 2391 | using ivar_iterator = specific_decl_iterator<ObjCIvarDecl>; |
| 2392 | using ivar_range = llvm::iterator_range<specific_decl_iterator<ObjCIvarDecl>>; |
| 2393 | |
| 2394 | ivar_range ivars() const { return ivar_range(ivar_begin(), ivar_end()); } |
| 2395 | |
| 2396 | ivar_iterator ivar_begin() const { |
| 2397 | return ivar_iterator(decls_begin()); |
| 2398 | } |
| 2399 | |
| 2400 | ivar_iterator ivar_end() const { |
| 2401 | return ivar_iterator(decls_end()); |
| 2402 | } |
| 2403 | |
| 2404 | unsigned ivar_size() const { |
| 2405 | return std::distance(ivar_begin(), ivar_end()); |
| 2406 | } |
| 2407 | |
| 2408 | bool ivar_empty() const { |
| 2409 | return ivar_begin() == ivar_end(); |
| 2410 | } |
| 2411 | |
| 2412 | SourceLocation getCategoryNameLoc() const { return CategoryNameLoc; } |
| 2413 | void setCategoryNameLoc(SourceLocation Loc) { CategoryNameLoc = Loc; } |
| 2414 | |
| 2415 | void setIvarLBraceLoc(SourceLocation Loc) { IvarLBraceLoc = Loc; } |
| 2416 | SourceLocation getIvarLBraceLoc() const { return IvarLBraceLoc; } |
| 2417 | void setIvarRBraceLoc(SourceLocation Loc) { IvarRBraceLoc = Loc; } |
| 2418 | SourceLocation getIvarRBraceLoc() const { return IvarRBraceLoc; } |
| 2419 | |
| 2420 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
| 2421 | static bool classofKind(Kind K) { return K == ObjCCategory; } |
| 2422 | }; |
| 2423 | |
| 2424 | class ObjCImplDecl : public ObjCContainerDecl { |
| 2425 | |
| 2426 | ObjCInterfaceDecl *ClassInterface; |
| 2427 | |
| 2428 | void anchor() override; |
| 2429 | |
| 2430 | protected: |
| 2431 | ObjCImplDecl(Kind DK, DeclContext *DC, |
| 2432 | ObjCInterfaceDecl *classInterface, |
| 2433 | IdentifierInfo *Id, |
| 2434 | SourceLocation nameLoc, SourceLocation atStartLoc) |
| 2435 | : ObjCContainerDecl(DK, DC, Id, nameLoc, atStartLoc), |
| 2436 | ClassInterface(classInterface) {} |
| 2437 | |
| 2438 | public: |
| 2439 | const ObjCInterfaceDecl *getClassInterface() const { return ClassInterface; } |
| 2440 | ObjCInterfaceDecl *getClassInterface() { return ClassInterface; } |
| 2441 | void setClassInterface(ObjCInterfaceDecl *IFace); |
| 2442 | |
| 2443 | void addInstanceMethod(ObjCMethodDecl *method) { |
| 2444 | |
| 2445 | method->setLexicalDeclContext(this); |
| 2446 | addDecl(method); |
| 2447 | } |
| 2448 | |
| 2449 | void addClassMethod(ObjCMethodDecl *method) { |
| 2450 | |
| 2451 | method->setLexicalDeclContext(this); |
| 2452 | addDecl(method); |
| 2453 | } |
| 2454 | |
| 2455 | void addPropertyImplementation(ObjCPropertyImplDecl *property); |
| 2456 | |
| 2457 | ObjCPropertyImplDecl *FindPropertyImplDecl(IdentifierInfo *propertyId, |
| 2458 | ObjCPropertyQueryKind queryKind) const; |
| 2459 | ObjCPropertyImplDecl *FindPropertyImplIvarDecl(IdentifierInfo *ivarId) const; |
| 2460 | |
| 2461 | |
| 2462 | using propimpl_iterator = specific_decl_iterator<ObjCPropertyImplDecl>; |
| 2463 | using propimpl_range = |
| 2464 | llvm::iterator_range<specific_decl_iterator<ObjCPropertyImplDecl>>; |
| 2465 | |
| 2466 | propimpl_range property_impls() const { |
| 2467 | return propimpl_range(propimpl_begin(), propimpl_end()); |
| 2468 | } |
| 2469 | |
| 2470 | propimpl_iterator propimpl_begin() const { |
| 2471 | return propimpl_iterator(decls_begin()); |
| 2472 | } |
| 2473 | |
| 2474 | propimpl_iterator propimpl_end() const { |
| 2475 | return propimpl_iterator(decls_end()); |
| 2476 | } |
| 2477 | |
| 2478 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
| 2479 | |
| 2480 | static bool classofKind(Kind K) { |
| 2481 | return K >= firstObjCImpl && K <= lastObjCImpl; |
| 2482 | } |
| 2483 | }; |
| 2484 | |
| 2485 | |
| 2486 | |
| 2487 | |
| 2488 | |
| 2489 | |
| 2490 | |
| 2491 | |
| 2492 | |
| 2493 | |
| 2494 | |
| 2495 | |
| 2496 | |
| 2497 | |
| 2498 | class ObjCCategoryImplDecl : public ObjCImplDecl { |
| 2499 | |
| 2500 | SourceLocation CategoryNameLoc; |
| 2501 | |
| 2502 | ObjCCategoryImplDecl(DeclContext *DC, IdentifierInfo *Id, |
| 2503 | ObjCInterfaceDecl *classInterface, |
| 2504 | SourceLocation nameLoc, SourceLocation atStartLoc, |
| 2505 | SourceLocation CategoryNameLoc) |
| 2506 | : ObjCImplDecl(ObjCCategoryImpl, DC, classInterface, Id, |
| 2507 | nameLoc, atStartLoc), |
| 2508 | CategoryNameLoc(CategoryNameLoc) {} |
| 2509 | |
| 2510 | void anchor() override; |
| 2511 | |
| 2512 | public: |
| 2513 | friend class ASTDeclReader; |
| 2514 | friend class ASTDeclWriter; |
| 2515 | |
| 2516 | static ObjCCategoryImplDecl *Create(ASTContext &C, DeclContext *DC, |
| 2517 | IdentifierInfo *Id, |
| 2518 | ObjCInterfaceDecl *classInterface, |
| 2519 | SourceLocation nameLoc, |
| 2520 | SourceLocation atStartLoc, |
| 2521 | SourceLocation CategoryNameLoc); |
| 2522 | static ObjCCategoryImplDecl *CreateDeserialized(ASTContext &C, unsigned ID); |
| 2523 | |
| 2524 | ObjCCategoryDecl *getCategoryDecl() const; |
| 2525 | |
| 2526 | SourceLocation getCategoryNameLoc() const { return CategoryNameLoc; } |
| 2527 | |
| 2528 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
| 2529 | static bool classofKind(Kind K) { return K == ObjCCategoryImpl;} |
| 2530 | }; |
| 2531 | |
| 2532 | raw_ostream &operator<<(raw_ostream &OS, const ObjCCategoryImplDecl &CID); |
| 2533 | |
| 2534 | |
| 2535 | |
| 2536 | |
| 2537 | |
| 2538 | |
| 2539 | |
| 2540 | |
| 2541 | |
| 2542 | |
| 2543 | |
| 2544 | |
| 2545 | |
| 2546 | |
| 2547 | |
| 2548 | |
| 2549 | |
| 2550 | |
| 2551 | class ObjCImplementationDecl : public ObjCImplDecl { |
| 2552 | |
| 2553 | ObjCInterfaceDecl *SuperClass; |
| 2554 | SourceLocation SuperLoc; |
| 2555 | |
| 2556 | |
| 2557 | SourceLocation IvarLBraceLoc; |
| 2558 | SourceLocation IvarRBraceLoc; |
| 2559 | |
| 2560 | |
| 2561 | |
| 2562 | LazyCXXCtorInitializersPtr IvarInitializers; |
| 2563 | unsigned NumIvarInitializers = 0; |
| 2564 | |
| 2565 | |
| 2566 | |
| 2567 | bool HasNonZeroConstructors : 1; |
| 2568 | |
| 2569 | |
| 2570 | bool HasDestructors : 1; |
| 2571 | |
| 2572 | ObjCImplementationDecl(DeclContext *DC, |
| 2573 | ObjCInterfaceDecl *classInterface, |
| 2574 | ObjCInterfaceDecl *superDecl, |
| 2575 | SourceLocation nameLoc, SourceLocation atStartLoc, |
| 2576 | SourceLocation superLoc = SourceLocation(), |
| 2577 | SourceLocation IvarLBraceLoc=SourceLocation(), |
| 2578 | SourceLocation IvarRBraceLoc=SourceLocation()) |
| 2579 | : ObjCImplDecl(ObjCImplementation, DC, classInterface, |
| 2580 | classInterface ? classInterface->getIdentifier() |
| 2581 | : nullptr, |
| 2582 | nameLoc, atStartLoc), |
| 2583 | SuperClass(superDecl), SuperLoc(superLoc), |
| 2584 | IvarLBraceLoc(IvarLBraceLoc), IvarRBraceLoc(IvarRBraceLoc), |
| 2585 | HasNonZeroConstructors(false), HasDestructors(false) {} |
| 2586 | |
| 2587 | void anchor() override; |
| 2588 | |
| 2589 | public: |
| 2590 | friend class ASTDeclReader; |
| 2591 | friend class ASTDeclWriter; |
| 2592 | |
| 2593 | static ObjCImplementationDecl *Create(ASTContext &C, DeclContext *DC, |
| 2594 | ObjCInterfaceDecl *classInterface, |
| 2595 | ObjCInterfaceDecl *superDecl, |
| 2596 | SourceLocation nameLoc, |
| 2597 | SourceLocation atStartLoc, |
| 2598 | SourceLocation superLoc = SourceLocation(), |
| 2599 | SourceLocation IvarLBraceLoc=SourceLocation(), |
| 2600 | SourceLocation IvarRBraceLoc=SourceLocation()); |
| 2601 | |
| 2602 | static ObjCImplementationDecl *CreateDeserialized(ASTContext &C, unsigned ID); |
| 2603 | |
| 2604 | |
| 2605 | using init_iterator = CXXCtorInitializer **; |
| 2606 | |
| 2607 | |
| 2608 | using init_const_iterator = CXXCtorInitializer * const *; |
| 2609 | |
| 2610 | using init_range = llvm::iterator_range<init_iterator>; |
| 2611 | using init_const_range = llvm::iterator_range<init_const_iterator>; |
| 2612 | |
| 2613 | init_range inits() { return init_range(init_begin(), init_end()); } |
| 2614 | |
| 2615 | init_const_range inits() const { |
| 2616 | return init_const_range(init_begin(), init_end()); |
| 2617 | } |
| 2618 | |
| 2619 | |
| 2620 | init_iterator init_begin() { |
| 2621 | const auto *ConstThis = this; |
| 2622 | return const_cast<init_iterator>(ConstThis->init_begin()); |
| 2623 | } |
| 2624 | |
| 2625 | |
| 2626 | init_const_iterator init_begin() const; |
| 2627 | |
| 2628 | |
| 2629 | init_iterator init_end() { |
| 2630 | return init_begin() + NumIvarInitializers; |
| 2631 | } |
| 2632 | |
| 2633 | |
| 2634 | init_const_iterator init_end() const { |
| 2635 | return init_begin() + NumIvarInitializers; |
| 2636 | } |
| 2637 | |
| 2638 | |
| 2639 | unsigned getNumIvarInitializers() const { |
| 2640 | return NumIvarInitializers; |
| 2641 | } |
| 2642 | |
| 2643 | void setNumIvarInitializers(unsigned numNumIvarInitializers) { |
| 2644 | NumIvarInitializers = numNumIvarInitializers; |
| 2645 | } |
| 2646 | |
| 2647 | void setIvarInitializers(ASTContext &C, |
| 2648 | CXXCtorInitializer ** initializers, |
| 2649 | unsigned numInitializers); |
| 2650 | |
| 2651 | |
| 2652 | |
| 2653 | bool hasNonZeroConstructors() const { return HasNonZeroConstructors; } |
| 2654 | void setHasNonZeroConstructors(bool val) { HasNonZeroConstructors = val; } |
| 2655 | |
| 2656 | |
| 2657 | |
| 2658 | bool hasDestructors() const { return HasDestructors; } |
| 2659 | void setHasDestructors(bool val) { HasDestructors = val; } |
| 2660 | |
| 2661 | |
| 2662 | |
| 2663 | IdentifierInfo *getIdentifier() const { |
| 2664 | return getClassInterface()->getIdentifier(); |
| 2665 | } |
| 2666 | |
| 2667 | |
| 2668 | |
| 2669 | |
| 2670 | |
| 2671 | |
| 2672 | StringRef getName() const { |
| 2673 | (0) . __assert_fail ("getIdentifier() && \"Name is not a simple identifier\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/DeclObjC.h", 2673, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(getIdentifier() && "Name is not a simple identifier"); |
| 2674 | return getIdentifier()->getName(); |
| 2675 | } |
| 2676 | |
| 2677 | |
| 2678 | |
| 2679 | |
| 2680 | std::string getNameAsString() const { |
| 2681 | return getName(); |
| 2682 | } |
| 2683 | |
| 2684 | |
| 2685 | |
| 2686 | StringRef getObjCRuntimeNameAsString() const; |
| 2687 | |
| 2688 | const ObjCInterfaceDecl *getSuperClass() const { return SuperClass; } |
| 2689 | ObjCInterfaceDecl *getSuperClass() { return SuperClass; } |
| 2690 | SourceLocation getSuperClassLoc() const { return SuperLoc; } |
| 2691 | |
| 2692 | void setSuperClass(ObjCInterfaceDecl * superCls) { SuperClass = superCls; } |
| 2693 | |
| 2694 | void setIvarLBraceLoc(SourceLocation Loc) { IvarLBraceLoc = Loc; } |
| 2695 | SourceLocation getIvarLBraceLoc() const { return IvarLBraceLoc; } |
| 2696 | void setIvarRBraceLoc(SourceLocation Loc) { IvarRBraceLoc = Loc; } |
| 2697 | SourceLocation getIvarRBraceLoc() const { return IvarRBraceLoc; } |
| 2698 | |
| 2699 | using ivar_iterator = specific_decl_iterator<ObjCIvarDecl>; |
| 2700 | using ivar_range = llvm::iterator_range<specific_decl_iterator<ObjCIvarDecl>>; |
| 2701 | |
| 2702 | ivar_range ivars() const { return ivar_range(ivar_begin(), ivar_end()); } |
| 2703 | |
| 2704 | ivar_iterator ivar_begin() const { |
| 2705 | return ivar_iterator(decls_begin()); |
| 2706 | } |
| 2707 | |
| 2708 | ivar_iterator ivar_end() const { |
| 2709 | return ivar_iterator(decls_end()); |
| 2710 | } |
| 2711 | |
| 2712 | unsigned ivar_size() const { |
| 2713 | return std::distance(ivar_begin(), ivar_end()); |
| 2714 | } |
| 2715 | |
| 2716 | bool ivar_empty() const { |
| 2717 | return ivar_begin() == ivar_end(); |
| 2718 | } |
| 2719 | |
| 2720 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
| 2721 | static bool classofKind(Kind K) { return K == ObjCImplementation; } |
| 2722 | }; |
| 2723 | |
| 2724 | raw_ostream &operator<<(raw_ostream &OS, const ObjCImplementationDecl &ID); |
| 2725 | |
| 2726 | |
| 2727 | |
| 2728 | class ObjCCompatibleAliasDecl : public NamedDecl { |
| 2729 | |
| 2730 | ObjCInterfaceDecl *AliasedClass; |
| 2731 | |
| 2732 | ObjCCompatibleAliasDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id, |
| 2733 | ObjCInterfaceDecl* aliasedClass) |
| 2734 | : NamedDecl(ObjCCompatibleAlias, DC, L, Id), AliasedClass(aliasedClass) {} |
| 2735 | |
| 2736 | void anchor() override; |
| 2737 | |
| 2738 | public: |
| 2739 | static ObjCCompatibleAliasDecl *Create(ASTContext &C, DeclContext *DC, |
| 2740 | SourceLocation L, IdentifierInfo *Id, |
| 2741 | ObjCInterfaceDecl* aliasedClass); |
| 2742 | |
| 2743 | static ObjCCompatibleAliasDecl *CreateDeserialized(ASTContext &C, |
| 2744 | unsigned ID); |
| 2745 | |
| 2746 | const ObjCInterfaceDecl *getClassInterface() const { return AliasedClass; } |
| 2747 | ObjCInterfaceDecl *getClassInterface() { return AliasedClass; } |
| 2748 | void setClassInterface(ObjCInterfaceDecl *D) { AliasedClass = D; } |
| 2749 | |
| 2750 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
| 2751 | static bool classofKind(Kind K) { return K == ObjCCompatibleAlias; } |
| 2752 | }; |
| 2753 | |
| 2754 | |
| 2755 | |
| 2756 | |
| 2757 | |
| 2758 | class ObjCPropertyImplDecl : public Decl { |
| 2759 | public: |
| 2760 | enum Kind { |
| 2761 | Synthesize, |
| 2762 | Dynamic |
| 2763 | }; |
| 2764 | |
| 2765 | private: |
| 2766 | SourceLocation AtLoc; |
| 2767 | |
| 2768 | |
| 2769 | |
| 2770 | |
| 2771 | |
| 2772 | |
| 2773 | |
| 2774 | SourceLocation IvarLoc; |
| 2775 | |
| 2776 | |
| 2777 | ObjCPropertyDecl *PropertyDecl; |
| 2778 | |
| 2779 | |
| 2780 | ObjCIvarDecl *PropertyIvarDecl; |
| 2781 | |
| 2782 | |
| 2783 | |
| 2784 | Expr *GetterCXXConstructor = nullptr; |
| 2785 | |
| 2786 | |
| 2787 | |
| 2788 | Expr *SetterCXXAssignment = nullptr; |
| 2789 | |
| 2790 | ObjCPropertyImplDecl(DeclContext *DC, SourceLocation atLoc, SourceLocation L, |
| 2791 | ObjCPropertyDecl *property, |
| 2792 | Kind PK, |
| 2793 | ObjCIvarDecl *ivarDecl, |
| 2794 | SourceLocation ivarLoc) |
| 2795 | : Decl(ObjCPropertyImpl, DC, L), AtLoc(atLoc), |
| 2796 | IvarLoc(ivarLoc), PropertyDecl(property), PropertyIvarDecl(ivarDecl) { |
| 2797 | assert(PK == Dynamic || PropertyIvarDecl); |
| 2798 | } |
| 2799 | |
| 2800 | public: |
| 2801 | friend class ASTDeclReader; |
| 2802 | |
| 2803 | static ObjCPropertyImplDecl *Create(ASTContext &C, DeclContext *DC, |
| 2804 | SourceLocation atLoc, SourceLocation L, |
| 2805 | ObjCPropertyDecl *property, |
| 2806 | Kind PK, |
| 2807 | ObjCIvarDecl *ivarDecl, |
| 2808 | SourceLocation ivarLoc); |
| 2809 | |
| 2810 | static ObjCPropertyImplDecl *CreateDeserialized(ASTContext &C, unsigned ID); |
| 2811 | |
| 2812 | SourceRange getSourceRange() const override LLVM_READONLY; |
| 2813 | |
| 2814 | SourceLocation getBeginLoc() const LLVM_READONLY { return AtLoc; } |
| 2815 | void setAtLoc(SourceLocation Loc) { AtLoc = Loc; } |
| 2816 | |
| 2817 | ObjCPropertyDecl *getPropertyDecl() const { |
| 2818 | return PropertyDecl; |
| 2819 | } |
| 2820 | void setPropertyDecl(ObjCPropertyDecl *Prop) { PropertyDecl = Prop; } |
| 2821 | |
| 2822 | Kind getPropertyImplementation() const { |
| 2823 | return PropertyIvarDecl ? Synthesize : Dynamic; |
| 2824 | } |
| 2825 | |
| 2826 | ObjCIvarDecl *getPropertyIvarDecl() const { |
| 2827 | return PropertyIvarDecl; |
| 2828 | } |
| 2829 | SourceLocation getPropertyIvarDeclLoc() const { return IvarLoc; } |
| 2830 | |
| 2831 | void setPropertyIvarDecl(ObjCIvarDecl *Ivar, |
| 2832 | SourceLocation IvarLoc) { |
| 2833 | PropertyIvarDecl = Ivar; |
| 2834 | this->IvarLoc = IvarLoc; |
| 2835 | } |
| 2836 | |
| 2837 | |
| 2838 | |
| 2839 | |
| 2840 | |
| 2841 | |
| 2842 | |
| 2843 | |
| 2844 | bool isIvarNameSpecified() const { |
| 2845 | return IvarLoc.isValid() && IvarLoc != getLocation(); |
| 2846 | } |
| 2847 | |
| 2848 | Expr *getGetterCXXConstructor() const { |
| 2849 | return GetterCXXConstructor; |
| 2850 | } |
| 2851 | |
| 2852 | void setGetterCXXConstructor(Expr *getterCXXConstructor) { |
| 2853 | GetterCXXConstructor = getterCXXConstructor; |
| 2854 | } |
| 2855 | |
| 2856 | Expr *getSetterCXXAssignment() const { |
| 2857 | return SetterCXXAssignment; |
| 2858 | } |
| 2859 | |
| 2860 | void setSetterCXXAssignment(Expr *setterCXXAssignment) { |
| 2861 | SetterCXXAssignment = setterCXXAssignment; |
| 2862 | } |
| 2863 | |
| 2864 | static bool classof(const Decl *D) { return classofKind(D->getKind()); } |
| 2865 | static bool classofKind(Decl::Kind K) { return K == ObjCPropertyImpl; } |
| 2866 | }; |
| 2867 | |
| 2868 | template<bool (*Filter)(ObjCCategoryDecl *)> |
| 2869 | void |
| 2870 | ObjCInterfaceDecl::filtered_category_iterator<Filter>:: |
| 2871 | findAcceptableCategory() { |
| 2872 | while (Current && !Filter(Current)) |
| 2873 | Current = Current->getNextClassCategoryRaw(); |
| 2874 | } |
| 2875 | |
| 2876 | template<bool (*Filter)(ObjCCategoryDecl *)> |
| 2877 | inline ObjCInterfaceDecl::filtered_category_iterator<Filter> & |
| 2878 | ObjCInterfaceDecl::filtered_category_iterator<Filter>::operator++() { |
| 2879 | Current = Current->getNextClassCategoryRaw(); |
| 2880 | findAcceptableCategory(); |
| 2881 | return *this; |
| 2882 | } |
| 2883 | |
| 2884 | inline bool ObjCInterfaceDecl::isVisibleCategory(ObjCCategoryDecl *Cat) { |
| 2885 | return !Cat->isHidden(); |
| 2886 | } |
| 2887 | |
| 2888 | inline bool ObjCInterfaceDecl::isVisibleExtension(ObjCCategoryDecl *Cat) { |
| 2889 | return Cat->IsClassExtension() && !Cat->isHidden(); |
| 2890 | } |
| 2891 | |
| 2892 | inline bool ObjCInterfaceDecl::isKnownExtension(ObjCCategoryDecl *Cat) { |
| 2893 | return Cat->IsClassExtension(); |
| 2894 | } |
| 2895 | |
| 2896 | } |
| 2897 | |
| 2898 | #endif |
| 2899 | |