Verify deserialized Swift decls as well as imported Clang decls.

Like the Clang decls, this happens at the end of the type-checking, just as
a simple walk through the loaded decls of the loaded modules. This caught
all of the issues in this commit series and will hopefully keep us honest in
the future.

(By the way, we don't verify right when we return a deserialized decl for the
same reason we don't verify right when we return an imported decl: parts of
the decl may be delayed, and (a) we don't want to force things to be imported
or deserialized sooner than necessary, yet (b) we want to verify as much as
possible.)

rdar://problem/16968891

Swift SVN r22200
This commit is contained in:
Jordan Rose
2014-09-23 02:06:27 +00:00
parent 988b8c2033
commit a49874afb5
7 changed files with 55 additions and 19 deletions

View File

@@ -12,6 +12,7 @@
#include "swift/Serialization/ModuleFile.h"
#include "swift/Serialization/ModuleFormat.h"
#include "swift/Subsystems.h"
#include "swift/AST/AST.h"
#include "swift/AST/ModuleLoader.h"
#include "swift/AST/NameLookup.h"
@@ -1174,3 +1175,11 @@ Identifier ModuleFile::getDiscriminatorForPrivateValue(const ValueDecl *D) {
assert(!discriminator.empty() && "no discriminator found for decl");
return discriminator;
}
void ModuleFile::verify() const {
#ifndef NDEBUG
for (const Serialized<Decl*> &next : Decls)
if (next.isComplete())
swift::verify(next);
#endif
}