Skip to content

Commit

Permalink
Add type error RedexError
Browse files Browse the repository at this point in the history
Summary: Treat type-checker errors on input special.

Reviewed By: NTillmann

Differential Revision: D50393279

fbshipit-source-id: 7943f28b72c14aaf8f448512b5aba8f1e8ea2625
  • Loading branch information
agampe authored and facebook-github-bot committed Oct 18, 2023
1 parent 08587f1 commit 5404b10
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
14 changes: 8 additions & 6 deletions libredex/PassManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class CheckerConfig {
"input with `-J ir_type_checker.run_on_input_ignore_access=true`.\n "
"You may turn off all input checking with `-J "
"ir_type_checker.run_on_input=false`.";
fail_error(msg);
fail_error(std::move(msg));
}

res = check_no_overwrite_this(false).validate_access(false).run_verifier(
Expand All @@ -155,7 +155,7 @@ class CheckerConfig {
msg +=
"\n If you are confident that this does not matter, turn off input "
"checking with `-J ir_type_checker.run_on_input=false`.";
fail_error(msg);
fail_error(std::move(msg));
}

bool run_after_pass(const Pass* pass) {
Expand Down Expand Up @@ -278,12 +278,14 @@ class CheckerConfig {
return boost::none;
}

static void fail_error(const std::string& error_msg, size_t errors = 1) {
std::cerr << error_msg << std::endl;
static void fail_error(std::string error_msg, size_t errors = 1) {
if (errors > 1) {
std::cerr << "(" << (errors - 1) << " more issues!)" << std::endl;
error_msg.append("\n(");
error_msg.append(std::to_string(errors - 1));
error_msg.append(" more issues!)");
}
_exit(EXIT_FAILURE);
assert_fail_impl("type-checker", RedexError::TYPE_CHECK_ERROR, "%s",
error_msg.c_str());
}

private:
Expand Down
3 changes: 2 additions & 1 deletion libredex/RedexException.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ enum RedexError {
REJECTED_CODING_PATTERN = 8,
INVALID_BETAMAP = 9,
BUFFER_END_EXCEEDED = 10,
MAX = 10,
TYPE_CHECK_ERROR = 11,
MAX = 11,
};

class RedexException : public std::exception {
Expand Down
4 changes: 4 additions & 0 deletions tools/redex-all/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1719,6 +1719,10 @@ int main(int argc, char* argv[]) {
redex_debug::disable_stack_trace_for_exc_type(
RedexError::REJECTED_CODING_PATTERN);

// Input type check issues are a straight issue, not a Redex crash.
redex_debug::set_exc_type_as_abort(RedexError::TYPE_CHECK_ERROR);
redex_debug::disable_stack_trace_for_exc_type(RedexError::TYPE_CHECK_ERROR);

auto maybe_global_profile =
ScopedCommandProfiling::maybe_from_env("GLOBAL_", "global");

Expand Down

0 comments on commit 5404b10

Please sign in to comment.