Commit Graph

26 Commits

Author SHA1 Message Date
Kim Grasman 56dbfbe9ca Remove Google-specific handling of third-party
This is part of Google's original open-sourcing of IWYU.

They keep third-party libraries in a directory called, well,
'third-party', so there was lots of special casing for code in
that directory.

Remove that code, unit tests covering it and explicit mappings.

Keep one special case for allowing include cycles for files with
'internal/' in the name, to avoid breaking the include_cycle test
case. Not sure what to do about that longer term, but I didn't want to
remove the test case right now.
2019-03-10 21:45:20 +01:00
Flamefire 23119ba66a Use absolute paths to build include names
This has been a long-standing issue with IWYU (see issues #5, #271 and
probably others) where ConvertToQuotedInclude generates absolute paths
if IWYU is invoked with the current directory different from the source
file path.

This patch moves most path building to use absolute paths and path of
the includer (rather than the cwd) to produce better results.
2016-06-08 08:23:26 +02:00
Kim Grasman e58967a2ec Make header guards consistent
- Remove DEVTOOLS_MAINTENANCE_ from header guards, that was a
  now-unnecessary Googleism

- Fix header guard to match filename in all production code

- Fix header guard to match path in all tests
2016-05-25 22:17:31 +02:00
Flamefire 6cf6b76a43 Remove CanonicalizeFilePath and add NormalizeDirPath 2016-05-18 20:54:58 +02:00
Kim Grasman 7c700e8ca5 Fix #210: Avoid mis-stripping of same path prefix
If two paths in the header search set shared the same prefix, IWYU would
sometimes pick the wrong one and produce an invalid quoted include. For
example:

Header search path: /a/foo, /a/foobar
File path: /a/foobar/header.h

This would yield "bar/header.h", as "/a/foo" was considered a basename of
the file path.

We fix this by ensuring all search path entries end with "/" up-front.

I didn't add a test for this, because an end-to-end test would be almost
nonsensical. Once we get the unit test suite up and running, I'd like to
add a test for this there instead.
2015-11-23 20:51:50 +01:00
Kim Gräsman 49b0d89ba0 Remove unused function GetCWD
- No longer necessary to define _POSIX_ for MSVC builds
- Remove some cruft from port.h
- Remove unused direct.h/unistd.h includes
- Clean up includes in iwyu_path_util.h
- No functionality change intended
- Tested on Win32/MSVC + Linux/GCC
2013-03-19 20:53:26 +00:00
Volodymyr Sapsai 40999861b2 Enhanced search paths of mapping files. Patch by Kim Gräsman.
Search for mapping files:
- in the current working directory;
- in the directory where IWYU executable is located;
- in the directory where another discovered mapping file is located.
2012-11-25 21:26:06 +00:00
csilvers+iwyu c23f0b9eef Some refactoring to straighten out dependencies.
This was motivated by an attempt to understand how iwyu_ast_util.cc
depended on iwyu_output, which turned out to be the use of VERRS.
I split the VERRS definition out into a separate iwyu_verrs module.
In the fallout from this I discovered some circular dependencies
that this CL attempts to disentangle.

