Skip to content

Commit 1131e67

Browse files
committed
Add a test for calling a non-trivial recursive function.
1 parent b8e81ee commit 1131e67

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

clang/test/Analysis/Checkers/WebKit/uncounted-local-vars.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,8 @@ struct TreeNode {
302302
}
303303

304304
int recursiveCost();
305+
int recursiveWeight();
306+
int weight();
305307

306308
int cost { 0 };
307309
mutable unsigned refCount { 0 };
@@ -317,4 +319,12 @@ int TreeNode::recursiveCost() {
317319
return totalCost;
318320
}
319321

322+
int TreeNode::recursiveWeight() {
323+
unsigned totalCost = weight();
324+
for (TreeNode* node = firstChild; node; node = node->nextSibling)
325+
// expected-warning@-1{{Local variable 'node' is uncounted and unsafe [alpha.webkit.UncountedLocalVarsChecker]}}
326+
totalCost += recursiveWeight();
327+
return totalCost;
328+
}
329+
320330
} // namespace local_var_in_recursive_function

0 commit comments

Comments
 (0)