]> granicus.if.org Git - clang/commit
Fix memory leak of raw_ostreams in LogDiagnosticPrinter handling.
authorDavid Blaikie <dblaikie@gmail.com>
Mon, 15 Sep 2014 17:30:56 +0000 (17:30 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Mon, 15 Sep 2014 17:30:56 +0000 (17:30 +0000)
commit132299d3f0412ef29cbe350716c7d88ba87731eb
tree1fc6dd65a632027cd5c44acda6d652e33e3392a9
parent693214b566d4a0c7f6401a11f0ca0e4b8cdba502
Fix memory leak of raw_ostreams in LogDiagnosticPrinter handling.

This is another case of conditional ownership (in this case a raw
reference, plus a boolean to indicate whether the referenced object
should be deleted). While it's not ideal, I prefer to make the ownership
explicit with a unique_ptr than using a boolean flag (though it does
make the reference and the unique_ptr redundant in the sense that they
both refer to the same memory). At some point we might write a reusable
conditional ownership pointer (a stateful custom deleter for a unique_ptr
may be appropriate).

Based on a patch from a patch by Anton Yartsev.

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