[PATCH] D30663: Use filename in linemarker when compiling preprocessed source (Revised)

Taewook Oh via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 6 11:53:04 PST 2017


twoh added inline comments.


================
Comment at: test/Frontend/preprocessed-input.c:3
+// RUN: %clang -emit-llvm -S -o - %t.i | FileCheck %s
+// CHECK: source_filename = {{.*}}preprocessed-input.c"{{$}}
----------------
inglorion wrote:
> Actually, I think you don't even have to run the preprocessor - you can just put the file with the linemarker here and check that the name from the linemarker is propagated, right?
> 
> Also, it seems that there is a similar issue to the one you're trying to fix when going from .ll to .o (or .ll to .s, for that matter) - the name is taken from the file you're reading from, not from the source_filename directive in that file. Of course, that doesn't differ from gcc (given that gcc doesn't handle .ll files), but you may want to address that, too, for consistency.
@inglorion Thanks for the comments! Putting preprocessed file makes sense to me. 

I recognize the second issue. If I do something like

```
clang -E -o test.i /abspath/test.c
clang -g -c -o test.o test.i
```

DW_AT_name is still test.i (for gcc, it is taken from the linemarker as well). 

Moreover, if we use the absolute path of test.i for clang, i.e.

```
clang -g -c -o test.o /abspath/test.i
```

DW_AT_name becomes /abspath/test.i where DW_AT_comp_dir is /abspath. I think this could be a problem if the user of the object file assumes that DW_AT_name is a relative to DW_AT_comp_dir. I'm planning to address this with a separate patch.


https://reviews.llvm.org/D30663





More information about the cfe-commits mailing list