mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
first cut at embedding filenames in C++ function names - for Justin to test
This commit is contained in:
parent
b5b87d0b15
commit
e200016200
1 changed files with 22 additions and 2 deletions
|
@ -194,14 +194,34 @@ void CPPCompile::DeclareLocals(const ProfileFunc* pf, const IDPList* lambda_ids)
|
|||
string CPPCompile::BodyName(const FuncInfo& func)
|
||||
{
|
||||
const auto& f = func.Func();
|
||||
const auto& bodies = f->GetBodies();
|
||||
const auto& body = func.Body();
|
||||
string fname = f->Name();
|
||||
|
||||
// Extend name with location information.
|
||||
auto loc = body->GetLocationInfo();
|
||||
if ( loc->filename )
|
||||
{
|
||||
auto fn = loc->filename;
|
||||
|
||||
// Skip leading goop that gets added by search paths.
|
||||
while ( *fn == '.' || *fn == '/' )
|
||||
++fn;
|
||||
|
||||
auto canonicalize =
|
||||
[](char c) -> char { return isalnum(c) ? c : '_'; };
|
||||
|
||||
string fns = fn;
|
||||
transform(fns.begin(), fns.end(), fns.begin(), canonicalize);
|
||||
|
||||
fname = fns + "__" + fname;
|
||||
}
|
||||
|
||||
const auto& bodies = f->GetBodies();
|
||||
|
||||
if ( bodies.size() == 1 )
|
||||
return fname;
|
||||
|
||||
// Make the name distinct-per-body.
|
||||
const auto& body = func.Body();
|
||||
|
||||
int i;
|
||||
for ( i = 0; i < bodies.size(); ++i )
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue