[PATCH] D43934: [ELF] - Report location for div/mod by zero.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 1 08:50:54 PST 2018


>> +Expr ScriptParser::combine(StringRef Op, Expr L, Expr R) {
>>    if (Op == "+")
>>      return [=] { return add(L(), R()); };
>>    if (Op == "-")
>>      return [=] { return sub(L(), R()); };
>>    if (Op == "*")
>>      return [=] { return L().getValue() * R().getValue(); };
>> -  if (Op == "/")
>> -    return [=] { return div(L(), R()); };
>> -  if (Op == "%")
>> -    return [=] { return mod(L(), R()); };
>> +  if (Op == "/") {
>> +    std::string Loc = getCurrentLocation();
>
>getCurrentLocation is pretty expensive. It probably is not critical in
>here, but we should probably keep the style of only calling
>getCurrentLocation() when there is an error.
>
>Cheers,
>Rafael

At the moment when there is a error (calculation of expression)
it is too late to call getCurrentLocation.
(getCurrentLocation returns location in linker script, so we have to call it
during parsing)

Actually we call it often, see ScriptParser.cpp, I believe you are talking about
getLocation probably.

George.


More information about the llvm-commits mailing list