diff options
Diffstat (limited to 'include/clang/AST/CXXInheritance.h')
-rw-r--r-- | include/clang/AST/CXXInheritance.h | 89 |
1 files changed, 47 insertions, 42 deletions
diff --git a/include/clang/AST/CXXInheritance.h b/include/clang/AST/CXXInheritance.h index 11fb229f0c091..2ae1d8b25823b 100644 --- a/include/clang/AST/CXXInheritance.h +++ b/include/clang/AST/CXXInheritance.h @@ -35,7 +35,7 @@ namespace clang { class ASTContext; class NamedDecl; -/// \brief Represents an element in a path from a derived class to a +/// Represents an element in a path from a derived class to a /// base class. /// /// Each step in the path references the link from a @@ -43,15 +43,15 @@ class NamedDecl; /// base "number" that identifies which base subobject of the /// original derived class we are referencing. struct CXXBasePathElement { - /// \brief The base specifier that states the link from a derived + /// The base specifier that states the link from a derived /// class to a base class, which will be followed by this base /// path element. const CXXBaseSpecifier *Base; - /// \brief The record decl of the class that the base is a base of. + /// The record decl of the class that the base is a base of. const CXXRecordDecl *Class; - /// \brief Identifies which base class subobject (of type + /// Identifies which base class subobject (of type /// \c Base->getType()) this base path element refers to. /// /// This value is only valid if \c !Base->isVirtual(), because there @@ -60,7 +60,7 @@ struct CXXBasePathElement { int SubobjectNumber; }; -/// \brief Represents a path from a specific derived class +/// Represents a path from a specific derived class /// (which is not represented as part of the path) to a particular /// (direct or indirect) base class subobject. /// @@ -70,14 +70,14 @@ struct CXXBasePathElement { /// subobject is being used. class CXXBasePath : public SmallVector<CXXBasePathElement, 4> { public: - /// \brief The access along this inheritance path. This is only + /// The access along this inheritance path. This is only /// calculated when recording paths. AS_none is a special value /// used to indicate a path which permits no legal access. AccessSpecifier Access = AS_public; CXXBasePath() = default; - /// \brief The set of declarations found inside this base class + /// The set of declarations found inside this base class /// subobject. DeclContext::lookup_result Decls; @@ -119,24 +119,42 @@ public: class CXXBasePaths { friend class CXXRecordDecl; - /// \brief The type from which this search originated. + /// The type from which this search originated. CXXRecordDecl *Origin = nullptr; /// Paths - The actual set of paths that can be taken from the /// derived class to the same base class. std::list<CXXBasePath> Paths; - + /// ClassSubobjects - Records the class subobjects for each class - /// type that we've seen. The first element in the pair says + /// type that we've seen. The first element IsVirtBase says /// whether we found a path to a virtual base for that class type, - /// while the element contains the number of non-virtual base + /// while NumberOfNonVirtBases contains the number of non-virtual base /// class subobjects for that class type. The key of the map is /// the cv-unqualified canonical type of the base class subobject. - llvm::SmallDenseMap<QualType, std::pair<bool, unsigned>, 8> ClassSubobjects; + struct IsVirtBaseAndNumberNonVirtBases { + unsigned IsVirtBase : 1; + unsigned NumberOfNonVirtBases : 31; + }; + llvm::SmallDenseMap<QualType, IsVirtBaseAndNumberNonVirtBases, 8> + ClassSubobjects; /// VisitedDependentRecords - Records the dependent records that have been /// already visited. - llvm::SmallDenseSet<const CXXRecordDecl *, 4> VisitedDependentRecords; + llvm::SmallPtrSet<const CXXRecordDecl *, 4> VisitedDependentRecords; + + /// DetectedVirtual - The base class that is virtual. + const RecordType *DetectedVirtual = nullptr; + + /// ScratchPath - A BasePath that is used by Sema::lookupInBases + /// to help build the set of paths. + CXXBasePath ScratchPath; + + /// Array of the declarations that have been found. This + /// array is constructed only if needed, e.g., to iterate over the + /// results within LookupResult. + std::unique_ptr<NamedDecl *[]> DeclsFound; + unsigned NumDeclsFound = 0; /// FindAmbiguities - Whether Sema::IsDerivedFrom should try find /// ambiguous paths while it is looking for a path from a derived @@ -152,20 +170,7 @@ class CXXBasePaths { /// if it finds a path that goes across a virtual base. The virtual class /// is also recorded. bool DetectVirtual; - - /// ScratchPath - A BasePath that is used by Sema::lookupInBases - /// to help build the set of paths. - CXXBasePath ScratchPath; - /// DetectedVirtual - The base class that is virtual. - const RecordType *DetectedVirtual = nullptr; - - /// \brief Array of the declarations that have been found. This - /// array is constructed only if needed, e.g., to iterate over the - /// results within LookupResult. - std::unique_ptr<NamedDecl *[]> DeclsFound; - unsigned NumDeclsFound = 0; - void ComputeDeclsFound(); bool lookupInBases(ASTContext &Context, const CXXRecordDecl *Record, @@ -196,53 +201,53 @@ public: decl_range found_decls(); - /// \brief Determine whether the path from the most-derived type to the + /// Determine whether the path from the most-derived type to the /// given base type is ambiguous (i.e., it refers to multiple subobjects of /// the same base type). bool isAmbiguous(CanQualType BaseType); - /// \brief Whether we are finding multiple paths to detect ambiguities. + /// Whether we are finding multiple paths to detect ambiguities. bool isFindingAmbiguities() const { return FindAmbiguities; } - /// \brief Whether we are recording paths. + /// Whether we are recording paths. bool isRecordingPaths() const { return RecordPaths; } - /// \brief Specify whether we should be recording paths or not. + /// Specify whether we should be recording paths or not. void setRecordingPaths(bool RP) { RecordPaths = RP; } - /// \brief Whether we are detecting virtual bases. + /// Whether we are detecting virtual bases. bool isDetectingVirtual() const { return DetectVirtual; } - /// \brief The virtual base discovered on the path (if we are merely + /// The virtual base discovered on the path (if we are merely /// detecting virtuals). const RecordType* getDetectedVirtual() const { return DetectedVirtual; } - /// \brief Retrieve the type from which this base-paths search + /// Retrieve the type from which this base-paths search /// began CXXRecordDecl *getOrigin() const { return Origin; } void setOrigin(CXXRecordDecl *Rec) { Origin = Rec; } - /// \brief Clear the base-paths results. + /// Clear the base-paths results. void clear(); - /// \brief Swap this data structure's contents with another CXXBasePaths + /// Swap this data structure's contents with another CXXBasePaths /// object. void swap(CXXBasePaths &Other); }; -/// \brief Uniquely identifies a virtual method within a class +/// Uniquely identifies a virtual method within a class /// hierarchy by the method itself and a class subobject number. struct UniqueVirtualMethod { - /// \brief The overriding virtual method. + /// The overriding virtual method. CXXMethodDecl *Method = nullptr; - /// \brief The subobject in which the overriding virtual method + /// The subobject in which the overriding virtual method /// resides. unsigned Subobject = 0; - /// \brief The virtual base class subobject of which this overridden + /// The virtual base class subobject of which this overridden /// virtual method is a part. Note that this records the closest /// derived virtual base class subobject. const CXXRecordDecl *InVirtualSubobject = nullptr; @@ -266,7 +271,7 @@ struct UniqueVirtualMethod { } }; -/// \brief The set of methods that override a given virtual method in +/// The set of methods that override a given virtual method in /// each subobject where it occurs. /// /// The first part of the pair is the subobject in which the @@ -310,7 +315,7 @@ public: void replaceAll(UniqueVirtualMethod Overriding); }; -/// \brief A mapping from each virtual member function to its set of +/// A mapping from each virtual member function to its set of /// final overriders. /// /// Within a class hierarchy for a given derived class, each virtual @@ -364,7 +369,7 @@ public: class CXXFinalOverriderMap : public llvm::MapVector<const CXXMethodDecl *, OverridingMethods> {}; -/// \brief A set of all the primary bases for a class. +/// A set of all the primary bases for a class. class CXXIndirectPrimaryBaseSet : public llvm::SmallSet<const CXXRecordDecl*, 32> {}; |