std::vector<const NamedDecl *> CXXRecordDecl::lookupDependentName( const DeclarationName &Name, llvm::function_ref<bool(const NamedDecl *ND)> Filter) { std::vector<const NamedDecl *> Results; // Lookup in the class. DeclContext::lookup_result DirectResult = lookup(Name); if (!DirectResult.empty()) { for (const NamedDecl *ND : DirectResult) { if (Filter(ND)) Results.push_back(ND); } return Results; } // Perform lookup into our base classes. CXXBasePaths Paths; Paths.setOrigin(this); if (!lookupInBases( [&](const CXXBaseSpecifier *Specifier, CXXBasePath &Path) { return CXXRecordDecl::FindOrdinaryMemberInDependentClasses( Specifier, Path, Name); }, Paths, /*LookupInDependent=*/true)) return Results; for (const NamedDecl *ND : Paths.front().Decls) { if (Filter(ND)) Results.push_back(ND); } return Results; }
bool RemoveNamespace::hasNameConflict(const NamedDecl *ND, const DeclContext *ParentCtx) { // we cannot lookup names from LinkageSpecDecl, e.g., // extern "C++" { ... } if (dyn_cast<LinkageSpecDecl>(ParentCtx)) return false; DeclarationName Name = ND->getDeclName(); DeclContext::lookup_result Result = ParentCtx->lookup(Name); return !Result.empty(); }
/// Returns the value stored in the 'success_' field of the passed-in /// AssertionResult instance. SVal GTestChecker::getAssertionResultSuccessFieldValue( const CXXRecordDecl *AssertionResultDecl, SVal Instance, ProgramStateRef State) const { DeclContext::lookup_result Result = AssertionResultDecl->lookup(SuccessII); if (Result.empty()) return UnknownVal(); auto *SuccessField = dyn_cast<FieldDecl>(Result.front()); if (!SuccessField) return UnknownVal(); Optional<Loc> FieldLoc = State->getLValue(SuccessField, Instance).getAs<Loc>(); if (!FieldLoc.hasValue()) return UnknownVal(); return State->getSVal(*FieldLoc); }