For vector<shared_ptr/unique_ptr>'s, emplace_back(new T()) is not
safe and can lead to memory leak. This happens when emplace_back
fails to allocate required memory and throws, and the object allocated
with new will never be deleted. Although this is not an issue
for LLVM as a compiler, it can hurt those who use it as a library.
Details
Details
Diff Detail
Diff Detail
Event Timeline
Comment Actions
Hi Chandler Carruth,
I found this bug in your slides at https://llvm.org/devmtg/2014-10/Slides/Carruth-TheLLVMPassManagerPart2.pdf.
I saw the same pattern somewhere else in the llvm repo too but I do not have the time and the tool to fix all of them.
I guess it would be much easier to fix it with the help of LLVM itself.
Hope this helps.
Boleyn Su
Comment Actions
Thanks @chandlerc .
@asbirlea and @aeubanks would you mind to take at a look at the CL?
Comment Actions
Looks good to me as well.
Thought this patch would be good to go with Chandler's accept; for future similar fixes, myself and aeubanks are good contacts.