[PATCH] D27506: [ELF] - Print absolute file name in errors when possible.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 7 11:42:36 PST 2016


grimar added inline comments.


================
Comment at: ELF/InputFiles.cpp:95
+  std::string Ret = Info.FileName + ":" + std::to_string(Info.Line);
+#ifdef LLVM_ON_WIN32
+  // Converts path to use unix path separators so error message is
----------------
ruiu wrote:
> grimar wrote:
> > ruiu wrote:
> > > grimar wrote:
> > > > ruiu wrote:
> > > > > Add a blank line before #ifdef.
> > > > I am going to export convertToUnixPathSeparator from \llvm\tools\lld\lib\Core\Reproduce.cpp as was requested by Rafael and use it here instead.
> > > OK, but if it involves packing into SmallString and unpack it to std::string, it would be uglier than this, so please upload a patch after you make a change. Thanks.
> > It did not involve packing/unpacking..
> Use `Ret.data()` instead of `&Ret[0]` because the latter is invalid if Ret is empty. (That shouldn't happen in this case, but always avoiding `&Ret[0]` is a good idea.)
That is true, but data() returns const char*, that why I did not use it as it requires cast then.
It is not very clean to remove const, though in c++ 11 it is safe to modify pointer returned by data() afaik.

Do you really prefer:
```
convertToUnixPathSeparator({(char*)Ret.data(), Ret.size()});
```
?


https://reviews.llvm.org/D27506





More information about the llvm-commits mailing list