Use unique_ptr for Scope, getScope returns a reference

This commit is contained in:
David Ungar
2019-06-12 07:29:00 -07:00
parent 6cfcabd8e5
commit 69f6b41a13
7 changed files with 22 additions and 23 deletions

View File

@@ -1695,9 +1695,10 @@ StringRef SourceFile::getFilename() const {
return SM.getIdentifierForBuffer(BufferID);
}
ASTScope *SourceFile::getScope() {
if (!Scope) Scope = ASTScope::createScopeTreeFor(this);
return Scope;
ASTScope &SourceFile::getScope() {
if (!Scope)
Scope = std::unique_ptr<ASTScope>(new (getASTContext()) ASTScope(this));
return *Scope.get();
}