R=csilvers
DELTA=603  (349 added, 222 deleted, 32 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=3892
2011-12-01 02:30:18 +00:00
csilvers+iwyu 2e988bfe45 Apply a patch by ryan.pav..., recognizing more types of .h
files and include structures.  See
http://code.google.com/p/include-what-you-use/issues/detail?id=58

R=dsturtevant
DELTA=9  (8 added, 0 deleted, 1 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=2970
2011-08-12 00:35:17 +00:00
csilvers+iwyu a15c84b30c Don't ask me why, but the automated system I use for updating patches wants to undo Paul Holden's latest patches and then re-apply them. I'm sure there's a way to skip doing that, but I don't know what it is, so I'm going to let it do its thing. This is step 2 (the re-apply).
Revision created by MOE tool push_codebase.
MOE_MIGRATION=2806
2011-08-01 20:58:24 +00:00
csilvers+iwyu 60272bf071 Don't ask me why, but the automated system I use for updating patches wants to undo Paul Holden's latest patches and then re-apply them. I'm sure there's a way to skip doing that, but I don't know what it is, so I'm going to let it do its thing. This is step 1 (the revert).
Revision created by MOE tool push_codebase.
MOE_MIGRATION=2805
2011-08-01 20:57:19 +00:00
paul.holden 624f2927c3 When running IWYU on Windows, it's possible for paths to come into the system with a mix of backslashes and forward slashes. This patch ensures that paths on Windows are correctly canonicalized as they enter the system, which means that the rest of IWYU's path-handling code can safely assume that it only needs to deal with forward slashes as directory separators. This resolves http://code.google.com/p/include-what-you-use/issues/detail?id=54. Reviewed by csilvers. 2011-07-21 07:54:01 +00:00
csilvers+iwyu 8ad81c9a09 [all changes by paul holden]
Recognise .hpp,.hxx and .hh files when generation recommendations. Resolves http://code.google.com/p/include-what-you-use/issues/detail?id=46. Reviewed by csilvers.

Fix some asserts which can fire when running with verbose output at level 3 or greater. This resolved http://code.google.com/p/include-what-you-use/issues/detail?id=50. Reviewed by csilvers.

Add support for IWYU pragmas using C-style comments. Fixes part of http://code.google.com/p/include-what-you-use/issues/detail?id=36. Reviewed by csilvers.

Fix the line endings on files added in r272 (they were CR+LF, not LF - sorry!)

Revision created by MOE tool push_codebase.

R=dsturtevant
DELTA=72  (68 added, 0 deleted, 4 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=2652
2011-07-20 19:04:54 +00:00
csilvers+iwyu c9e330f23b Cleanup: add missing stddef.h (for offsetof).
Tested:
blaze test --crosstool_top=//third_party/crosstool:{v14,v15}-unstable \
devtools/maintenance/include_what_you_use/...

R=dsturtevant,csilvers
DELTA=1  (1 added, 0 deleted, 0 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=2636
2011-07-20 19:04:03 +00:00
paul.holden 7be7eac32c Recognise .hpp,.hxx and .hh files when generation recommendations. Resolves http://code.google.com/p/include-what-you-use/issues/detail?id=46. Reviewed by csilvers. 2011-07-19 08:16:06 +00:00
csilvers+iwyu 3392c4d1e9 Improve the heuristic for identifying associated .h files.
Here's the new (additional) rule:

If there's is a .h in the first include of a .cc its basename
is the same as the .cc except for the extension then assume
it's the header implementing that file.

I had to modify the test framework a bit to capture test files
in subdirectories.

R=nilton
DELTA=91  (77 added, 0 deleted, 14 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=2483
2011-07-02 00:06:22 +00:00
csilvers+iwyu 256da9418d Include-what-you-use fixit -- run iwyu on itself to fix up includes (part 2).
R=csilvers
DELTA=51  (3 added, 47 deleted, 1 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=1736
2011-05-04 18:32:59 +00:00
csilvers+iwyu 5ca17d139e Include-what-you-use fixit -- fix #includes on iwyu itself.
R=csilvers
DELTA=123  (22 added, 5 deleted, 96 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=1732
2011-05-04 18:30:53 +00:00
csilvers+iwyu 3d55404056 Include-what-you-use fixes by running it on itself.
R=dsturtevant,csilvers
	DELTA=215  (135 added, 45 deleted, 35 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=1731
2011-05-04 18:29:59 +00:00
csilvers+iwyu ed381497a3 Add a test to protect against syntax errors in main(). Also
test some main()-invariant logic while I'm at it.

DELTA=19  (16 added, 0 deleted, 3 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=1409
2011-04-13 03:11:35 +00:00
csilvers+iwyu 37c67ac363 I was not correctly getting the location for member-exprs. I
thought I was saying the location is where the . (or ->) is,
which is what I want, but clang doesn't actually expose that.
So I have go through some hoops to try to figure it out.

We were actually seeing a problem with this when running:

blaze build --host_cpu=k8 --compile_only -k --crosstool_top=//third_party/llvm/crosstool --plugin=//devtools/maintenance/include_what_you_use:run_iwyu //gws/plugins/local/src:enhanced_listing_ad

It has 'msg_->MSG_foo' in it, where MSG_foo is a macro.  We
were attributing this use to the file defining MSG_foo, rather
than to us.  With this change, we properly attribute it to us.

R=dsturtevant
DELTA=150  (125 added, 6 deleted, 19 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=1347
2011-04-12 05:00:17 +00:00
csilvers+iwyu c13983f294 Testing MOE. Should be a no-op
Revision created by MOE tool push_codebase.
MOE_MIGRATION=744
2011-03-04 00:52:15 +00:00
csilvers+iwyu 5a63e3a5ca At wan's suggestion, reorganize this code to keep the
public/private information in a separate data structure from
the mapping.  Besides being a bit clearer to follow, this
makes it easier to verify that we're consistent in declaring a
file public or private.  We now do verify this, which turned
up a few inconsistencies in the hard-coded data (not anything
major), which I've fixed.

This prompted a bit of a change in the API, to separate out
adding of mappings from adding of public/private-ness.  This
fits the iwyu preprocessor workflow better, allowing us to
resolve a TODO or two.

I've also cleaned up a comment or two.

R=wan
DELTA=186  (81 added, 60 deleted, 45 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=722
2011-03-04 00:00:14 +00:00
csilvers 0587bf76cc 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 :/ )

Resolves
   http://code.google.com/p/include-what-you-use/issues/detail?id=15

Patch submitted by paul.hol...@gmail.com and reviewed by csilvers
2011-02-24 21:14:57 +00:00
csilvers 000a1fff6d Fixes to get code to compile under MSVC 10. Submitted by pichet2...:
http://code.google.com/p/include-what-you-use/issues/detail?id=7
with small changes by csilvers to encapsulate all arch-specific
information in one file, port.h.

Reviewed by csilvers
2011-02-08 06:12:32 +00:00
csilvers dee92b5e0a Initial release! Grains of salt not included. 2011-02-04 22:28:15 +00:00