]> granicus.if.org Git - clang/commit
Let ASTReader optionally delete its ASTDeserializationListener.
authorNico Weber <nicolasweber@gmx.de>
Thu, 8 May 2014 04:26:47 +0000 (04:26 +0000)
committerNico Weber <nicolasweber@gmx.de>
Thu, 8 May 2014 04:26:47 +0000 (04:26 +0000)
commitd8758315cabbfdea5caa3e25531012d035838129
tree48a22e35397a92f625dfc3b7f4d62f75e8d41bb8
parente81307a78e7395d512cdea0a59ff7937ac8ebe63
Let ASTReader optionally delete its ASTDeserializationListener.

Use this to fix the leak of DeserializedDeclsDumper and DeserializedDeclsChecker
in FrontendAction (found by LSan), PR19560.

The "delete this" bool is necessary because both PCHGenerator and ASTUnit
return the same object from both getDeserializationListener() and
getASTMutationListener(), so ASTReader can't just have a unique_ptr.

It's also not possible to just let FrontendAction (or CompilerInstance) own
these listeners due to lifetime issues (see comments on PR19560).

Finally, ASTDeserializationListener can't easily be refcounted, since several of
the current listeners are allocated on the stack.

Having this bool isn't ideal, but it's a pattern that's used in other places in
the codebase too, and it seems better than leaking.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208277 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Frontend/CompilerInstance.h
include/clang/Serialization/ASTDeserializationListener.h
include/clang/Serialization/ASTReader.h
lib/Frontend/CompilerInstance.cpp
lib/Frontend/FrontendAction.cpp
lib/Serialization/ASTReader.cpp