update(userspace/engine): propagate compiler warnings

Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
This commit is contained in:
Jason Dellaluce
2024-03-25 17:25:56 +00:00
committed by poiana
parent bc078f1f63
commit fa8e780b07
3 changed files with 18 additions and 6 deletions

View File

@@ -75,7 +75,8 @@ static const std::string warning_codes[] = {
"LOAD_APPEND_NO_VALUES", "LOAD_APPEND_NO_VALUES",
"LOAD_EXCEPTION_NAME_NOT_UNIQUE", "LOAD_EXCEPTION_NAME_NOT_UNIQUE",
"LOAD_INVALID_MACRO_NAME", "LOAD_INVALID_MACRO_NAME",
"LOAD_INVALID_LIST_NAME" "LOAD_INVALID_LIST_NAME",
"LOAD_COMPILE_CONDITION"
}; };
const std::string& falco::load_result::warning_code_str(warning_code wc) const std::string& falco::load_result::warning_code_str(warning_code wc)
@@ -96,7 +97,8 @@ static const std::string warning_strings[] = {
"Overriding/appending with no values", "Overriding/appending with no values",
"Multiple exceptions defined with the same name", "Multiple exceptions defined with the same name",
"Invalid macro name", "Invalid macro name",
"Invalid list name" "Invalid list name",
"Warning in rule condition"
}; };
const std::string& falco::load_result::warning_str(warning_code wc) const std::string& falco::load_result::warning_str(warning_code wc)
@@ -117,7 +119,8 @@ static const std::string warning_descs[] = {
"A rule exception is overriding/appending with no values", "A rule exception is overriding/appending with no values",
"A rule is defining multiple exceptions with the same name", "A rule is defining multiple exceptions with the same name",
"A macro is defined with an invalid name", "A macro is defined with an invalid name",
"A list is defined with an invalid name" "A list is defined with an invalid name",
"A rule condition or output have been parsed with a warning"
}; };
const std::string& falco::load_result::warning_desc(warning_code wc) const std::string& falco::load_result::warning_desc(warning_code wc)

View File

@@ -61,7 +61,8 @@ public:
LOAD_APPEND_NO_VALUES, LOAD_APPEND_NO_VALUES,
LOAD_EXCEPTION_NAME_NOT_UNIQUE, LOAD_EXCEPTION_NAME_NOT_UNIQUE,
LOAD_INVALID_MACRO_NAME, LOAD_INVALID_MACRO_NAME,
LOAD_INVALID_LIST_NAME LOAD_INVALID_LIST_NAME,
LOAD_COMPILE_CONDITION
}; };
virtual ~load_result() = default; virtual ~load_result() = default;

View File

@@ -447,20 +447,28 @@ bool rule_loader::compiler::compile_condition(
// skip the rule silently if skip_if_unknown_filter is true and // skip the rule silently if skip_if_unknown_filter is true and
// we encountered some specific kind of errors // we encountered some specific kind of errors
std::string err = e.what(); std::string err = e.what();
rule_loader::context ctx(compiler.get_pos(), condition, cond_ctx);
if(err_is_unknown_type_or_field(err) && allow_unknown_fields) if(err_is_unknown_type_or_field(err) && allow_unknown_fields)
{ {
cfg.res->add_warning( cfg.res->add_warning(
falco::load_result::load_result::LOAD_UNKNOWN_FILTER, falco::load_result::load_result::LOAD_UNKNOWN_FILTER,
err, err,
cond_ctx); ctx);
return false; return false;
} }
rule_loader::context ctx(compiler.get_pos(), condition, cond_ctx);
throw rule_loader::rule_load_exception( throw rule_loader::rule_load_exception(
falco::load_result::load_result::LOAD_ERR_COMPILE_CONDITION, falco::load_result::load_result::LOAD_ERR_COMPILE_CONDITION,
err, err,
ctx); ctx);
} }
for (const auto &w : compiler.get_warnings())
{
rule_loader::context ctx(w.pos, condition, cond_ctx);
cfg.res->add_warning(
falco::load_result::load_result::LOAD_COMPILE_CONDITION,
w.msg,
ctx);
}
return true; return true;
} }