[llvm] r247518 - [llvm-mc] More meaningful error if input file doesn't exist.
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 13 11:08:31 PDT 2015
On Sun, Sep 13, 2015 at 4:43 AM, Rafael EspĂndola
<rafael.espindola at gmail.com> wrote:
> testcase?
>
Will add one.
> Can't this be done by testing the value of EC down at
> BufferPtr.getError() instead of calling sys::fs::exists?
>
> Cheers,
> Rafael
>
Probably it could. I was just mimicing what was already there (e.g. llvm-size).
I will do a sweep over all tools needing this and send out a review,
it's arguably better.
>
> On 13 September 2015 at 00:09, Davide Italiano via llvm-commits
> <llvm-commits at lists.llvm.org> wrote:
>> Author: davide
>> Date: Sat Sep 12 23:09:40 2015
>> New Revision: 247518
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=247518&view=rev
>> Log:
>> [llvm-mc] More meaningful error if input file doesn't exist.
>>
>> Before we just printed on stderr the program name. Now at least we
>> print the name of the file that doesn't exist. There's probably room
>> for improvement of error handling in llvm-mc (and the tools in general),
>> but still this is a step forward.
>>
>> Modified:
>> llvm/trunk/tools/llvm-mc/llvm-mc.cpp
>>
>> Modified: llvm/trunk/tools/llvm-mc/llvm-mc.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/llvm-mc.cpp?rev=247518&r1=247517&r2=247518&view=diff
>> ==============================================================================
>> --- llvm/trunk/tools/llvm-mc/llvm-mc.cpp (original)
>> +++ llvm/trunk/tools/llvm-mc/llvm-mc.cpp Sat Sep 12 23:09:40 2015
>> @@ -395,6 +395,11 @@ int main(int argc, char **argv) {
>> // construct the Triple object.
>> Triple TheTriple(TripleName);
>>
>> + if (InputFilename != "-" && !sys::fs::exists(InputFilename)) {
>> + errs() << ProgName << ": '" << InputFilename << "': "
>> + << "No such file\n";
>> + return 1;
>> + }
>> ErrorOr<std::unique_ptr<MemoryBuffer>> BufferPtr =
>> MemoryBuffer::getFileOrSTDIN(InputFilename);
>> if (std::error_code EC = BufferPtr.getError()) {
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
--
Davide
"There are no solved problems; there are only problems that are more
or less solved" -- Henri Poincare
More information about the llvm-commits
mailing list