aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-03-12 02:25:52 +0000
committerChris Lattner <sabre@nondot.org>2008-03-12 02:25:52 +0000
commit2ee8553432fb2029567053ffd4541983a2bb81eb (patch)
tree8be92655a68ea8c4f147d5ac3bf6cb56adc64fbe /lib/Bitcode/Reader/BitcodeReader.cpp
parent74b7f7bbd7426f5b292f30348fff9b744a81e75f (diff)
downloadexternal_llvm-2ee8553432fb2029567053ffd4541983a2bb81eb.zip
external_llvm-2ee8553432fb2029567053ffd4541983a2bb81eb.tar.gz
external_llvm-2ee8553432fb2029567053ffd4541983a2bb81eb.tar.bz2
when the bitcode reader is referencing a paramattr, make sure to bump its refcount.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48276 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r--lib/Bitcode/Reader/BitcodeReader.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp
index a58ead5..c86ee30 100644
--- a/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -31,6 +31,11 @@ void BitcodeReader::FreeState() {
Buffer = 0;
std::vector<PATypeHolder>().swap(TypeList);
ValueList.clear();
+
+ // Drop references to ParamAttrs.
+ for (unsigned i = 0, e = ParamAttrs.size(); i != e; ++i)
+ ParamAttrs[i]->dropRef();
+
std::vector<const ParamAttrsList*>().swap(ParamAttrs);
std::vector<BasicBlock*>().swap(FunctionBBs);
std::vector<Function*>().swap(FunctionsWithBodies);
@@ -237,7 +242,13 @@ bool BitcodeReader::ParseParamAttrBlock() {
if (Record[i+1] != ParamAttr::None)
Attrs.push_back(ParamAttrsWithIndex::get(Record[i], Record[i+1]));
}
- ParamAttrs.push_back(Attrs.empty() ? NULL : ParamAttrsList::get(Attrs));
+ if (Attrs.empty()) {
+ ParamAttrs.push_back(0);
+ } else {
+ ParamAttrs.push_back(ParamAttrsList::get(Attrs));
+ ParamAttrs.back()->addRef();
+ }
+
Attrs.clear();
break;
}