[PATCH] D147256: [DebugInfo] Fix file path separator when targeting windows.

Hans Wennborg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 17 09:52:48 PDT 2023


hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

lgtm



================
Comment at: clang/lib/Driver/ToolChains/Clang.cpp:583
+  llvm::sys::path::Style Style =
+      llvm::sys::path::is_absolute(ObjFileNameForDebug)
+          ? llvm::sys::path::Style::native
----------------
zequanwu wrote:
> hans wrote:
> > zequanwu wrote:
> > > hans wrote:
> > > > Won't the code above (line 580) make many filenames absolute and cause us to use native slashes even when we want backslashes?
> > > > 
> > > > This would also need a test.
> > > > Won't the code above (line 580) make many filenames absolute and cause us to use native slashes even when we want backslashes?
> > > Yes, I don't think we should change anything if it's converted to an absolute path.
> > > 
> > > Only if the `-fdebug-compilation-dir` is not given or is an absolute path, the path in `/Fo` will be converted to absolute path. Users can avoid the path being converted to absolute path by passing a relative path to `-fdebug-compilation-dir`, just like what we do in chrome build (`-fdebug-compilation-dir=.`).
> > > 
> > > Added a test.
> > Apologies for all the questions, but I find the logic a bit complex still. The test cases are helpful though.
> > 
> > Could we simplify by just always using Windows slashes here, regardless of `-fdebug-compilation-dir` etc.?
> The object file path will be converted to absolute path depending on whether `-fdebug-compilation-dir` is given or whether it's absolute path. I don't think we want to change a native absolute path of object file to use Windows slashes. Or this could happen on linux: `/usr/local/src/a.obj` -> `\usr\local\src\a.obj`. So, we only use windows slashes when it's not an absolute path here.
Thanks, that makes sense. Can you add a comment with that explanation?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147256/new/

https://reviews.llvm.org/D147256



More information about the llvm-commits mailing list