doctaweeks / include-what-you-use

Automatically exported from code.google.com/p/include-what-you-use
Other
0 stars 0 forks source link

GetCanonicalName improvements #15

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The attached patch provides the following improvements to GetCanonicalName:

* .cxx and .cpp extensions are handled (I'm using the same list as used in 
IsHeaderFile() - perhaps .inl should be considered too)
* Path separators are canonicalised on Win32. Our build system provides search 
paths with forward slashes as separators, but paths with backslashes creep in 
somewhere. So foo\bar\baz.h and foo/bar/baz.h should now be considered the same.

I've added a couple of tests for the first case to the testsuite, but the 
README suggests that there's no framework for the 'more_tests' tests yet. When 
this is available I'll add some extra tests for separator canonicalisation.

There are a few TODOs:

* CanonicalizeFilePath should probably collapse '../' sequences, i.e. a/b/../c 
and a/c should be considered the same (this is handled nicely by 
PathCanonicalize on Win32, perhaps there's a nice Unixy equivalent?) 
* We should probably ignore case on Win32.

(BTW there is a 'canonicalize()' function in llvm/Support/FileSystem.h which 
would do what we want, but it doesn't seem to be implemented :/ )

Original issue reported on code.google.com by paul.hol...@gmail.com on 23 Feb 2011 at 8:31

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks!  Applied at r33.

You're right that we should probably combine the list used in IsHeaderFile() 
and the list used in iwyu_path_util.  Probably we should provide two functions 
in iwyu_path_util, one that marks headerfile-like names and one that marks 
sourcefile-like names, and use those two functions both to canonicalize the 
path and in IsHeaderFile().

Original comment by csilv...@gmail.com on 24 Feb 2011 at 9:15

GoogleCodeExporter commented 9 years ago

Original comment by csilv...@gmail.com on 24 Feb 2011 at 9:15