diff options
| author | 2019-01-27 16:42:12 +0000 | |
|---|---|---|
| committer | 2019-01-27 16:42:12 +0000 | |
| commit | b773203fb58f3ef282fb69c832d8710cab5bc82d (patch) | |
| tree | e75913f147570fbd75169647b144df85b88a038c /gnu/llvm/tools/clang/lib/AST/CXXInheritance.cpp | |
| parent | tweak errno in previous (diff) | |
| download | wireguard-openbsd-b773203fb58f3ef282fb69c832d8710cab5bc82d.tar.xz wireguard-openbsd-b773203fb58f3ef282fb69c832d8710cab5bc82d.zip | |
Import LLVM 7.0.1 release including clang, lld and lldb.
Diffstat (limited to 'gnu/llvm/tools/clang/lib/AST/CXXInheritance.cpp')
| -rw-r--r-- | gnu/llvm/tools/clang/lib/AST/CXXInheritance.cpp | 97 |
1 files changed, 48 insertions, 49 deletions
diff --git a/gnu/llvm/tools/clang/lib/AST/CXXInheritance.cpp b/gnu/llvm/tools/clang/lib/AST/CXXInheritance.cpp index 24e96ba3801..a0b22b6a85e 100644 --- a/gnu/llvm/tools/clang/lib/AST/CXXInheritance.cpp +++ b/gnu/llvm/tools/clang/lib/AST/CXXInheritance.cpp @@ -34,13 +34,13 @@ using namespace clang; -/// \brief Computes the set of declarations referenced by these base +/// Computes the set of declarations referenced by these base /// paths. void CXXBasePaths::ComputeDeclsFound() { assert(NumDeclsFound == 0 && !DeclsFound && "Already computed the set of declarations"); - llvm::SetVector<NamedDecl *, SmallVector<NamedDecl *, 8>> Decls; + llvm::SmallSetVector<NamedDecl *, 8> Decls; for (paths_iterator Path = begin(), PathEnd = end(); Path != PathEnd; ++Path) Decls.insert(Path->Decls.front()); @@ -63,8 +63,8 @@ CXXBasePaths::decl_range CXXBasePaths::found_decls() { /// an unqualified, canonical class type. bool CXXBasePaths::isAmbiguous(CanQualType BaseType) { BaseType = BaseType.getUnqualifiedType(); - std::pair<bool, unsigned>& Subobjects = ClassSubobjects[BaseType]; - return Subobjects.second + (Subobjects.first? 1 : 0) > 1; + IsVirtBaseAndNumberNonVirtBases Subobjects = ClassSubobjects[BaseType]; + return Subobjects.NumberOfNonVirtBases + (Subobjects.IsVirtBase ? 1 : 0) > 1; } /// clear - Clear out all prior path information. @@ -76,7 +76,7 @@ void CXXBasePaths::clear() { DetectedVirtual = nullptr; } -/// @brief Swaps the contents of this CXXBasePaths structure with the +/// Swaps the contents of this CXXBasePaths structure with the /// contents of Other. void CXXBasePaths::swap(CXXBasePaths &Other) { std::swap(Origin, Other.Origin); @@ -99,7 +99,7 @@ bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base, CXXBasePaths &Paths) const { if (getCanonicalDecl() == Base->getCanonicalDecl()) return false; - + Paths.setOrigin(const_cast<CXXRecordDecl*>(this)); const CXXRecordDecl *BaseDecl = Base->getCanonicalDecl(); @@ -120,7 +120,7 @@ bool CXXRecordDecl::isVirtuallyDerivedFrom(const CXXRecordDecl *Base) const { if (getCanonicalDecl() == Base->getCanonicalDecl()) return false; - + Paths.setOrigin(const_cast<CXXRecordDecl*>(this)); const CXXRecordDecl *BaseDecl = Base->getCanonicalDecl(); @@ -165,7 +165,7 @@ bool CXXRecordDecl::forallBases(ForallBasesCallback BaseMatches, continue; } - CXXRecordDecl *Base = + CXXRecordDecl *Base = cast_or_null<CXXRecordDecl>(Ty->getDecl()->getDefinition()); if (!Base || (Base->isDependentContext() && @@ -174,7 +174,7 @@ bool CXXRecordDecl::forallBases(ForallBasesCallback BaseMatches, AllMatches = false; continue; } - + Queue.push_back(Base); if (!BaseMatches(Base)) { if (AllowShortCircuit) return false; @@ -209,29 +209,29 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context, // C++ [temp.dep]p3: // In the definition of a class template or a member of a class template, // if a base class of the class template depends on a template-parameter, - // the base class scope is not examined during unqualified name lookup - // either at the point of definition of the class template or member or + // the base class scope is not examined during unqualified name lookup + // either at the point of definition of the class template or member or // during an instantiation of the class tem- plate or member. if (!LookupInDependent && BaseType->isDependentType()) continue; - + // Determine whether we need to visit this base class at all, // updating the count of subobjects appropriately. - std::pair<bool, unsigned>& Subobjects = ClassSubobjects[BaseType]; + IsVirtBaseAndNumberNonVirtBases &Subobjects = ClassSubobjects[BaseType]; bool VisitBase = true; bool SetVirtual = false; if (BaseSpec.isVirtual()) { - VisitBase = !Subobjects.first; - Subobjects.first = true; + VisitBase = !Subobjects.IsVirtBase; + Subobjects.IsVirtBase = true; if (isDetectingVirtual() && DetectedVirtual == nullptr) { // If this is the first virtual we find, remember it. If it turns out // there is no base path here, we'll reset it later. DetectedVirtual = BaseType->getAs<RecordType>(); SetVirtual = true; } - } else - ++Subobjects.second; - + } else { + ++Subobjects.NumberOfNonVirtBases; + } if (isRecordingPaths()) { // Add this base specifier to the current path. CXXBasePathElement Element; @@ -240,7 +240,7 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context, if (BaseSpec.isVirtual()) Element.SubobjectNumber = 0; else - Element.SubobjectNumber = Subobjects.second; + Element.SubobjectNumber = Subobjects.NumberOfNonVirtBases; ScratchPath.push_back(Element); // Calculate the "top-down" access to this base class. @@ -261,13 +261,13 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context, if (IsFirstStep) ScratchPath.Access = BaseSpec.getAccessSpecifier(); else - ScratchPath.Access = CXXRecordDecl::MergeAccess(AccessToHere, + ScratchPath.Access = CXXRecordDecl::MergeAccess(AccessToHere, BaseSpec.getAccessSpecifier()); } - + // Track whether there's a path involving this specific base. bool FoundPathThroughBase = false; - + if (BaseMatches(&BaseSpec, ScratchPath)) { // We've found a path that terminates at this base. FoundPath = FoundPathThroughBase = true; @@ -313,15 +313,15 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context, // a sub-object A if A is a base class sub-object of B. Any // declarations that are so hidden are eliminated from // consideration. - - // There is a path to a base class that meets the criteria. If we're + + // There is a path to a base class that meets the criteria. If we're // not collecting paths or finding ambiguities, we're done. FoundPath = FoundPathThroughBase = true; if (!isFindingAmbiguities()) return FoundPath; } } - + // Pop this base specifier off the current path (if we're // collecting paths). if (isRecordingPaths()) { @@ -336,7 +336,7 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context, // Reset the scratch path access. ScratchPath.Access = AccessToHere; - + return FoundPath; } @@ -352,7 +352,7 @@ bool CXXRecordDecl::lookupInBases(BaseMatchesCallback BaseMatches, // we're done. if (!Paths.isRecordingPaths() || !Paths.isFindingAmbiguities()) return true; - + // C++ [class.member.lookup]p6: // When virtual base classes are used, a hidden declaration can be // reached along a path through the sub-object lattice that does @@ -396,7 +396,7 @@ bool CXXRecordDecl::lookupInBases(BaseMatchesCallback BaseMatches, return true; } -bool CXXRecordDecl::FindBaseClass(const CXXBaseSpecifier *Specifier, +bool CXXRecordDecl::FindBaseClass(const CXXBaseSpecifier *Specifier, CXXBasePath &Path, const CXXRecordDecl *BaseRecord) { assert(BaseRecord->getCanonicalDecl() == BaseRecord && @@ -405,7 +405,7 @@ bool CXXRecordDecl::FindBaseClass(const CXXBaseSpecifier *Specifier, ->getCanonicalDecl() == BaseRecord; } -bool CXXRecordDecl::FindVirtualBaseClass(const CXXBaseSpecifier *Specifier, +bool CXXRecordDecl::FindVirtualBaseClass(const CXXBaseSpecifier *Specifier, CXXBasePath &Path, const CXXRecordDecl *BaseRecord) { assert(BaseRecord->getCanonicalDecl() == BaseRecord && @@ -415,7 +415,7 @@ bool CXXRecordDecl::FindVirtualBaseClass(const CXXBaseSpecifier *Specifier, ->getCanonicalDecl() == BaseRecord; } -bool CXXRecordDecl::FindTagMember(const CXXBaseSpecifier *Specifier, +bool CXXRecordDecl::FindTagMember(const CXXBaseSpecifier *Specifier, CXXBasePath &Path, DeclarationName Name) { RecordDecl *BaseRecord = @@ -490,12 +490,12 @@ bool CXXRecordDecl::FindOMPReductionMember(const CXXBaseSpecifier *Specifier, } bool CXXRecordDecl:: -FindNestedNameSpecifierMember(const CXXBaseSpecifier *Specifier, +FindNestedNameSpecifierMember(const CXXBaseSpecifier *Specifier, CXXBasePath &Path, DeclarationName Name) { RecordDecl *BaseRecord = Specifier->getType()->castAs<RecordType>()->getDecl(); - + for (Path.Decls = BaseRecord->lookup(Name); !Path.Decls.empty(); Path.Decls = Path.Decls.slice(1)) { @@ -504,7 +504,7 @@ FindNestedNameSpecifierMember(const CXXBaseSpecifier *Specifier, Path.Decls.front()->isInIdentifierNamespace(IDNS_Tag)) return true; } - + return false; } @@ -538,20 +538,20 @@ std::vector<const NamedDecl *> CXXRecordDecl::lookupDependentName( return Results; } -void OverridingMethods::add(unsigned OverriddenSubobject, +void OverridingMethods::add(unsigned OverriddenSubobject, UniqueVirtualMethod Overriding) { SmallVectorImpl<UniqueVirtualMethod> &SubobjectOverrides = Overrides[OverriddenSubobject]; - if (std::find(SubobjectOverrides.begin(), SubobjectOverrides.end(), + if (std::find(SubobjectOverrides.begin(), SubobjectOverrides.end(), Overriding) == SubobjectOverrides.end()) SubobjectOverrides.push_back(Overriding); } void OverridingMethods::add(const OverridingMethods &Other) { for (const_iterator I = Other.begin(), IE = Other.end(); I != IE; ++I) { - for (overriding_const_iterator M = I->second.begin(), + for (overriding_const_iterator M = I->second.begin(), MEnd = I->second.end(); - M != MEnd; + M != MEnd; ++M) add(I->first, *M); } @@ -567,11 +567,11 @@ void OverridingMethods::replaceAll(UniqueVirtualMethod Overriding) { namespace { class FinalOverriderCollector { - /// \brief The number of subobjects of a given class type that + /// The number of subobjects of a given class type that /// occur within the class hierarchy. llvm::DenseMap<const CXXRecordDecl *, unsigned> SubobjectCount; - /// \brief Overriders for each virtual base subobject. + /// Overriders for each virtual base subobject. llvm::DenseMap<const CXXRecordDecl *, CXXFinalOverriderMap *> VirtualOverriders; CXXFinalOverriderMap FinalOverriders; @@ -586,7 +586,7 @@ public: } // namespace -void FinalOverriderCollector::Collect(const CXXRecordDecl *RD, +void FinalOverriderCollector::Collect(const CXXRecordDecl *RD, bool VirtualBase, const CXXRecordDecl *InVirtualSubobject, CXXFinalOverriderMap &Overriders) { @@ -633,12 +633,11 @@ void FinalOverriderCollector::Collect(const CXXRecordDecl *RD, // Merge the overriders from this base class into our own set of // overriders. - for (CXXFinalOverriderMap::iterator OM = BaseOverriders->begin(), + for (CXXFinalOverriderMap::iterator OM = BaseOverriders->begin(), OMEnd = BaseOverriders->end(); OM != OMEnd; ++OM) { - const CXXMethodDecl *CanonOM - = cast<CXXMethodDecl>(OM->first->getCanonicalDecl()); + const CXXMethodDecl *CanonOM = OM->first->getCanonicalDecl(); Overriders[CanonOM].add(OM->second); } } @@ -649,7 +648,7 @@ void FinalOverriderCollector::Collect(const CXXRecordDecl *RD, if (!M->isVirtual()) continue; - CXXMethodDecl *CanonM = cast<CXXMethodDecl>(M->getCanonicalDecl()); + CXXMethodDecl *CanonM = M->getCanonicalDecl(); using OverriddenMethodsRange = llvm::iterator_range<CXXMethodDecl::method_iterator>; OverriddenMethodsRange OverriddenMethods = CanonM->overridden_methods(); @@ -657,7 +656,7 @@ void FinalOverriderCollector::Collect(const CXXRecordDecl *RD, if (OverriddenMethods.begin() == OverriddenMethods.end()) { // This is a new virtual function that does not override any // other virtual function. Add it to the map of virtual - // functions for which we are tracking overridders. + // functions for which we are tracking overridders. // C++ [class.virtual]p2: // For convenience we say that any virtual function overrides itself. @@ -712,12 +711,12 @@ void FinalOverriderCollector::Collect(const CXXRecordDecl *RD, FinalOverriderCollector::~FinalOverriderCollector() { for (llvm::DenseMap<const CXXRecordDecl *, CXXFinalOverriderMap *>::iterator VO = VirtualOverriders.begin(), VOEnd = VirtualOverriders.end(); - VO != VOEnd; + VO != VOEnd; ++VO) delete VO->second; } -void +void CXXRecordDecl::getFinalOverriders(CXXFinalOverriderMap &FinalOverriders) const { FinalOverriderCollector Collector; Collector.Collect(this, false, nullptr, FinalOverriders); @@ -755,7 +754,7 @@ CXXRecordDecl::getFinalOverriders(CXXFinalOverriderMap &FinalOverriders) const { } } -static void +static void AddIndirectPrimaryBases(const CXXRecordDecl *RD, ASTContext &Context, CXXIndirectPrimaryBaseSet& Bases) { // If the record has a virtual primary base class, add it to our set. @@ -778,7 +777,7 @@ AddIndirectPrimaryBases(const CXXRecordDecl *RD, ASTContext &Context, } -void +void CXXRecordDecl::getIndirectPrimaryBases(CXXIndirectPrimaryBaseSet& Bases) const { ASTContext &Context = getASTContext(); |
