namespace clang {
class CXXConstructorDecl;
+class CXXRecordDecl;
class DeclaratorDecl;
class LookupResult;
struct ObjCMethodList;
/// introduce the same declarations repeatedly.
virtual void ReadExtVectorDecls(SmallVectorImpl<TypedefNameDecl *> &Decls) {}
+ /// \brief Read the set of dynamic classes known to the external Sema source.
+ ///
+ /// The external source should append its own dynamic classes to
+ /// the given vector of declarations. Note that this routine may be
+ /// invoked multiple times; the external source should take care not to
+ /// introduce the same declarations repeatedly.
+ virtual void ReadDynamicClasses(SmallVectorImpl<CXXRecordDecl *> &Decls) {}
+
// isa/cast/dyn_cast support
static bool classof(const ExternalASTSource *Source) {
return Source->SemaSource;
/// by code generation).
llvm::DenseMap<CXXRecordDecl *, bool> VTablesUsed;
+ typedef LazyVector<CXXRecordDecl *, ExternalSemaSource,
+ &ExternalSemaSource::ReadDynamicClasses, 2, 2>
+ DynamicClassesType;
+
/// \brief A list of all of the dynamic classes in this translation
/// unit.
- SmallVector<CXXRecordDecl *, 16> DynamicClasses;
+ DynamicClassesType DynamicClasses;
/// \brief Note that the vtable for the given class was used at the
/// given location.
virtual void ReadExtVectorDecls(SmallVectorImpl<TypedefNameDecl *> &Decls);
+ virtual void ReadDynamicClasses(SmallVectorImpl<CXXRecordDecl *> &Decls);
+
/// \brief Load a selector from disk, registering its ID if it exists.
void LoadSelector(Selector Sel);
// If any dynamic classes have their key function defined within
// this translation unit, then those vtables are considered "used" and must
// be emitted.
- for (unsigned I = 0, N = DynamicClasses.size(); I != N; ++I) {
- assert(!DynamicClasses[I]->isDependentType() &&
+ for (DynamicClassesType::iterator I = DynamicClasses.begin(ExternalSource),
+ E = DynamicClasses.end();
+ I != E; ++I) {
+ assert(!(*I)->isDependentType() &&
"Should not see dependent types here!");
- if (const CXXMethodDecl *KeyFunction
- = Context.getKeyFunction(DynamicClasses[I])) {
+ if (const CXXMethodDecl *KeyFunction = Context.getKeyFunction(*I)) {
const FunctionDecl *Definition = 0;
if (KeyFunction->hasBody(Definition))
- MarkVTableUsed(Definition->getLocation(), DynamicClasses[I], true);
+ MarkVTableUsed(Definition->getLocation(), *I, true);
}
}
// If there were any dynamic classes declarations, deserialize them
// and add them to Sema's vector of such declarations.
- for (unsigned I = 0, N = DynamicClasses.size(); I != N; ++I)
- SemaObj->DynamicClasses.push_back(
- cast<CXXRecordDecl>(GetDecl(DynamicClasses[I])));
// Load the offsets of the declarations that Sema references.
// They will be lazily deserialized when needed.
ExtVectorDecls.clear();
}
+void ASTReader::ReadDynamicClasses(SmallVectorImpl<CXXRecordDecl *> &Decls) {
+ for (unsigned I = 0, N = DynamicClasses.size(); I != N; ++I) {
+ CXXRecordDecl *D
+ = dyn_cast_or_null<CXXRecordDecl>(GetDecl(DynamicClasses[I]));
+ if (D)
+ Decls.push_back(D);
+ }
+ DynamicClasses.clear();
+}
+
void ASTReader::LoadSelector(Selector Sel) {
// It would be complicated to avoid reading the methods anyway. So don't.
ReadMethodPool(Sel);
// Build a record containing all of dynamic classes declarations.
RecordData DynamicClasses;
- for (unsigned I = 0, N = SemaRef.DynamicClasses.size(); I != N; ++I)
- AddDeclRef(SemaRef.DynamicClasses[I], DynamicClasses);
+ AddLazyVectorDecls(*this, SemaRef.DynamicClasses, DynamicClasses);
// Build a record containing all of pending implicit instantiations.
RecordData PendingInstantiations;
// Build a record containing all of dynamic classes declarations.
RecordData DynamicClasses;
- for (unsigned I = 0, N = SemaRef.DynamicClasses.size(); I != N; ++I)
- if (SemaRef.DynamicClasses[I]->getPCHLevel() == 0)
- AddDeclRef(SemaRef.DynamicClasses[I], DynamicClasses);
+ AddLazyVectorDecls(*this, SemaRef.DynamicClasses, DynamicClasses);
// Build a record containing all of pending implicit instantiations.
RecordData PendingInstantiations;