[llvm-bugs] [Bug 40298] New: "clang -c -emit-llvm" deletes input file if the file has invalid format and .bc suffix

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Jan 12 19:55:41 PST 2019


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

            Bug ID: 40298
           Summary: "clang -c -emit-llvm" deletes input file if the file
                    has invalid format and .bc suffix
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Driver
          Assignee: unassignedclangbugs at nondot.org
          Reporter: wangxiayang.fdt at gmail.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

Hi. I found clang deleted my input file as 'Repro' suggested. Partly it was my
mistake by making the input and output files have the same name. But maybe
clang could warn me or abort such compiling action in order not to corrupt my
input file.

Repro:
1. A trivial C program like: void foo() {}
2. Save as test.c
3. $ clang -c -emit-llvm test.c
4. $ llvm-ar rcu test.a.bc test.bc
5. $ clang -c -emit-llvm test.a.bc

Result:
test.a.bc is deleted by clang after 5.

Notes and comments:
1) Step 4 is simply a way to create an invalid LLVM bitcode file with .bc
suffix.
2) Tested with svn repo. "svn info" shows "Last Changed Rev: 351002" and
"Revision: 351007"
3) gcc sometimes reports like 'input and output file have the same name'. So I
wonder whether clang would prefer to warn or abort instead of removing the
input file.

Thank you!

-- 
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/20190113/20f0b406/attachment-0001.html>


More information about the llvm-bugs mailing list