[llvm-bugs] [Bug 39409] New: fixit should follow symlinks when writing files

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Oct 23 10:28:04 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=39409

            Bug ID: 39409
           Summary: fixit should follow symlinks when writing files
           Product: clang
           Version: 6.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: mblythester at gmail.com
                CC: llvm-bugs at lists.llvm.org

-----------
Test input:
-----------
------
foo_real.cc:
------
#include "foo.h"
void foo( cFoo x){
  (void)x;
}
------
foo_real.h:
------
#include "bar.h"
namespace nFoo{
  class cFoo{};
  class cFooBar: public cBar {};
}
------
bar.h:
------
namespace nBar{
  class cBar{};
}
------
foo.cc is a softlink/symlink to foo_real.cc
foo.h is a softlink/symlink to foo_real.h
------
$ ls -o
total 4
-rw-rw-r-- 1 mblythe 34 Oct 23 12:59 bar.h
lrwxrwxrwx 1 mblythe 11 Oct 23 13:02 foo.cc -> foo_real.cc
lrwxrwxrwx 1 mblythe 10 Oct 23 13:02 foo.h -> foo_real.h
-rw-rw-r-- 1 mblythe 50 Oct 23 12:57 foo_real.cc
-rw-rw-r-- 1 mblythe 85 Oct 23 12:59 foo_real.h
------
Compile command and ouptut:
------
$ clang -c -o foo foo.cc -Xclang -fixit
In file included from foo.cc:1:
./foo.h:5:25: error: unknown class name 'cBar'; did you mean 'nBar::cBar'?
  class cFooBar: public cBar {};
                        ^~~~
                        nBar::cBar
./foo.h:5:25: note: FIX-IT applied suggested code changes
./bar.h:2:9: note: 'nBar::cBar' declared here
  class cBar{};
        ^
foo.cc:3:11: error: unknown type name 'cFoo'; did you mean 'nFoo::cFoo'?
void foo( cFoo x){
          ^~~~
          nFoo::cFoo
foo.cc:3:11: note: FIX-IT applied suggested code changes
./foo.h:4:9: note: 'nFoo::cFoo' declared here
  class cFoo{};
        ^
2 errors generated.
------

----------------
Expected Result:
----------------------
The softlinks/symlinks remain unchanged, and the fixit changes are applied to
the files that they reference.
------
foo_real.cc:
------
#include "foo.h"
void foo( nFoo::cFoo x){
  (void)x;
}
------
foo_real.h:
------
#include "bar.h"
namespace nFoo{
  class cFoo{};
  class cFooBar: public nBar::cBar {};
}
------

-------------------------
Current Incorrect Result:
-------------------------
The softlinks/symlinks are replaced with files containing the fixes:
------
$ ls -o
total 8
-rw-rw-r-- 1 mblythe 34 Oct 23 12:59 bar.h
-rw-rw-r-- 1 mblythe 56 Oct 23 13:20 foo.cc
-rw-rw-r-- 1 mblythe 91 Oct 23 13:20 foo.h
-rw-rw-r-- 1 mblythe 50 Oct 23 12:57 foo_real.cc
-rw-rw-r-- 1 mblythe 85 Oct 23 12:59 foo_real.h
------

I realize that it may be an uncommon or unusual use case to have the source
files be softlinks/symlinks, but I'd expect it to be well-supported.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20181023/ce4ecb37/attachment.html>


More information about the llvm-bugs mailing list