Merge remote-tracking branch 'origin/topic/vern/CPP-trim'

* origin/topic/vern/CPP-trim:
  suppress unneeded initializations
  address clang 10 warnings
This commit is contained in:
Tim Wojtulewicz 2021-11-29 13:44:11 -07:00
commit fbcebb85a1
7 changed files with 40 additions and 25 deletions

View file

@ -1,3 +1,7 @@
4.2.0-dev.391 | 2021-11-29 13:44:11 -0700
* suppress unneeded initializations (Vern Paxson, Corelight)
4.2.0-dev.387 | 2021-11-24 13:32:33 -0700 4.2.0-dev.387 | 2021-11-24 13:32:33 -0700
* fixes for constructing and assigning records with fields that are empty vectors (Vern Paxson, Corelight) * fixes for constructing and assigning records with fields that are empty vectors (Vern Paxson, Corelight)

View file

@ -1 +1 @@
4.2.0-dev.387 4.2.0-dev.391

View file

@ -64,6 +64,12 @@ void CPPCompile::Compile(bool report_uncompilable)
// previously compiled instances of those if present. // previously compiled instances of those if present.
for ( const auto& func : funcs ) for ( const auto& func : funcs )
{ {
if ( func.ShouldSkip() )
{
not_fully_compilable.insert(func.Func()->Name());
continue;
}
if ( func.Func()->Flavor() != FUNC_FLAVOR_FUNCTION ) if ( func.Func()->Flavor() != FUNC_FLAVOR_FUNCTION )
// Can't be called directly. // Can't be called directly.
continue; continue;
@ -94,7 +100,6 @@ void CPPCompile::Compile(bool report_uncompilable)
{ {
TypePtr tp{NewRef{}, (Type*)(t)}; TypePtr tp{NewRef{}, (Type*)(t)};
types.AddKey(tp, pfs.HashType(t)); types.AddKey(tp, pfs.HashType(t));
(void)RegisterType(tp);
} }
// ### This doesn't work for -O add-C++ // ### This doesn't work for -O add-C++
@ -102,13 +107,6 @@ void CPPCompile::Compile(bool report_uncompilable)
NL(); NL();
#if 0
for ( auto gi : all_global_info )
Emit(gi->Declare());
NL();
#endif
for ( auto& g : pfs.AllGlobals() ) for ( auto& g : pfs.AllGlobals() )
CreateGlobal(g); CreateGlobal(g);
@ -126,7 +124,8 @@ void CPPCompile::Compile(bool report_uncompilable)
// The scaffolding is now in place to go ahead and generate // The scaffolding is now in place to go ahead and generate
// the functions & lambdas. First declare them ... // the functions & lambdas. First declare them ...
for ( const auto& func : funcs ) for ( const auto& func : funcs )
DeclareFunc(func); if ( ! func.ShouldSkip() )
DeclareFunc(func);
// We track lambdas by their internal names, because two different // We track lambdas by their internal names, because two different
// LambdaExpr's can wind up referring to the same underlying lambda // LambdaExpr's can wind up referring to the same underlying lambda
@ -148,7 +147,8 @@ void CPPCompile::Compile(bool report_uncompilable)
// ... and now generate their bodies. // ... and now generate their bodies.
for ( const auto& func : funcs ) for ( const auto& func : funcs )
CompileFunc(func); if ( ! func.ShouldSkip() )
CompileFunc(func);
lambda_names.clear(); lambda_names.clear();
for ( const auto& l : pfs.Lambdas() ) for ( const auto& l : pfs.Lambdas() )

View file

@ -240,6 +240,9 @@ void CPPCompile::GenStandaloneActivation()
for ( const auto& func : funcs ) for ( const auto& func : funcs )
{ {
if ( func.ShouldSkip() )
continue;
auto f = func.Func(); auto f = func.Func();
auto fname = BodyName(func); auto fname = BodyName(func);
auto bname = Canonicalize(fname.c_str()) + "_zf"; auto bname = Canonicalize(fname.c_str()) + "_zf";

View file

@ -382,19 +382,6 @@ static void generate_CPP(std::unique_ptr<ProfileFuncs>& pfs)
auto hm = std::make_unique<CPPHashManager>(hash_name.c_str()); auto hm = std::make_unique<CPPHashManager>(hash_name.c_str());
if ( analysis_options.gen_CPP )
{
if ( analysis_options.only_func )
{ // deactivate all functions except the target one
for ( auto& func : funcs )
{
auto fn = func.Func()->Name();
if ( *analysis_options.only_func != fn )
func.SetSkip(true);
}
}
}
const auto gen_name = hash_dir + "CPP-gen.cc"; const auto gen_name = hash_dir + "CPP-gen.cc";
const auto addl_name = hash_dir + "CPP-gen-addl.h"; const auto addl_name = hash_dir + "CPP-gen-addl.h";
@ -551,6 +538,19 @@ void analyze_scripts()
// No work to do, avoid profiling overhead. // No work to do, avoid profiling overhead.
return; return;
if ( analysis_options.gen_CPP )
{
if ( analysis_options.only_func )
{ // deactivate all functions except the target one
for ( auto& func : funcs )
{
auto fn = func.Func()->Name();
if ( *analysis_options.only_func != fn )
func.SetSkip(true);
}
}
}
// Now that everything's parsed and BiF's have been initialized, // Now that everything's parsed and BiF's have been initialized,
// profile the functions. // profile the functions.
auto pfs = std::make_unique<ProfileFuncs>(funcs, is_CPP_compilable, false); auto pfs = std::make_unique<ProfileFuncs>(funcs, is_CPP_compilable, false);

View file

@ -1099,7 +1099,7 @@ eval auto v = frame[z.v2].double_val;
ZAM_run_time_error(z.loc, "underflow converting double to count"); ZAM_run_time_error(z.loc, "underflow converting double to count");
break; break;
} }
if ( v > UINT64_MAX ) if ( v > static_cast<double>(UINT64_MAX) )
{ {
ZAM_run_time_error(z.loc, "overflow converting double to count"); ZAM_run_time_error(z.loc, "overflow converting double to count");
break; break;

View file

@ -379,6 +379,13 @@ const ZAMStmt ZAMCompiler::GenCond(const Expr* e, int& branch_v)
else else
branch_v = 2; branch_v = 2;
// clang 10 gets perturbed that the indentation of the "default" in the
// following switch block doesn't match that of the cases that we include
// from "ZAM-Conds.h". It really shouldn't worry about indentation mismatches
// across included files since those are not indicative of possible
// logic errors, but Oh Well.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmisleading-indentation"
switch ( e->Tag() ) switch ( e->Tag() )
{ {
#include "ZAM-Conds.h" #include "ZAM-Conds.h"
@ -386,6 +393,7 @@ const ZAMStmt ZAMCompiler::GenCond(const Expr* e, int& branch_v)
default: default:
reporter->InternalError("bad expression type in ZAMCompiler::GenCond"); reporter->InternalError("bad expression type in ZAMCompiler::GenCond");
} }
#pragma GCC diagnostic pop
// Not reached. // Not reached.
} }