| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | #ifndef LLVM_CLANG_SEMA_LOOKUP_H |
| 15 | #define LLVM_CLANG_SEMA_LOOKUP_H |
| 16 | |
| 17 | #include "clang/AST/Decl.h" |
| 18 | #include "clang/AST/DeclBase.h" |
| 19 | #include "clang/AST/DeclCXX.h" |
| 20 | #include "clang/AST/DeclarationName.h" |
| 21 | #include "clang/AST/Type.h" |
| 22 | #include "clang/AST/UnresolvedSet.h" |
| 23 | #include "clang/Basic/LLVM.h" |
| 24 | #include "clang/Basic/LangOptions.h" |
| 25 | #include "clang/Basic/SourceLocation.h" |
| 26 | #include "clang/Basic/Specifiers.h" |
| 27 | #include "clang/Sema/Sema.h" |
| 28 | #include "llvm/ADT/MapVector.h" |
| 29 | #include "llvm/ADT/Optional.h" |
| 30 | #include "llvm/ADT/STLExtras.h" |
| 31 | #include "llvm/Support/Casting.h" |
| 32 | #include <cassert> |
| 33 | #include <utility> |
| 34 | |
| 35 | namespace clang { |
| 36 | |
| 37 | class CXXBasePaths; |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | class LookupResult { |
| 47 | public: |
| 48 | enum LookupResultKind { |
| 49 | |
| 50 | NotFound = 0, |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | NotFoundInCurrentInstantiation, |
| 56 | |
| 57 | |
| 58 | |
| 59 | Found, |
| 60 | |
| 61 | |
| 62 | |
| 63 | FoundOverloaded, |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | FoundUnresolvedValue, |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | Ambiguous |
| 74 | }; |
| 75 | |
| 76 | enum AmbiguityKind { |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | AmbiguousBaseSubobjectTypes, |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | AmbiguousBaseSubobjects, |
| 104 | |
| 105 | |
| 106 | |
| 107 | |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | AmbiguousReference, |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 126 | |
| 127 | |
| 128 | |
| 129 | |
| 130 | |
| 131 | |
| 132 | |
| 133 | |
| 134 | |
| 135 | AmbiguousTagHiding |
| 136 | }; |
| 137 | |
| 138 | |
| 139 | enum TemporaryToken { |
| 140 | Temporary |
| 141 | }; |
| 142 | |
| 143 | using iterator = UnresolvedSetImpl::iterator; |
| 144 | |
| 145 | LookupResult(Sema &SemaRef, const DeclarationNameInfo &NameInfo, |
| 146 | Sema::LookupNameKind LookupKind, |
| 147 | Sema::RedeclarationKind Redecl = Sema::NotForRedeclaration) |
| 148 | : SemaPtr(&SemaRef), NameInfo(NameInfo), LookupKind(LookupKind), |
| 149 | Redecl(Redecl != Sema::NotForRedeclaration), |
| 150 | ExternalRedecl(Redecl == Sema::ForExternalRedeclaration), |
| 151 | Diagnose(Redecl == Sema::NotForRedeclaration) { |
| 152 | configure(); |
| 153 | } |
| 154 | |
| 155 | |
| 156 | |
| 157 | |
| 158 | LookupResult(Sema &SemaRef, DeclarationName Name, |
| 159 | SourceLocation NameLoc, Sema::LookupNameKind LookupKind, |
| 160 | Sema::RedeclarationKind Redecl = Sema::NotForRedeclaration) |
| 161 | : SemaPtr(&SemaRef), NameInfo(Name, NameLoc), LookupKind(LookupKind), |
| 162 | Redecl(Redecl != Sema::NotForRedeclaration), |
| 163 | ExternalRedecl(Redecl == Sema::ForExternalRedeclaration), |
| 164 | Diagnose(Redecl == Sema::NotForRedeclaration) { |
| 165 | configure(); |
| 166 | } |
| 167 | |
| 168 | |
| 169 | |
| 170 | |
| 171 | LookupResult(TemporaryToken _, const LookupResult &Other) |
| 172 | : SemaPtr(Other.SemaPtr), NameInfo(Other.NameInfo), |
| 173 | LookupKind(Other.LookupKind), IDNS(Other.IDNS), Redecl(Other.Redecl), |
| 174 | ExternalRedecl(Other.ExternalRedecl), HideTags(Other.HideTags), |
| 175 | AllowHidden(Other.AllowHidden), |
| 176 | TemplateNameLookup(Other.TemplateNameLookup) {} |
| 177 | |
| 178 | |
| 179 | |
| 180 | LookupResult(const LookupResult &) = delete; |
| 181 | LookupResult &operator=(const LookupResult &) = delete; |
| 182 | |
| 183 | LookupResult(LookupResult &&Other) |
| 184 | : ResultKind(std::move(Other.ResultKind)), |
| 185 | Ambiguity(std::move(Other.Ambiguity)), Decls(std::move(Other.Decls)), |
| 186 | Paths(std::move(Other.Paths)), |
| 187 | NamingClass(std::move(Other.NamingClass)), |
| 188 | BaseObjectType(std::move(Other.BaseObjectType)), |
| 189 | SemaPtr(std::move(Other.SemaPtr)), NameInfo(std::move(Other.NameInfo)), |
| 190 | NameContextRange(std::move(Other.NameContextRange)), |
| 191 | LookupKind(std::move(Other.LookupKind)), IDNS(std::move(Other.IDNS)), |
| 192 | Redecl(std::move(Other.Redecl)), |
| 193 | ExternalRedecl(std::move(Other.ExternalRedecl)), |
| 194 | HideTags(std::move(Other.HideTags)), |
| 195 | Diagnose(std::move(Other.Diagnose)), |
| 196 | AllowHidden(std::move(Other.AllowHidden)), |
| 197 | Shadowed(std::move(Other.Shadowed)), |
| 198 | TemplateNameLookup(std::move(Other.TemplateNameLookup)) { |
| 199 | Other.Paths = nullptr; |
| 200 | Other.Diagnose = false; |
| 201 | } |
| 202 | |
| 203 | LookupResult &operator=(LookupResult &&Other) { |
| 204 | ResultKind = std::move(Other.ResultKind); |
| 205 | Ambiguity = std::move(Other.Ambiguity); |
| 206 | Decls = std::move(Other.Decls); |
| 207 | Paths = std::move(Other.Paths); |
| 208 | NamingClass = std::move(Other.NamingClass); |
| 209 | BaseObjectType = std::move(Other.BaseObjectType); |
| 210 | SemaPtr = std::move(Other.SemaPtr); |
| 211 | NameInfo = std::move(Other.NameInfo); |
| 212 | NameContextRange = std::move(Other.NameContextRange); |
| 213 | LookupKind = std::move(Other.LookupKind); |
| 214 | IDNS = std::move(Other.IDNS); |
| 215 | Redecl = std::move(Other.Redecl); |
| 216 | ExternalRedecl = std::move(Other.ExternalRedecl); |
| 217 | HideTags = std::move(Other.HideTags); |
| 218 | Diagnose = std::move(Other.Diagnose); |
| 219 | AllowHidden = std::move(Other.AllowHidden); |
| 220 | Shadowed = std::move(Other.Shadowed); |
| 221 | TemplateNameLookup = std::move(Other.TemplateNameLookup); |
| 222 | Other.Paths = nullptr; |
| 223 | Other.Diagnose = false; |
| 224 | return *this; |
| 225 | } |
| 226 | |
| 227 | ~LookupResult() { |
| 228 | if (Diagnose) diagnose(); |
| 229 | if (Paths) deletePaths(Paths); |
| 230 | } |
| 231 | |
| 232 | |
| 233 | const DeclarationNameInfo &getLookupNameInfo() const { |
| 234 | return NameInfo; |
| 235 | } |
| 236 | |
| 237 | |
| 238 | void setLookupNameInfo(const DeclarationNameInfo &NameInfo) { |
| 239 | this->NameInfo = NameInfo; |
| 240 | } |
| 241 | |
| 242 | |
| 243 | DeclarationName getLookupName() const { |
| 244 | return NameInfo.getName(); |
| 245 | } |
| 246 | |
| 247 | |
| 248 | void setLookupName(DeclarationName Name) { |
| 249 | NameInfo.setName(Name); |
| 250 | } |
| 251 | |
| 252 | |
| 253 | Sema::LookupNameKind getLookupKind() const { |
| 254 | return LookupKind; |
| 255 | } |
| 256 | |
| 257 | |
| 258 | bool isForRedeclaration() const { |
| 259 | return Redecl; |
| 260 | } |
| 261 | |
| 262 | |
| 263 | |
| 264 | bool isForExternalRedeclaration() const { |
| 265 | return ExternalRedecl; |
| 266 | } |
| 267 | |
| 268 | Sema::RedeclarationKind redeclarationKind() const { |
| 269 | return ExternalRedecl ? Sema::ForExternalRedeclaration : |
| 270 | Redecl ? Sema::ForVisibleRedeclaration : Sema::NotForRedeclaration; |
| 271 | } |
| 272 | |
| 273 | |
| 274 | |
| 275 | void setAllowHidden(bool AH) { |
| 276 | AllowHidden = AH; |
| 277 | } |
| 278 | |
| 279 | |
| 280 | |
| 281 | bool isHiddenDeclarationVisible(NamedDecl *ND) const { |
| 282 | return AllowHidden || |
| 283 | (isForExternalRedeclaration() && ND->isExternallyDeclarable()); |
| 284 | } |
| 285 | |
| 286 | |
| 287 | |
| 288 | void setHideTags(bool Hide) { |
| 289 | HideTags = Hide; |
| 290 | } |
| 291 | |
| 292 | |
| 293 | |
| 294 | |
| 295 | void setTemplateNameLookup(bool TemplateName) { |
| 296 | TemplateNameLookup = TemplateName; |
| 297 | } |
| 298 | |
| 299 | bool isTemplateNameLookup() const { return TemplateNameLookup; } |
| 300 | |
| 301 | bool isAmbiguous() const { |
| 302 | return getResultKind() == Ambiguous; |
| 303 | } |
| 304 | |
| 305 | |
| 306 | |
| 307 | |
| 308 | bool isSingleResult() const { |
| 309 | return getResultKind() == Found; |
| 310 | } |
| 311 | |
| 312 | |
| 313 | bool isOverloadedResult() const { |
| 314 | return getResultKind() == FoundOverloaded; |
| 315 | } |
| 316 | |
| 317 | bool isUnresolvableResult() const { |
| 318 | return getResultKind() == FoundUnresolvedValue; |
| 319 | } |
| 320 | |
| 321 | LookupResultKind getResultKind() const { |
| 322 | assert(sanity()); |
| 323 | return ResultKind; |
| 324 | } |
| 325 | |
| 326 | AmbiguityKind getAmbiguityKind() const { |
| 327 | assert(isAmbiguous()); |
| 328 | return Ambiguity; |
| 329 | } |
| 330 | |
| 331 | const UnresolvedSetImpl &asUnresolvedSet() const { |
| 332 | return Decls; |
| 333 | } |
| 334 | |
| 335 | iterator begin() const { return iterator(Decls.begin()); } |
| 336 | iterator end() const { return iterator(Decls.end()); } |
| 337 | |
| 338 | |
| 339 | bool empty() const { return Decls.empty(); } |
| 340 | |
| 341 | |
| 342 | |
| 343 | CXXBasePaths *getBasePaths() const { |
| 344 | return Paths; |
| 345 | } |
| 346 | |
| 347 | |
| 348 | |
| 349 | static bool isVisible(Sema &SemaRef, NamedDecl *D) { |
| 350 | |
| 351 | if (!D->isHidden()) |
| 352 | return true; |
| 353 | |
| 354 | |
| 355 | |
| 356 | return isVisibleSlow(SemaRef, D); |
| 357 | } |
| 358 | |
| 359 | |
| 360 | |
| 361 | NamedDecl *getAcceptableDecl(NamedDecl *D) const { |
| 362 | if (!D->isInIdentifierNamespace(IDNS)) |
| 363 | return nullptr; |
| 364 | |
| 365 | if (isVisible(getSema(), D) || isHiddenDeclarationVisible(D)) |
| 366 | return D; |
| 367 | |
| 368 | return getAcceptableDeclSlow(D); |
| 369 | } |
| 370 | |
| 371 | private: |
| 372 | static bool isVisibleSlow(Sema &SemaRef, NamedDecl *D); |
| 373 | NamedDecl *getAcceptableDeclSlow(NamedDecl *D) const; |
| 374 | |
| 375 | public: |
| 376 | |
| 377 | unsigned getIdentifierNamespace() const { |
| 378 | return IDNS; |
| 379 | } |
| 380 | |
| 381 | |
| 382 | |
| 383 | bool isClassLookup() const { |
| 384 | return NamingClass != nullptr; |
| 385 | } |
| 386 | |
| 387 | |
| 388 | |
| 389 | |
| 390 | |
| 391 | |
| 392 | |
| 393 | |
| 394 | |
| 395 | |
| 396 | |
| 397 | |
| 398 | |
| 399 | |
| 400 | |
| 401 | |
| 402 | |
| 403 | CXXRecordDecl *getNamingClass() const { |
| 404 | return NamingClass; |
| 405 | } |
| 406 | |
| 407 | |
| 408 | void setNamingClass(CXXRecordDecl *Record) { |
| 409 | NamingClass = Record; |
| 410 | } |
| 411 | |
| 412 | |
| 413 | |
| 414 | |
| 415 | QualType getBaseObjectType() const { |
| 416 | return BaseObjectType; |
| 417 | } |
| 418 | |
| 419 | |
| 420 | void setBaseObjectType(QualType T) { |
| 421 | BaseObjectType = T; |
| 422 | } |
| 423 | |
| 424 | |
| 425 | |
| 426 | void addDecl(NamedDecl *D) { |
| 427 | addDecl(D, D->getAccess()); |
| 428 | } |
| 429 | |
| 430 | |
| 431 | |
| 432 | void addDecl(NamedDecl *D, AccessSpecifier AS) { |
| 433 | Decls.addDecl(D, AS); |
| 434 | ResultKind = Found; |
| 435 | } |
| 436 | |
| 437 | |
| 438 | |
| 439 | void addAllDecls(const LookupResult &Other) { |
| 440 | Decls.append(Other.Decls.begin(), Other.Decls.end()); |
| 441 | ResultKind = Found; |
| 442 | } |
| 443 | |
| 444 | |
| 445 | |
| 446 | bool wasNotFoundInCurrentInstantiation() const { |
| 447 | return ResultKind == NotFoundInCurrentInstantiation; |
| 448 | } |
| 449 | |
| 450 | |
| 451 | |
| 452 | void setNotFoundInCurrentInstantiation() { |
| 453 | assert(ResultKind == NotFound && Decls.empty()); |
| 454 | ResultKind = NotFoundInCurrentInstantiation; |
| 455 | } |
| 456 | |
| 457 | |
| 458 | |
| 459 | bool isShadowed() const { return Shadowed; } |
| 460 | |
| 461 | |
| 462 | |
| 463 | void setShadowed() { Shadowed = true; } |
| 464 | |
| 465 | |
| 466 | |
| 467 | |
| 468 | |
| 469 | |
| 470 | void resolveKind(); |
| 471 | |
| 472 | |
| 473 | |
| 474 | void resolveKindAfterFilter() { |
| 475 | if (Decls.empty()) { |
| 476 | if (ResultKind != NotFoundInCurrentInstantiation) |
| 477 | ResultKind = NotFound; |
| 478 | |
| 479 | if (Paths) { |
| 480 | deletePaths(Paths); |
| 481 | Paths = nullptr; |
| 482 | } |
| 483 | } else { |
| 484 | llvm::Optional<AmbiguityKind> SavedAK; |
| 485 | bool WasAmbiguous = false; |
| 486 | if (ResultKind == Ambiguous) { |
| 487 | SavedAK = Ambiguity; |
| 488 | WasAmbiguous = true; |
| 489 | } |
| 490 | ResultKind = Found; |
| 491 | resolveKind(); |
| 492 | |
| 493 | |
| 494 | |
| 495 | if (ResultKind == Ambiguous) { |
| 496 | (void)WasAmbiguous; |
| 497 | assert(WasAmbiguous); |
| 498 | Ambiguity = SavedAK.getValue(); |
| 499 | } else if (Paths) { |
| 500 | deletePaths(Paths); |
| 501 | Paths = nullptr; |
| 502 | } |
| 503 | } |
| 504 | } |
| 505 | |
| 506 | template <class DeclClass> |
| 507 | DeclClass *getAsSingle() const { |
| 508 | if (getResultKind() != Found) return nullptr; |
| 509 | return dyn_cast<DeclClass>(getFoundDecl()); |
| 510 | } |
| 511 | |
| 512 | |
| 513 | |
| 514 | |
| 515 | |
| 516 | |
| 517 | NamedDecl *getFoundDecl() const { |
| 518 | (0) . __assert_fail ("getResultKind() == Found && \"getFoundDecl called on non-unique result\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Sema/Lookup.h", 519, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(getResultKind() == Found |
| 519 | (0) . __assert_fail ("getResultKind() == Found && \"getFoundDecl called on non-unique result\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Sema/Lookup.h", 519, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true"> && "getFoundDecl called on non-unique result"); |
| 520 | return (*begin())->getUnderlyingDecl(); |
| 521 | } |
| 522 | |
| 523 | |
| 524 | NamedDecl *getRepresentativeDecl() const { |
| 525 | (0) . __assert_fail ("!Decls.empty() && \"cannot get representative of empty set\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Sema/Lookup.h", 525, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(!Decls.empty() && "cannot get representative of empty set"); |
| 526 | return *begin(); |
| 527 | } |
| 528 | |
| 529 | |
| 530 | bool isSingleTagDecl() const { |
| 531 | return getResultKind() == Found && isa<TagDecl>(getFoundDecl()); |
| 532 | } |
| 533 | |
| 534 | |
| 535 | |
| 536 | |
| 537 | |
| 538 | void setAmbiguousBaseSubobjectTypes(CXXBasePaths &P); |
| 539 | |
| 540 | |
| 541 | |
| 542 | |
| 543 | |
| 544 | void setAmbiguousBaseSubobjects(CXXBasePaths &P); |
| 545 | |
| 546 | |
| 547 | |
| 548 | |
| 549 | void setAmbiguousQualifiedTagHiding() { |
| 550 | setAmbiguous(AmbiguousTagHiding); |
| 551 | } |
| 552 | |
| 553 | |
| 554 | LLVM_ATTRIBUTE_REINITIALIZES void clear() { |
| 555 | ResultKind = NotFound; |
| 556 | Decls.clear(); |
| 557 | if (Paths) deletePaths(Paths); |
| 558 | Paths = nullptr; |
| 559 | NamingClass = nullptr; |
| 560 | Shadowed = false; |
| 561 | } |
| 562 | |
| 563 | |
| 564 | |
| 565 | void clear(Sema::LookupNameKind Kind) { |
| 566 | clear(); |
| 567 | LookupKind = Kind; |
| 568 | configure(); |
| 569 | } |
| 570 | |
| 571 | |
| 572 | void setRedeclarationKind(Sema::RedeclarationKind RK) { |
| 573 | Redecl = (RK != Sema::NotForRedeclaration); |
| 574 | ExternalRedecl = (RK == Sema::ForExternalRedeclaration); |
| 575 | configure(); |
| 576 | } |
| 577 | |
| 578 | void dump(); |
| 579 | void print(raw_ostream &); |
| 580 | |
| 581 | |
| 582 | |
| 583 | void suppressDiagnostics() { |
| 584 | Diagnose = false; |
| 585 | } |
| 586 | |
| 587 | |
| 588 | bool isSuppressingDiagnostics() const { |
| 589 | return !Diagnose; |
| 590 | } |
| 591 | |
| 592 | |
| 593 | void (SourceRange SR) { |
| 594 | NameContextRange = SR; |
| 595 | } |
| 596 | |
| 597 | |
| 598 | |
| 599 | |
| 600 | SourceRange () const { |
| 601 | return NameContextRange; |
| 602 | } |
| 603 | |
| 604 | |
| 605 | |
| 606 | SourceLocation getNameLoc() const { |
| 607 | return NameInfo.getLoc(); |
| 608 | } |
| 609 | |
| 610 | |
| 611 | |
| 612 | Sema &getSema() const { return *SemaPtr; } |
| 613 | |
| 614 | |
| 615 | |
| 616 | |
| 617 | class Filter { |
| 618 | friend class LookupResult; |
| 619 | |
| 620 | LookupResult &Results; |
| 621 | LookupResult::iterator I; |
| 622 | bool Changed = false; |
| 623 | bool CalledDone = false; |
| 624 | |
| 625 | Filter(LookupResult &Results) : Results(Results), I(Results.begin()) {} |
| 626 | |
| 627 | public: |
| 628 | Filter(Filter &&F) |
| 629 | : Results(F.Results), I(F.I), Changed(F.Changed), |
| 630 | CalledDone(F.CalledDone) { |
| 631 | F.CalledDone = true; |
| 632 | } |
| 633 | |
| 634 | ~Filter() { |
| 635 | (0) . __assert_fail ("CalledDone && \"LookupResult..Filter destroyed without done() call\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Sema/Lookup.h", 636, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(CalledDone && |
| 636 | (0) . __assert_fail ("CalledDone && \"LookupResult..Filter destroyed without done() call\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Sema/Lookup.h", 636, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true"> "LookupResult::Filter destroyed without done() call"); |
| 637 | } |
| 638 | |
| 639 | bool hasNext() const { |
| 640 | return I != Results.end(); |
| 641 | } |
| 642 | |
| 643 | NamedDecl *next() { |
| 644 | (0) . __assert_fail ("I != Results.end() && \"next() called on empty filter\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Sema/Lookup.h", 644, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(I != Results.end() && "next() called on empty filter"); |
| 645 | return *I++; |
| 646 | } |
| 647 | |
| 648 | |
| 649 | void restart() { |
| 650 | I = Results.begin(); |
| 651 | } |
| 652 | |
| 653 | |
| 654 | void erase() { |
| 655 | Results.Decls.erase(--I); |
| 656 | Changed = true; |
| 657 | } |
| 658 | |
| 659 | |
| 660 | |
| 661 | void replace(NamedDecl *D) { |
| 662 | Results.Decls.replace(I-1, D); |
| 663 | Changed = true; |
| 664 | } |
| 665 | |
| 666 | |
| 667 | void replace(NamedDecl *D, AccessSpecifier AS) { |
| 668 | Results.Decls.replace(I-1, D, AS); |
| 669 | Changed = true; |
| 670 | } |
| 671 | |
| 672 | void done() { |
| 673 | (0) . __assert_fail ("!CalledDone && \"done() called twice\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Sema/Lookup.h", 673, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(!CalledDone && "done() called twice"); |
| 674 | CalledDone = true; |
| 675 | |
| 676 | if (Changed) |
| 677 | Results.resolveKindAfterFilter(); |
| 678 | } |
| 679 | }; |
| 680 | |
| 681 | |
| 682 | Filter makeFilter() { |
| 683 | return Filter(*this); |
| 684 | } |
| 685 | |
| 686 | void setFindLocalExtern(bool FindLocalExtern) { |
| 687 | if (FindLocalExtern) |
| 688 | IDNS |= Decl::IDNS_LocalExtern; |
| 689 | else |
| 690 | IDNS &= ~Decl::IDNS_LocalExtern; |
| 691 | } |
| 692 | |
| 693 | private: |
| 694 | void diagnose() { |
| 695 | if (isAmbiguous()) |
| 696 | getSema().DiagnoseAmbiguousLookup(*this); |
| 697 | else if (isClassLookup() && getSema().getLangOpts().AccessControl) |
| 698 | getSema().CheckLookupAccess(*this); |
| 699 | } |
| 700 | |
| 701 | void setAmbiguous(AmbiguityKind AK) { |
| 702 | ResultKind = Ambiguous; |
| 703 | Ambiguity = AK; |
| 704 | } |
| 705 | |
| 706 | void addDeclsFromBasePaths(const CXXBasePaths &P); |
| 707 | void configure(); |
| 708 | |
| 709 | |
| 710 | bool sanity() const; |
| 711 | |
| 712 | bool sanityCheckUnresolved() const { |
| 713 | for (iterator I = begin(), E = end(); I != E; ++I) |
| 714 | if (isa<UnresolvedUsingValueDecl>((*I)->getUnderlyingDecl())) |
| 715 | return true; |
| 716 | return false; |
| 717 | } |
| 718 | |
| 719 | static void deletePaths(CXXBasePaths *); |
| 720 | |
| 721 | |
| 722 | LookupResultKind ResultKind = NotFound; |
| 723 | |
| 724 | |
| 725 | AmbiguityKind Ambiguity = {}; |
| 726 | UnresolvedSet<8> Decls; |
| 727 | CXXBasePaths *Paths = nullptr; |
| 728 | CXXRecordDecl *NamingClass = nullptr; |
| 729 | QualType BaseObjectType; |
| 730 | |
| 731 | |
| 732 | Sema *SemaPtr; |
| 733 | DeclarationNameInfo NameInfo; |
| 734 | SourceRange ; |
| 735 | Sema::LookupNameKind LookupKind; |
| 736 | unsigned IDNS = 0; |
| 737 | |
| 738 | bool Redecl; |
| 739 | bool ExternalRedecl; |
| 740 | |
| 741 | |
| 742 | |
| 743 | bool HideTags = true; |
| 744 | |
| 745 | bool Diagnose = false; |
| 746 | |
| 747 | |
| 748 | bool AllowHidden = false; |
| 749 | |
| 750 | |
| 751 | |
| 752 | |
| 753 | bool Shadowed = false; |
| 754 | |
| 755 | |
| 756 | bool TemplateNameLookup = false; |
| 757 | }; |
| 758 | |
| 759 | |
| 760 | |
| 761 | |
| 762 | |
| 763 | |
| 764 | |
| 765 | class VisibleDeclConsumer { |
| 766 | public: |
| 767 | |
| 768 | virtual ~VisibleDeclConsumer(); |
| 769 | |
| 770 | |
| 771 | |
| 772 | |
| 773 | virtual bool includeHiddenDecls() const; |
| 774 | |
| 775 | |
| 776 | |
| 777 | |
| 778 | |
| 779 | |
| 780 | |
| 781 | |
| 782 | |
| 783 | |
| 784 | |
| 785 | |
| 786 | |
| 787 | virtual void FoundDecl(NamedDecl *ND, NamedDecl *Hiding, DeclContext *Ctx, |
| 788 | bool InBaseClass) = 0; |
| 789 | |
| 790 | |
| 791 | |
| 792 | |
| 793 | |
| 794 | virtual void EnteredContext(DeclContext *Ctx) {} |
| 795 | }; |
| 796 | |
| 797 | |
| 798 | class ADLResult { |
| 799 | private: |
| 800 | |
| 801 | llvm::MapVector<NamedDecl*, NamedDecl*> Decls; |
| 802 | |
| 803 | struct select_second { |
| 804 | NamedDecl *operator()(std::pair<NamedDecl*, NamedDecl*> P) const { |
| 805 | return P.second; |
| 806 | } |
| 807 | }; |
| 808 | |
| 809 | public: |
| 810 | |
| 811 | void insert(NamedDecl *D); |
| 812 | |
| 813 | |
| 814 | void erase(NamedDecl *D) { |
| 815 | Decls.erase(cast<NamedDecl>(D->getCanonicalDecl())); |
| 816 | } |
| 817 | |
| 818 | using iterator = |
| 819 | llvm::mapped_iterator<decltype(Decls)::iterator, select_second>; |
| 820 | |
| 821 | iterator begin() { return iterator(Decls.begin(), select_second()); } |
| 822 | iterator end() { return iterator(Decls.end(), select_second()); } |
| 823 | }; |
| 824 | |
| 825 | } |
| 826 | |
| 827 | #endif |
| 828 | |