Deleted Added
full compact
CXXInheritance.cpp (199482) CXXInheritance.cpp (200583)
1//===------ CXXInheritance.cpp - C++ Inheritance ----------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 76 unchanged lines hidden (view full) ---

85bool CXXRecordDecl::isDerivedFrom(CXXRecordDecl *Base, CXXBasePaths &Paths) const {
86 if (getCanonicalDecl() == Base->getCanonicalDecl())
87 return false;
88
89 Paths.setOrigin(const_cast<CXXRecordDecl*>(this));
90 return lookupInBases(&FindBaseClass, Base->getCanonicalDecl(), Paths);
91}
92
1//===------ CXXInheritance.cpp - C++ Inheritance ----------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 76 unchanged lines hidden (view full) ---

85bool CXXRecordDecl::isDerivedFrom(CXXRecordDecl *Base, CXXBasePaths &Paths) const {
86 if (getCanonicalDecl() == Base->getCanonicalDecl())
87 return false;
88
89 Paths.setOrigin(const_cast<CXXRecordDecl*>(this));
90 return lookupInBases(&FindBaseClass, Base->getCanonicalDecl(), Paths);
91}
92
93static bool BaseIsNot(const CXXRecordDecl *Base, void *OpaqueTarget) {
94 // OpaqueTarget is a CXXRecordDecl*.
95 return Base->getCanonicalDecl() != (const CXXRecordDecl*) OpaqueTarget;
96}
97
98bool CXXRecordDecl::isProvablyNotDerivedFrom(const CXXRecordDecl *Base) const {
99 return forallBases(BaseIsNot, (void*) Base->getCanonicalDecl());
100}
101
102bool CXXRecordDecl::forallBases(ForallBasesCallback *BaseMatches,
103 void *OpaqueData,
104 bool AllowShortCircuit) const {
105 ASTContext &Context = getASTContext();
106 llvm::SmallVector<const CXXRecordDecl*, 8> Queue;
107
108 const CXXRecordDecl *Record = this;
109 bool AllMatches = true;
110 while (true) {
111 for (CXXRecordDecl::base_class_const_iterator
112 I = Record->bases_begin(), E = Record->bases_end(); I != E; ++I) {
113 const RecordType *Ty = I->getType()->getAs<RecordType>();
114 if (!Ty) {
115 if (AllowShortCircuit) return false;
116 AllMatches = false;
117 continue;
118 }
119
120 CXXRecordDecl *Base =
121 cast_or_null<CXXRecordDecl>(Ty->getDecl()->getDefinition(Context));
122 if (!Base) {
123 if (AllowShortCircuit) return false;
124 AllMatches = false;
125 continue;
126 }
127
128 Queue.push_back(Base);
129 if (!BaseMatches(Base, OpaqueData)) {
130 if (AllowShortCircuit) return false;
131 AllMatches = false;
132 continue;
133 }
134 }
135
136 if (Queue.empty()) break;
137 Record = Queue.back(); // not actually a queue.
138 Queue.pop_back();
139 }
140
141 return AllMatches;
142}
143
93bool CXXRecordDecl::lookupInBases(BaseMatchesCallback *BaseMatches,
94 void *UserData,
95 CXXBasePaths &Paths) const {
96 bool FoundPath = false;
97
98 ASTContext &Context = getASTContext();
99 for (base_class_const_iterator BaseSpec = bases_begin(),
100 BaseSpecEnd = bases_end(); BaseSpec != BaseSpecEnd; ++BaseSpec) {

--- 145 unchanged lines hidden ---
144bool CXXRecordDecl::lookupInBases(BaseMatchesCallback *BaseMatches,
145 void *UserData,
146 CXXBasePaths &Paths) const {
147 bool FoundPath = false;
148
149 ASTContext &Context = getASTContext();
150 for (base_class_const_iterator BaseSpec = bases_begin(),
151 BaseSpecEnd = bases_end(); BaseSpec != BaseSpecEnd; ++BaseSpec) {

--- 145 unchanged lines hidden ---