[PATCH] D19842: In openFileForRead, attempt to fetch the actual name of the file on disk -- including case -- so that clang can later warn about non-portable #include and #import directives.
David Majnemer via llvm-commits
llvm-commits at lists.llvm.org
Tue May 3 17:11:53 PDT 2016
majnemer added inline comments.
================
Comment at: lib/Support/Unix/Path.inc:560-561
@@ +559,4 @@
+ if (HasProc) {
+ char ProcPath[64];
+ int N = snprintf(ProcPath, sizeof(ProcPath), "/proc/self/fd/%d", ResultFD);
+ assert(N > 0 && N < sizeof(ProcPath));
----------------
eric_niebler wrote:
> majnemer wrote:
> > I think it'd be nicer to build a twine like so:
> > SmallString<32> ProcPathStorage;
> > StringRef ProcPath = Twine("/proc/self/fd/").concat(ResultFD).toNullTerminatedStringRef(ProcPathStorage);
> Serious question: why is that nicer?
snprintf engages a ton of machinery behind the scenes, twine is much lighter weight.
http://reviews.llvm.org/D19842
More information about the llvm-commits
mailing list