Fwd: [PATCH] Fixing a driver bug where clang cannot locate source file at drive root
arthur.j.odwyer at gmail.com
Mon Jul 1 22:42:40 PDT 2013
[Re-sending, since mailing the Reply-To: apparently failed to do anything.]
If I recall correctly from my DOS/Windows days, "C:test.c"
really means "the file named test.c in the current working directory
associated with C:", and is not generally equivalent to "C:\test.c".
(Windows maintains separate current working directories for each
different drive letter.) Corroboration:
You should double-check that the current behavior is actually a bug;
maybe you're just in the wrong directory when you run clang.
On Mon, Jul 1, 2013 at 10:11 AM, Yunzhong Gao
<Yunzhong_Gao at playstation.sony.com> wrote:
> ygao added you to the CC list for the revision "Fixing a driver bug where clang cannot locate source file at drive root".
> If I run the following command on Windows, I get an error that clang cannot find the source file. MinGW/GCC seems to work fine.
> C:> clang C:test.c
> error: error reading 'C:test.c'
> 1 error generated.
> This change attempts to fix it by patching the directory name if the directory name is the same as a drive name.
> I am not sure how to write a regression test for this bug :(
> Any suggestions? Maybe write a test that copies itself to the drive root at the beginning of the RUN line?
> Would appreciate it if someone could review and commit this for me.
> Many thanks,
> - Gao.
> Index: lib/Basic/FileManager.cpp
> --- lib/Basic/FileManager.cpp
> +++ lib/Basic/FileManager.cpp
> @@ -293,6 +293,14 @@
> DirName = DirName.substr(0, DirName.size()-1);
> +#ifdef LLVM_ON_WIN32
> + // Fixing a problem with "clang C:test.c" on Windows.
> + // Stat("C:") does not recognize "C:" as a valid directory
> + if (DirName.size() > 1 && DirName.back() == ':' &&
> + DirName.equals_lower(llvm::sys::path::root_name(DirName)))
> + DirName = DirName.str() + '\\';
> llvm::StringMapEntry<DirectoryEntry *> &NamedDirEnt =
More information about the cfe-commits