Commit Graph

14 Commits

Author SHA1 Message Date
Kim Grasman 7c2ec8f05b Rename port.h -> iwyu_port.h 2019-12-26 16:12:02 +01:00
EugeneZelenko eb7f5d1ef0 Fix Clang-tidy warnings
- readability-redundant-member-init warnings
- modernize nested templates; '> >'
- modernize-use-default warnings
2016-11-16 21:04:24 +01: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
csilvers+iwyu 9d79483b7b A few small fixes to get the build working.
R=wan
DELTA=2  (1 added, 1 deleted, 0 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=1752
2011-05-04 20:52:23 +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 32bf5284e8 Renames Contains() to ContainsKey() to stress that:
1. it only works with an associative container (e.g. set or map),
2. it takes a key_value rather than a value_type.

R=csilvers
DELTA=55  (1 added, 3 deleted, 51 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=1570
2011-04-26 23:02:58 +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 f3aeefb7d0 A major revamp of the way we handle template arguments. The
crux of the change is that the InstantiatedTemplateVisitor no
longer takes a set of types-of-interest, but instead takes a
map called the resugar_map.  The resugar map is a tool to deal
with the fact that clang canonicalizes all substituted
template types (the "T"'s in a written template), so if you
say
typedef int MyTypedef;
template<class T> void MyFunc() { T foo; }
MyFunc<MyTypedef>();
clang will say the body is 'int foo;', not 'MyTypedef foo;'.
This is difficult for include-what-you-use.

There's one entry in the resugar map for every template
parameter.  Each entry has the form <canonical-type,
type-as-written>, to make it easy to map from the canonical
type back to the type-as-written.  When the type-as-written
has component types (e.g. both Foo* and vector<Foo> have a
component type of Foo), there is also an entry for each
component type.

Both template classes and template functions have a
complicating factor.  For template classes, it's default
template args, which are *not* written by the caller and
usually want to attribute to the function-author.  We store
these in the resugar map with a value of NULL, to indicate
they are default arguments that have no as-written form.

For template functions, likewise some or all template
arguments may be omitted by the caller, in which case the
compiler derives them from the function arguments.  We do
something similar, looking for plausible mappings between
types-as-written in template functions (or their components)
and the clang-derived template arguments.  This part could
still use improvement.  To really do it right, we'd need to
refactor SemaTemplateDeduction to take an argument to not
canonicalize deduced template arguments.

In InstantiatedTemplateVisitor, we use the resugar-map
to beef up CanIgnoreType() and ReportTypeUse().  We ignore
types that are not in the resugar map (and thus do not
correspond to template arguments as typed).  When we do use a
type, we resugar it before reporting its use.  The net result
is that we should see much lower incidence of clang reporting
a weird dependency because of a type that the template-caller
has never even heard of.

We also use the fact we can tell an argument is a default
template argument to decide if the template-author or the
template-caller is responsible for the type.  We say the
template-caller is *unless* the author intends-to-provide the
type, based on #includes.  This handles the case when
hash<T> uses the default implementation (in stl_hash, which
stl_hashtable.h #includes) vs when it uses a user-provided
implementation (which stl_hashtable.h obviously doesn't
#include).

Implementation-wise, we needed to beef up HandleFunctionCall
to pass around the calling Expr, which holds the template
arguments as written in some cases.  We also needed to update
the cache to handle the new data structures.

Administrative note: wan reviewed this but had to bow out
before finishing all the back-and-forth, and dsturtevant
reviewed it but didn't feel qualified to judge entirely, so
take the "R=" below with a grain of salt.  This may require
more work in the future.

R=wan,dsturtevant
DELTA=1173  (852 added, 138 deleted, 183 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=1077
2011-03-26 22:16:53 +00:00
csilvers+iwyu 97d04c4a90 Replace assert() by CHECK_, which is always executed, even in
opt mode.

R=wan
DELTA=131  (16 added, 15 deleted, 100 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=738
2011-03-04 00:29:56 +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