10 DetectCallDepth::FunctionNode::FunctionNode(
const TString& fname)
16 const TString& DetectCallDepth::FunctionNode::getName()
const
21 void DetectCallDepth::FunctionNode::addCallee(
22 DetectCallDepth::FunctionNode* callee)
24 for (
size_t i = 0;
i < callees.size(); ++
i) {
25 if (callees[
i] == callee)
28 callees.push_back(callee);
38 for (
size_t i = 0;
i < callees.size(); ++
i) {
39 switch (callees[
i]->visit) {
42 return kInfiniteCallDepth;
49 int callDepth = callees[
i]->detectCallDepth(detectCallDepth, depth + 1);
52 detectCallDepth->getInfoSink().
info <<
"<-" << callees[
i]->getName();
55 maxDepth =
std::max(callDepth, maxDepth);
74 currentFunction(
NULL),
76 maxDepth(limitCallStackDepth ? maxCallStackDepth : FunctionNode::kInfiniteCallDepth)
82 for (
size_t i = 0;
i < functions.size(); ++
i)
88 switch (node->
getOp())
98 currentFunction = findFunctionByName(node->
getName());
99 if (currentFunction ==
NULL) {
100 currentFunction =
new FunctionNode(node->
getName());
101 functions.push_back(currentFunction);
104 currentFunction =
NULL;
111 FunctionNode*
func = findFunctionByName(node->
getName());
113 func =
new FunctionNode(node->
getName());
114 functions.push_back(func);
117 currentFunction->addCallee(func);
129 return depth >= maxDepth;
132 void DetectCallDepth::resetFunctionNodes()
134 for (
size_t i = 0;
i < functions.size(); ++
i) {
135 functions[
i]->reset();
141 currentFunction =
NULL;
142 resetFunctionNodes();
144 int maxCallDepth = func->detectCallDepth(
this, 1);
146 if (maxCallDepth == FunctionNode::kInfiniteCallDepth)
149 if (maxCallDepth >= maxDepth)
157 if (maxDepth != FunctionNode::kInfiniteCallDepth) {
160 for (
size_t i = 0;
i < functions.size(); ++
i) {
166 FunctionNode*
main = findFunctionByName(
"main(");
170 return detectCallDepthForFunction(main);
176 DetectCallDepth::FunctionNode* DetectCallDepth::findFunctionByName(
179 for (
size_t i = 0;
i < functions.size(); ++
i) {
180 if (functions[
i]->getName() ==
name)
int main(int argc, char **argv)
EGLImageKHR EGLint * name
#define ASSERT(expression)
const TString & getName() const
GLint GLenum GLsizei GLsizei GLsizei depth
virtual bool visitAggregate(Visit, TIntermAggregate *)
std::basic_string< char, std::char_traits< char >, TStringAllocator > TString
bool checkExceedsMaxDepth(int depth)
ErrorCode detectCallDepth()
DetectCallDepth(TInfoSink &infoSync, bool limitCallStackDepth, int maxCallStackDepth)