diff options
author | Eli Friedman <efriedma@codeaurora.org> | 2017-12-19 01:54:09 +0000 |
---|---|---|
committer | Eli Friedman <efriedma@codeaurora.org> | 2017-12-19 01:54:09 +0000 |
commit | 8516b7f6b5b079fd617882cd739d377f5bb38678 (patch) | |
tree | 8f66d0aeb499d22a12b979f409f44ce19dcf48be /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | b1e350f71fa973ee515cbc432f1434f099292e8d (diff) | |
download | bcm5719-llvm-8516b7f6b5b079fd617882cd739d377f5bb38678.tar.gz bcm5719-llvm-8516b7f6b5b079fd617882cd739d377f5bb38678.zip |
[Coverage] Fix use-after free in coverage emission
Fixes regression from r320533.
This fixes the undefined behavior, but I'm not sure it's really right...
I think we end up with missing coverage for code in modules.
Differential Revision: https://reviews.llvm.org/D41374
llvm-svn: 321052
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index c59dc71da59..7b2599d664a 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -4289,7 +4289,11 @@ void CodeGenModule::ClearUnusedCoverageMapping(const Decl *D) { } void CodeGenModule::EmitDeferredUnusedCoverageMappings() { - for (const auto &Entry : DeferredEmptyCoverageMappingDecls) { + // We call takeVector() here to avoid use-after-free. + // FIXME: DeferredEmptyCoverageMappingDecls is getting mutated because + // we deserialize function bodies to emit coverage info for them, and that + // deserializes more declarations. How should we handle that case? + for (const auto &Entry : DeferredEmptyCoverageMappingDecls.takeVector()) { if (!Entry.second) continue; const Decl *D = Entry.first; |