[Lldb-commits] [lldb] r251727 - Abstract the notion of the truth value of an expression result, for use

Enrico Granata via lldb-commits lldb-commits at lists.llvm.org
Fri Oct 30 17:15:26 PDT 2015


> On Oct 30, 2015, at 5:02 PM, Jim Ingham via lldb-commits <lldb-commits at lists.llvm.org> wrote:
> 
> bool
> +ValueObject::IsLogicalTrue (Error& error)
> +{
> +    Scalar scalar_value;
> +    
> +    if (!ResolveValue (scalar_value))
> +    {
> +        error.SetErrorString("failed to get a scalar result");
> +        return false;
> +    }
> +    
> +    bool ret;
> +    if (scalar_value.ULongLong(1) == 0)
> +        ret = false;
> +    else
> +        ret = true;
> +    error.Clear();
> +    return ret;
> +}
> +

Should we be hardcoding the C notion of false == 0 and true == 1?
Could we instead not do something like

bool
ValueObject::IsLogicalTrue()
{
 Language *language = Language::FindPlugin(GetObjectRuntimeLanguage())
if (language)
  return language->IsLogicalTrue(*this);
else
 // we could fall back to your algorithm in that case since we don’t have a language plugin for C?
}

Thanks,
- Enrico
📩 egranata@.com ☎️ 27683

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20151030/1369d6bb/attachment.html>


More information about the lldb-commits mailing list