Switch Sema::DynamicClasses over to LazyVector
llvm-svn: 136317
This commit is contained in:
parent
8a815152c2
commit
32002197b2
|
@ -19,6 +19,7 @@
|
|||
namespace clang {
|
||||
|
||||
class CXXConstructorDecl;
|
||||
class CXXRecordDecl;
|
||||
class DeclaratorDecl;
|
||||
class LookupResult;
|
||||
struct ObjCMethodList;
|
||||
|
@ -107,6 +108,14 @@ public:
|
|||
/// 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;
|
||||
|
|
|
@ -3375,9 +3375,13 @@ public:
|
|||
/// 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.
|
||||
|
|
|
@ -1382,6 +1382,8 @@ public:
|
|||
|
||||
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);
|
||||
|
||||
|
|
|
@ -408,14 +408,15 @@ void Sema::ActOnEndOfTranslationUnit() {
|
|||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4341,9 +4341,6 @@ void ASTReader::InitializeSema(Sema &S) {
|
|||
|
||||
// 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.
|
||||
|
@ -4586,6 +4583,16 @@ void ASTReader::ReadExtVectorDecls(SmallVectorImpl<TypedefNameDecl *> &Decls) {
|
|||
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);
|
||||
|
|
|
@ -2867,8 +2867,7 @@ void ASTWriter::WriteASTCore(Sema &SemaRef, MemorizeStatCalls *StatCalls,
|
|||
|
||||
// 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;
|
||||
|
@ -3137,9 +3136,7 @@ void ASTWriter::WriteASTChain(Sema &SemaRef, MemorizeStatCalls *StatCalls,
|
|||
|
||||
// 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;
|
||||
|
|
Loading…
Reference in New Issue