[jit] de-optionalize SourceRange context (#32880)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/32880

The PR below made it impossible to construct a SourceRange without a
context, so get rid of its optional-ness

Test Plan: Imported from OSS

Differential Revision: D19670923

Pulled By: suo

fbshipit-source-id: 05936fca2a3d5e613313ade9287b2210bc4a3ccd
This commit is contained in:
Michael Suo
2020-02-18 23:42:46 -08:00
committed by Facebook Github Bot
parent d85c913bfd
commit d13c1b8af8
2 changed files with 3 additions and 7 deletions

View File

@ -50,12 +50,8 @@ ErrorReport::CallStack::~CallStack() {
const char* ErrorReport::what() const noexcept {
std::stringstream msg;
msg << "\n" << ss.str();
if (context) {
msg << ":\n";
context->highlight(msg);
} else {
msg << ".\n";
}
msg << ":\n";
context.highlight(msg);
if (error_stack.size() > 0) {
for (auto it = error_stack.rbegin(); it != error_stack.rend() - 1; ++it) {

View File

@ -38,7 +38,7 @@ struct CAFFE2_API ErrorReport : public std::exception {
friend const ErrorReport& operator<<(const ErrorReport& e, const T& t);
mutable std::stringstream ss;
c10::optional<SourceRange> context;
SourceRange context;
mutable std::string the_message;
std::vector<Call> error_stack;
};