[cfe-dev] Clang tooling and absolute filenames

Manuel Klimek klimek at google.com
Fri Apr 19 06:44:49 PDT 2013

On Fri, Apr 19, 2013 at 3:24 PM, Jonathan Anderson <
jonathan.anderson at cl.cam.ac.uk> wrote:

> On Friday, 19 April 2013 at 12:53, Manuel Klimek wrote:
> > That would be me :)
> Nice to meet you. :)
> > What breaks due to that disagreement?
> I have a string constant in foo.ll that is generated from __FILE__
> ("foo.c"). This string constant is used during instrumentation to look up
> information in my analysis results file, which contains information from
> all translation units. The trouble is, the analysis doesn't know about
> "foo.c", even though I ran it with "analyse foo.c"; it thinks the file is
> called "/Users/jon/[…]/foo.c".
> I currently get around this by running my analysis results through sed to
> remove the "/Users/jon/[…]/" part, but that's pretty hacky (and it won't
> work if I switch my protobuf output from text representation to binary).
> Another approach would be to modify my makefile to pass absolute filenames
> to Clang (in which case its __FILE__ would match what's in the analysis
> file), but I might like to distribute the analysis file along with the
> source files it describes, in which case I really, really don't want to be
> stuck with absolute filenames.

I still don't understand how the compilation and the analysis are related,

> The problem with relative paths is when you get a path handed in, and
> you're trying to figure out which command line applies to it.
> Sure, it's the same issue that I have, but the relative-absolute problem
> goes the other way. The problem with the current approach is that the
> desire to use absolute filenames in one case *precludes* the ability to use
> relative filenames in the other case. If Clang's Tooling framework
> defaulted to using "whatever string is passed on the command line" as the
> filename, however, projects that require absolute filenames could use them
> but other projects (like mine) that prefer relative names can use those.

Perhaps I don't need to - as far as I understand what you want to change is
basically the filename that gets passed to clang as the "main source file
name". That sounds like it makes sense. If you whip up a patch and send it
to me (preferred on llvm-reviews.chandlerc.com) I think that makes sense...

Or correct me if I seem to have misunderstood your goal...


> Jon
> --
> Jonathan Anderson
> Research Associate
> Computer Laboratory
> University of Cambridge
> jonathan.anderson at cl.cam.ac.uk
> +44 1223 763 747
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130419/37d408e6/attachment.html>

More information about the cfe-dev mailing list