summaryrefslogtreecommitdiff
path: root/codemaker
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-01-31 14:46:38 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-02-01 12:15:22 +0000
commit2489000d3fd66319a8355fd4e37cfdfda47296d0 (patch)
treecaad79e7b5bec3863604b20190b682c0d73d2b25 /codemaker
parent595848c85acc2609fcc48a40c7a9f216a2722cd8 (diff)
loplugin:useuniqueptr extend to check local vars
just the simple and obvious case for now, of a local var being allocated and deleted inside a single local block, and the delete happening at the end of the block Change-Id: I3a7a094da543debdcd2374737c2ecff91d644625 Reviewed-on: https://gerrit.libreoffice.org/33749 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'codemaker')
-rw-r--r--codemaker/source/codemaker/exceptiontree.cxx9
-rw-r--r--codemaker/source/cppumaker/cpputype.cxx8
-rw-r--r--codemaker/source/javamaker/javatype.cxx4
3 files changed, 9 insertions, 12 deletions
diff --git a/codemaker/source/codemaker/exceptiontree.cxx b/codemaker/source/codemaker/exceptiontree.cxx
index 0f63a5bd0ab5..e9edd6d8e146 100644
--- a/codemaker/source/codemaker/exceptiontree.cxx
+++ b/codemaker/source/codemaker/exceptiontree.cxx
@@ -36,14 +36,11 @@ using codemaker::ExceptionTreeNode;
ExceptionTreeNode * ExceptionTreeNode::add(rtl::OString const & theName) {
std::unique_ptr< ExceptionTreeNode > node(new ExceptionTreeNode(theName));
- children.push_back(node.get());
- return node.release();
+ children.push_back(std::move(node));
+ return children.back().get();
}
void ExceptionTreeNode::clearChildren() {
- for (ExceptionTreeNode* child : children) {
- delete child;
- }
children.clear();
}
@@ -85,7 +82,7 @@ void ExceptionTree::add(
break;
}
if ((*j)->name == *i) {
- node = *j;
+ node = j->get();
break;
}
}
diff --git a/codemaker/source/cppumaker/cpputype.cxx b/codemaker/source/cppumaker/cpputype.cxx
index 47aab6c356c9..6432baee05d6 100644
--- a/codemaker/source/cppumaker/cpputype.cxx
+++ b/codemaker/source/cppumaker/cpputype.cxx
@@ -3359,9 +3359,9 @@ void includeExceptions(
if (node->present) {
includes.add(node->name);
} else {
- for (codemaker::ExceptionTreeNode* pChild : node->children)
+ for (std::unique_ptr<codemaker::ExceptionTreeNode> const & pChild : node->children)
{
- includeExceptions(includes, pChild);
+ includeExceptions(includes, pChild.get());
}
}
}
@@ -3713,9 +3713,9 @@ void ServiceType::dumpCatchClauses(
out << indent() << "throw;\n";
dec();
} else {
- for (codemaker::ExceptionTreeNode* pChild : node->children)
+ for (std::unique_ptr<codemaker::ExceptionTreeNode> const & pChild : node->children)
{
- dumpCatchClauses(out, pChild);
+ dumpCatchClauses(out, pChild.get());
}
}
}
diff --git a/codemaker/source/javamaker/javatype.cxx b/codemaker/source/javamaker/javatype.cxx
index 1d414a1d9150..2da2e5f925f2 100644
--- a/codemaker/source/javamaker/javatype.cxx
+++ b/codemaker/source/javamaker/javatype.cxx
@@ -2087,9 +2087,9 @@ void addExceptionHandlers(
if (node->present) {
code->addException(start, end, handler, node->name.replace('.', '/'));
} else {
- for (codemaker::ExceptionTreeNode* p : node->children)
+ for (std::unique_ptr<codemaker::ExceptionTreeNode> const & p : node->children)
{
- addExceptionHandlers(p, start, end, handler, code);
+ addExceptionHandlers(p.get(), start, end, handler, code);
}
}
}