DestructorAnalysis: Fix for recursive types

We can't just recursively process types without caching. Instead mark a type as
safe before we recurse and reset this assumption if we proved otherwise on the
recursive traversal.

rdar://20132313

Swift SVN r26048
This commit is contained in:
Arnold Schwaighofer
2015-03-12 17:14:25 +00:00
parent 853cc6a7b3
commit 165bfb6f95
3 changed files with 69 additions and 8 deletions

View File

@@ -14,12 +14,14 @@
#include "swift/SIL/SILValue.h"
#include "swift/SILAnalysis/Analysis.h"
#include "llvm/ADT/DenseMap.h"
namespace swift {
/// This analysis determines memory effects during destruction.
class DestructorAnalysis : public SILAnalysis {
SILModule *Mod;
llvm::DenseMap<CanType, bool> Cached;
public:
DestructorAnalysis(SILModule *M)
@@ -33,6 +35,7 @@ public:
bool mayStoreToMemoryOnDestruction(SILType T);
protected:
bool cacheResult(CanType Type, bool Result);
bool isSafeType(Type);
bool implementsDestructorSafeContainerProtocol(NominalTypeDecl *);
bool areTypeParametersSafe(CanType);