summaryrefslogtreecommitdiff
path: root/tools/llvm2cpp
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2007-04-22 05:46:44 +0000
committerReid Spencer <rspencer@reidspencer.com>2007-04-22 05:46:44 +0000
commit4f859aa532dbf061736f9c23e0d0882b5cdfe566 (patch)
tree5b03ace46223602b455c373f25432ef52f8ea2b4 /tools/llvm2cpp
parent3b87d6a7b57277a17e75ec83759ea95e0579e219 (diff)
downloadllvm-4f859aa532dbf061736f9c23e0d0882b5cdfe566.tar.gz
llvm-4f859aa532dbf061736f9c23e0d0882b5cdfe566.tar.bz2
llvm-4f859aa532dbf061736f9c23e0d0882b5cdfe566.tar.xz
For PR1146:
Make ParamAttrsList objects unique. You can no longer directly create or destroy them but instead must go through the ParamAttrsList::get() interface. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36327 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm2cpp')
-rw-r--r--tools/llvm2cpp/CppWriter.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/tools/llvm2cpp/CppWriter.cpp b/tools/llvm2cpp/CppWriter.cpp
index 42a8560215..58c67b716e 100644
--- a/tools/llvm2cpp/CppWriter.cpp
+++ b/tools/llvm2cpp/CppWriter.cpp
@@ -461,13 +461,14 @@ CppWriter::printTypeInternal(const Type* Ty) {
const ParamAttrsList *PAL = FT->getParamAttrs();
Out << "ParamAttrsList *" << typeName << "_PAL = 0;";
nl(Out);
- if (PAL && !PAL->empty()) {
- Out << typeName << "_PAL = new ParamAttrsList();";
- nl(Out);
+ if (PAL) {
+ Out << '{'; in(); nl(Out);
+ Out << "ParamAttrsVector Attrs;"; nl(Out);
+ Out << "ParamAttrsWithIndex PAWI;"; nl(Out);
for (unsigned i = 0; i < PAL->size(); ++i) {
uint16_t index = PAL->getParamIndex(i);
uint16_t attrs = PAL->getParamAttrs(index);
- Out << typeName << "_PAL->addAttributes(" << index << ", 0";
+ Out << "PAWI.index = " << index << "; PAWI.attrs = 0 ";
if (attrs & ParamAttr::SExt)
Out << " | ParamAttr::SExt";
if (attrs & ParamAttr::ZExt)
@@ -480,9 +481,15 @@ CppWriter::printTypeInternal(const Type* Ty) {
Out << " | ParamAttr::NoReturn";
if (attrs & ParamAttr::NoUnwind)
Out << " | ParamAttr::NoUnwind";
- Out << ");";
+ Out << ";";
+ nl(Out);
+ Out << "Attrs.push_back(PAWI);";
nl(Out);
}
+ Out << typeName << "_PAL = ParamAttrsList::get(Attrs);";
+ nl(Out);
+ out(); nl(Out);
+ Out << '}'; nl(Out);
}
bool isForward = printTypeInternal(FT->getReturnType());
std::string retTypeName(getCppName(FT->getReturnType()));