gollvm: fix memory leak for decl vars
In Bfunction::localVariable, decl vars are not included in
valueVarMap_, therefore not deleted when the function is
destroyed. Fix the destructor to delete them.
Change-Id: I2f219a3505a3f85060bf4f3da1ee83421975cb24
Reviewed-on: https://go-review.googlesource.com/92975
Reviewed-by: Than McIntosh <thanm@google.com>
diff --git a/bridge/go-llvm-bfunction.cpp b/bridge/go-llvm-bfunction.cpp
index dc24910..ab72a5a 100644
--- a/bridge/go-llvm-bfunction.cpp
+++ b/bridge/go-llvm-bfunction.cpp
@@ -54,6 +54,12 @@
}
for (auto &lab : labels_)
delete lab;
+ for (auto &v : localVariables_) {
+ // only delete declvars here, others are in valueVarMap_
+ // and will be deleted below.
+ if (v->isDeclVar())
+ delete v;
+ }
for (auto &kv : valueVarMap_)
delete kv.second;
assert(labelAddressPlaceholders_.empty());