;
40IsVirtBaseAndNumberNonVirtBases Subobjects = ClassSubobjects[BaseType];
41 returnSubobjects.NumberOfNonVirtBases + (Subobjects.IsVirtBase ? 1 : 0) > 1;
47ClassSubobjects.clear();
48VisitedDependentRecords.clear();
49ScratchPath.
clear();
50DetectedVirtual =
nullptr;
56std::swap(Origin,
Other.Origin);
57Paths.swap(
Other.Paths);
58ClassSubobjects.swap(
Other.ClassSubobjects);
59VisitedDependentRecords.swap(
Other.VisitedDependentRecords);
60std::swap(FindAmbiguities,
Other.FindAmbiguities);
61std::swap(RecordPaths,
Other.RecordPaths);
62std::swap(DetectVirtual,
Other.DetectVirtual);
63std::swap(DetectedVirtual,
Other.DetectedVirtual);
111 return Base->getCanonicalDecl() != TargetDecl;
120 if(CurContext->
Equals(
this))
131 for(
const auto&I :
Record->bases()) {
139(
Base->isDependentContext() &&
144Queue.push_back(
Base);
145 if(!BaseMatches(
Base))
151 Record= Queue.pop_back_val();
157boolCXXBasePaths::lookupInBases(
ASTContext&Context,
160 boolLookupInDependent) {
161 boolFoundPath =
false;
165 boolIsFirstStep = ScratchPath.empty();
167 for(
const auto&BaseSpec :
Record->bases()) {
172 boolisCurrentInstantiation = isa<InjectedClassNameType>(BaseType);
173 if(!isCurrentInstantiation) {
174 if(
auto*BaseRecord = cast_if_present<CXXRecordDecl>(
175BaseSpec.getType()->getAsRecordDecl()))
176isCurrentInstantiation = BaseRecord->isDependentContext() &&
177BaseRecord->isCurrentInstantiation(
Record);
185 if(!LookupInDependent &&
191IsVirtBaseAndNumberNonVirtBases &Subobjects = ClassSubobjects[BaseType];
192 boolVisitBase =
true;
193 boolSetVirtual =
false;
194 if(BaseSpec.isVirtual()) {
195VisitBase = !Subobjects.IsVirtBase;
196Subobjects.IsVirtBase =
true;
204++Subobjects.NumberOfNonVirtBases;
209Element.Base = &BaseSpec;
211 if(BaseSpec.isVirtual())
212Element.SubobjectNumber = 0;
214Element.SubobjectNumber = Subobjects.NumberOfNonVirtBases;
215ScratchPath.push_back(Element);
233ScratchPath.
Access= BaseSpec.getAccessSpecifier();
236BaseSpec.getAccessSpecifier());
240 boolFoundPathThroughBase =
false;
242 if(BaseMatches(&BaseSpec, ScratchPath)) {
244FoundPath = FoundPathThroughBase =
true;
247Paths.push_back(ScratchPath);
253}
else if(VisitBase) {
255 if(LookupInDependent) {
259 if(
auto*RT = BaseSpec.getType()->getAs<
RecordType>())
260BaseRecord = cast<CXXRecordDecl>(RT->getDecl());
265BaseRecord = TD->getTemplatedDecl();
269BaseRecord =
nullptr;
270 else if(!VisitedDependentRecords.insert(BaseRecord).second)
271BaseRecord =
nullptr;
274BaseRecord = cast<CXXRecordDecl>(BaseSpec.getType()->getAsRecordDecl());
277lookupInBases(Context, BaseRecord, BaseMatches, LookupInDependent)) {
286FoundPath = FoundPathThroughBase =
true;
295ScratchPath.pop_back();
299 if(SetVirtual && !FoundPathThroughBase) {
300DetectedVirtual =
nullptr;
305ScratchPath.
Access= AccessToHere;
312 boolLookupInDependent)
const{
314 if(!Paths.lookupInBases(
getASTContext(),
this, BaseMatches,
320 if(!Paths.isRecordingPaths() || !Paths.isFindingAmbiguities())
335 if(!PE.Base->isVirtual())
340VBase = cast<CXXRecordDecl>(
Record->getDecl());
352HidingClass = cast<CXXRecordDecl>(
Record->getDecl());
370 "User data for FindBaseClass is not canonical!");
372->getCanonicalDecl() == BaseRecord;
379 "User data for FindBaseClass is not canonical!");
382->getCanonicalDecl() == BaseRecord;
437llvm::function_ref<
bool(
const NamedDecl*ND)> Filter) {
438std::vector<const NamedDecl *> Results;
440 boolAnyOrdinaryMembers =
false;
443AnyOrdinaryMembers =
true;
445Results.push_back(ND);
447 if(AnyOrdinaryMembers)
452Paths.setOrigin(
this);
462Results.push_back(*I);
470= Overrides[OverriddenSubobject];
471 if(!llvm::is_contained(SubobjectOverrides, Overriding))
472SubobjectOverrides.push_back(Overriding);
478MEnd = I->second.end();
488I->second.push_back(Overriding);
494classFinalOverriderCollector {
497llvm::DenseMap<const CXXRecordDecl *, unsigned> SubobjectCount;
500llvm::DenseMap<const CXXRecordDecl *, CXXFinalOverriderMap *> VirtualOverriders;
505~FinalOverriderCollector();
514voidFinalOverriderCollector::Collect(
const CXXRecordDecl*RD,
518 unsignedSubobjectNumber = 0;
523 for(
const auto&
Base: RD->
bases()) {
525 const CXXRecordDecl*BaseDecl = cast<CXXRecordDecl>(RT->getDecl());
529 if(Overriders.empty() && !
Base.isVirtual()) {
532Collect(BaseDecl,
false, InVirtualSubobject, Overriders);
543 if(
Base.isVirtual()) {
545BaseOverriders = MyVirtualOverriders;
546 if(!MyVirtualOverriders) {
552BaseOverriders = MyVirtualOverriders;
554Collect(BaseDecl,
true, BaseDecl, *MyVirtualOverriders);
557Collect(BaseDecl,
false, InVirtualSubobject, ComputedBaseOverriders);
561 for(CXXFinalOverriderMap::iterator OM = BaseOverriders->begin(),
562OMEnd = BaseOverriders->end();
566Overriders[CanonOM].add(OM->second);
571 for(
auto*M : RD->
methods()) {
577 usingOverriddenMethodsRange =
578llvm::iterator_range<CXXMethodDecl::method_iterator>;
581 if(OverriddenMethods.begin() == OverriddenMethods.end()) {
588Overriders[CanonM].add(SubobjectNumber,
590InVirtualSubobject));
601 while(!Stack.empty()) {
614Overriders[CanonOM].replaceAll(
616InVirtualSubobject));
619 if(OverriddenMethods.begin() == OverriddenMethods.end())
624Stack.push_back(OverriddenMethods);
630Overriders[CanonM].add(SubobjectNumber,
632InVirtualSubobject));
636FinalOverriderCollector::~FinalOverriderCollector() {
637 for(llvm::DenseMap<const CXXRecordDecl *, CXXFinalOverriderMap *>::iterator
638VO = VirtualOverriders.begin(), VOEnd = VirtualOverriders.end();
646FinalOverriderCollector Collector;
647Collector.Collect(
this,
false,
nullptr, FinalOverriders);
652 for(
auto&OM : FinalOverriders) {
653 for(
auto&SO : OM.second) {
655 if(Overriding.size() < 2)
659 if(!M.InVirtualSubobject)
669OP.Method->getParent()->isVirtuallyDerivedFrom(
670M.InVirtualSubobject))
677llvm::erase_if(Overriding, IsHidden);
690 for(
const auto&I : RD->
bases()) {
691assert(!I.getType()->isDependentType() &&
692 "Cannot get indirect primary bases for class with dependent bases.");
695cast<CXXRecordDecl>(I.getType()->getAsRecordDecl());
712 for(
const auto&I :
bases()) {
713assert(!I.getType()->isDependentType() &&
714 "Cannot get indirect primary bases for class with dependent bases.");
717cast<CXXRecordDecl>(I.getType()->getAsRecordDecl());
Defines the clang::ASTContext interface.
static bool findOrdinaryMemberInDependentClasses(const CXXBaseSpecifier *Specifier, CXXBasePath &Path, DeclarationName Name)
static void AddIndirectPrimaryBases(const CXXRecordDecl *RD, ASTContext &Context, CXXIndirectPrimaryBaseSet &Bases)
static bool isOrdinaryMember(const NamedDecl *ND)
static bool findOrdinaryMember(const CXXRecordDecl *RD, CXXBasePath &Path, DeclarationName Name)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the C++ template declaration subclasses.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
llvm::MachO::Record Record
static RecordDecl * getAsRecordDecl(QualType BaseType)
C Language Family Type Representation.
const NestedNameSpecifier * Specifier
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
const ASTRecordLayout & getASTRecordLayout(const RecordDecl *D) const
Get or compute information about the layout of the specified record (struct/union/class) D,...
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
ASTRecordLayout - This class contains layout information for one RecordDecl, which is a struct/union/...
const CXXRecordDecl * getPrimaryBase() const
getPrimaryBase - Get the primary base for this record.
bool isPrimaryBaseVirtual() const
isPrimaryBaseVirtual - Get whether the primary base for this record is virtual or not.
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
AccessSpecifier Access
The access along this inheritance path.
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
bool isRecordingPaths() const
Whether we are recording paths.
bool isDetectingVirtual() const
Whether we are detecting virtual bases.
bool isAmbiguous(CanQualType BaseType)
Determine whether the path from the most-derived type to the given base type is ambiguous (i....
void clear()
Clear the base-paths results.
bool isFindingAmbiguities() const
Whether we are finding multiple paths to detect ambiguities.
void swap(CXXBasePaths &Other)
Swap this data structure's contents with another CXXBasePaths object.
Represents a base class of a C++ class.
A mapping from each virtual member function to its set of final overriders.
A set of all the primary bases for a class.
Represents a static or instance method of a struct/union/class.
overridden_method_range overridden_methods() const
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Represents a C++ struct/union/class.
void getIndirectPrimaryBases(CXXIndirectPrimaryBaseSet &Bases) const
Get the indirect primary bases for this class.
bool isProvablyNotDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is provably not derived from the type Base.
method_range methods() const
static AccessSpecifier MergeAccess(AccessSpecifier PathAccess, AccessSpecifier DeclAccess)
Calculates the access of a decl that is reached along a path.
bool isPolymorphic() const
Whether this class is polymorphic (C++ [class.virtual]), which means that the class contains or inher...
bool lookupInBases(BaseMatchesCallback BaseMatches, CXXBasePaths &Paths, bool LookupInDependent=false) const
Look for entities within the base classes of this C++ class, transitively searching all base class su...
bool hasDefinition() const
void getFinalOverriders(CXXFinalOverriderMap &FinaOverriders) const
Retrieve the final overriders for each virtual member function in the class hierarchy where this clas...
llvm::function_ref< bool(const CXXBaseSpecifier *Specifier, CXXBasePath &Path)> BaseMatchesCallback
Function type used by lookupInBases() to determine whether a specific base class subobject matches th...
bool isCurrentInstantiation(const DeclContext *CurContext) const
Determine whether this dependent class is a current instantiation, when viewed from within the given ...
bool hasMemberName(DeclarationName N) const
Determine whether this class has a member with the given name, possibly in a non-dependent base class...
llvm::function_ref< bool(const CXXRecordDecl *BaseDefinition)> ForallBasesCallback
Function type used by forallBases() as a callback.
static bool FindVirtualBaseClass(const CXXBaseSpecifier *Specifier, CXXBasePath &Path, const CXXRecordDecl *BaseRecord)
Base-class lookup callback that determines whether the given base class specifier refers to a specifi...
static bool FindBaseClass(const CXXBaseSpecifier *Specifier, CXXBasePath &Path, const CXXRecordDecl *BaseRecord)
Base-class lookup callback that determines whether the given base class specifier refers to a specifi...
bool isVirtuallyDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is virtually derived from the class Base.
bool forallBases(ForallBasesCallback BaseMatches) const
Determines if the given callback holds for all the direct or indirect base classes of this type.
std::vector< const NamedDecl * > lookupDependentName(DeclarationName Name, llvm::function_ref< bool(const NamedDecl *ND)> Filter)
Performs an imprecise lookup of a dependent name in this class.
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
unsigned getNumVBases() const
Retrieves the number of virtual base classes of this class.
bool isDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is derived from the class Base.
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC.
bool isFileContext() const
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
ASTContext & getASTContext() const LLVM_READONLY
bool isInIdentifierNamespace(unsigned NS) const
@ IDNS_Ordinary
Ordinary names.
@ IDNS_Member
Members, declared with object declarations within tag definitions.
@ IDNS_Tag
Tags, declared with 'struct foo;' and referenced with 'struct foo'.
The name of a declaration.
This represents a decl that may have a name.
CXXRecordDecl * getAsRecordDecl() const
Retrieve the record declaration stored in this nested name specifier.
The set of methods that override a given virtual method in each subobject where it occurs.
void replaceAll(UniqueVirtualMethod Overriding)
MapType::iterator iterator
SmallVectorImpl< UniqueVirtualMethod >::const_iterator overriding_const_iterator
MapType::const_iterator const_iterator
void add(unsigned OverriddenSubobject, UniqueVirtualMethod Overriding)
A (possibly-)qualified type.
RecordDecl * getDefinition() const
Returns the RecordDecl that actually defines this struct/union/class.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
RecordDecl * getDecl() const
Represents a C++ template name within the type system.
TemplateDecl * getAsTemplateDecl(bool IgnoreDeduced=false) const
Retrieve the underlying template declaration that this template name refers to, if known.
Represents a type template specialization; the template must be a class template, a type alias templa...
TemplateName getTemplateName() const
Retrieve the name of the template that we are specializing.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
const T * getAs() const
Member-template getAs<specific type>'.
The JSON file list parser is used to communicate input to InstallAPI.
if(T->getSizeExpr()) TRY_TO(TraverseStmt(const_cast< Expr * >(T -> getSizeExpr())))
@ Other
Other implicit parameter.
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
Represents an element in a path from a derived class to a base class.
Uniquely identifies a virtual method within a class hierarchy by the method itself and a class subobj...
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4