Merge remote-tracking branch 'origin/topic/vern/canonicalize-std-string'

* origin/topic/vern/canonicalize-std-string:
  switched CPPCompile::Canonicalize() to take std::string instead of const char*
This commit is contained in:
Arne Welzel 2024-11-04 18:47:02 +01:00
commit c171d9e8c2
8 changed files with 16 additions and 14 deletions

View file

@ -1,3 +1,7 @@
7.1.0-dev.459 | 2024-11-04 18:47:02 +0100
* switched CPPCompile::Canonicalize() to take std::string instead of const char* (Vern Paxson, Corelight)
7.1.0-dev.457 | 2024-11-04 16:33:14 +0100
* minor ZAM BTest updates for recently added fnv1a64 BiF (Vern Paxson, Corelight)

View file

@ -1 +1 @@
7.1.0-dev.457
7.1.0-dev.459

View file

@ -10,7 +10,7 @@ void CPPCompile::DeclareFunc(const FuncInfo& func) {
if ( ! IsCompilable(func) )
return;
auto fname = Canonicalize(BodyName(func).c_str()) + "_zf";
auto fname = Canonicalize(BodyName(func)) + "_zf";
auto pf = func.Profile();
auto f = func.Func();
const auto& body = func.Body();
@ -25,7 +25,7 @@ void CPPCompile::DeclareFunc(const FuncInfo& func) {
void CPPCompile::DeclareLambda(const LambdaExpr* l, const ProfileFunc* pf) {
ASSERT(is_CPP_compilable(pf));
auto lname = Canonicalize(l->Name().c_str()) + "_lb";
auto lname = Canonicalize(l->Name()) + "_lb";
auto body = l->Ingredients()->Body();
auto l_id = l->Ingredients()->GetID();
auto& ids = l->OuterIDs();

View file

@ -646,7 +646,7 @@ string CPPCompile::GenLambdaExpr(const Expr* e) {
string CPPCompile::GenLambdaExpr(const Expr* e, string capture_args) {
auto l = static_cast<const LambdaExpr*>(e);
auto name = Canonicalize(l->Name().c_str()) + "_lb_cl";
auto name = Canonicalize(l->Name()) + "_lb_cl";
auto cl_args = string("\"") + name + "\"" + std::move(capture_args);
auto body = string("make_intrusive<") + name + ">(" + cl_args + ")";
auto func = string("make_intrusive<CPPLambdaFunc>(\"") + l->Name() + "\", cast_intrusive<FuncType>(" +

View file

@ -10,7 +10,7 @@ void CPPCompile::CompileFunc(const FuncInfo& func) {
if ( ! IsCompilable(func) )
return;
auto fname = Canonicalize(BodyName(func).c_str()) + "_zf";
auto fname = Canonicalize(BodyName(func)) + "_zf";
auto pf = func.Profile();
auto f = func.Func();
const auto& body = func.Body();
@ -19,7 +19,7 @@ void CPPCompile::CompileFunc(const FuncInfo& func) {
}
void CPPCompile::CompileLambda(const LambdaExpr* l, const ProfileFunc* pf) {
auto lname = Canonicalize(l->Name().c_str()) + "_lb";
auto lname = Canonicalize(l->Name()) + "_lb";
auto body = l->Ingredients()->Body();
auto l_id = l->Ingredients()->GetID();
auto& ids = l->OuterIDs();

View file

@ -259,7 +259,7 @@ void CPPCompile::GenStandaloneActivation() {
auto f = func.Func();
auto fname = BodyName(func);
auto bname = Canonicalize(fname.c_str()) + "_zf";
auto bname = Canonicalize(fname) + "_zf";
if ( compiled_funcs.count(bname) == 0 )
// We didn't wind up compiling it.

View file

@ -129,7 +129,7 @@ static string trim_name(const ID* id) {
return ns;
}
string CPPCompile::LocalName(const ID* l) const { return Canonicalize(trim_name(l).c_str()); }
string CPPCompile::LocalName(const ID* l) const { return Canonicalize(trim_name(l)); }
string CPPCompile::CaptureName(const ID* c) const {
// We want to strip both the module and any inlining appendage.
@ -139,15 +139,13 @@ string CPPCompile::CaptureName(const ID* c) const {
if ( appendage != string::npos )
tn.erase(tn.begin() + appendage, tn.end());
return Canonicalize(tn.c_str());
return Canonicalize(tn);
}
string CPPCompile::Canonicalize(const char* name) const {
string CPPCompile::Canonicalize(const std::string& name) const {
string cname;
for ( int i = 0; name[i]; ++i ) {
auto c = name[i];
for ( auto c : name ) {
// Strip <>'s - these get introduced for lambdas.
if ( c == '<' || c == '>' )
continue;

View file

@ -47,7 +47,7 @@ std::string CaptureName(const IDPtr& l) const { return CaptureName(l.get()); }
// Returns a canonicalized name, with various non-alphanumeric characters
// stripped or transformed, and guaranteed not to conflict with C++ keywords.
std::string Canonicalize(const char* name) const;
std::string Canonicalize(const std::string& name) const;
// Returns the name of the global corresponding to an expression (which must
// be a EXPR_NAME).