Coverage Report

Created: 2026-09-21 06:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/zeek/src/script_opt/ZAM/Profile.cc
Line
Count
Source
1
// See the file "COPYING" in the main distribution directory for copyright.
2
3
#include "zeek/script_opt/ZAM/Profile.h"
4
5
#include "zeek/Obj.h"
6
#include "zeek/script_opt/ProfileFunc.h"
7
8
namespace zeek::detail {
9
10
ZAMLocInfo::ZAMLocInfo(std::string _func_name, std::shared_ptr<Location> _loc, std::shared_ptr<ZAMLocInfo> _parent)
11
0
    : loc(std::move(_loc)), parent(std::move(_parent)) {
12
0
    func_name = func_name_at_loc(std::move(_func_name), loc.get());
13
14
0
    auto main_module = func_name.find("::");
15
0
    if ( main_module != std::string::npos )
16
0
        modules.insert(func_name.substr(0, main_module));
17
18
0
    if ( parent ) {
19
0
        auto& m = parent->GetModules();
20
0
        modules.insert(m.begin(), m.end());
21
0
    }
22
0
}
23
24
0
std::string ZAMLocInfo::Describe(bool include_lines) const {
25
0
    std::string desc;
26
27
0
    if ( AST_blocks ) {
28
0
        desc = AST_blocks->GetDesc(loc.get());
29
0
        if ( parent )
30
0
            desc = parent->Describe(false) + ";" + desc;
31
0
    }
32
0
    else {
33
0
        if ( parent ) {
34
0
            desc = parent->Describe(false);
35
0
            if ( func_name != parent->FuncName() )
36
0
                desc += ";" + func_name;
37
0
        }
38
0
        else
39
0
            desc = func_name;
40
41
0
        if ( include_lines ) {
42
0
            desc += ";" + func_name + ":" + std::to_string(loc->FirstLine());
43
0
            if ( loc->LastLine() > loc->FirstLine() ) {
44
0
                desc.append("-");
45
0
                desc.append(std::to_string(loc->LastLine()));
46
0
            }
47
0
        }
48
0
    }
49
50
0
    return desc;
51
0
}
52
53
} // namespace zeek::detail