summaryrefslogtreecommitdiffstats
path: root/llvm/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
commite7b19035ed5cd15571f0e2233bd7128144ad4036 (patch)
tree596d4092980676c161a024e5ebef9ccaefc5a2ed /llvm/lib/Bitcode/Reader/BitcodeReader.cpp
parent4182fd56ad87573e2bff59083ecb21ccbf528268 (diff)
downloadbcm5719-llvm-e7b19035ed5cd15571f0e2233bd7128144ad4036.tar.gz
bcm5719-llvm-e7b19035ed5cd15571f0e2233bd7128144ad4036.zip
when the bitcode reader is referencing a paramattr, make sure to bump its refcount.
llvm-svn: 48276
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index a58ead5f14c..c86ee3048a9 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/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;
}
OpenPOWER on IntegriCloud