Add a -V <bool> flag to frame variable/expression that enables execution of type validators. The jury is still out on what the user experience of type validators should be, so for now gate it on a specific flag. The mode I am using is prefix variables that fail to validate with a bang, and then emitting the actual validation error on a separate line. Of course, given the total absence of validators, this should never actually happen to you
llvm-svn: 217303
This commit is contained in:
@@ -71,6 +71,8 @@ ValueObjectPrinter::PrintValueObject ()
|
||||
|
||||
if (ShouldPrintValueObject())
|
||||
{
|
||||
PrintValidationMarkerIfNeeded();
|
||||
|
||||
PrintLocationIfNeeded();
|
||||
m_stream->Indent();
|
||||
|
||||
@@ -89,6 +91,8 @@ ValueObjectPrinter::PrintValueObject ()
|
||||
else
|
||||
m_stream->EOL();
|
||||
|
||||
PrintValidationErrorIfNeeded();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -624,3 +628,44 @@ ValueObjectPrinter::PrintChildrenIfNeeded (bool value_printed,
|
||||
else
|
||||
m_stream->EOL();
|
||||
}
|
||||
|
||||
bool
|
||||
ValueObjectPrinter::ShouldPrintValidation ()
|
||||
{
|
||||
return options.m_run_validator;
|
||||
}
|
||||
|
||||
bool
|
||||
ValueObjectPrinter::PrintValidationMarkerIfNeeded ()
|
||||
{
|
||||
if (!ShouldPrintValidation())
|
||||
return false;
|
||||
|
||||
m_validation = m_valobj->GetValidationStatus();
|
||||
|
||||
if (TypeValidatorResult::Failure == m_validation.first)
|
||||
{
|
||||
m_stream->Printf("! ");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
ValueObjectPrinter::PrintValidationErrorIfNeeded ()
|
||||
{
|
||||
if (!ShouldPrintValidation())
|
||||
return false;
|
||||
|
||||
if (TypeValidatorResult::Success == m_validation.first)
|
||||
return false;
|
||||
|
||||
if (m_validation.second.empty())
|
||||
m_validation.second.assign("unknown error");
|
||||
|
||||
m_stream->Printf(" ! validation error: %s", m_validation.second.c_str());
|
||||
m_stream->EOL();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user