Commit Graph

49 Commits

Author SHA1 Message Date
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
Volodymyr Sapsai 23285f14f4 Update to reflect getOptionalExplicitTemplateArgs changes in Clang.
Clang r256359 removed `getOptionalExplicitTemplateArgs` on various Expr
subclasses. Use
  `void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const`
instead.

`const ASTTemplateKWAndArgsInfo *getTemplateKWAndArgsInfo() const` doesn't look
like appropriate replacement because it checks only `HasTemplateKWAndArgsInfo`
and we'll need to do `hasExplicitTemplateArgs()` checks ourselves.
2015-12-24 00:52:13 -08:00
Kim Gräsman 4f0227be66 Fix issue 129: Unused templates are ignored on Windows
On Windows builds of Clang/IWYU -fdelayed-template-parsing
is enabled by default. This means parsing of (function) templates
is delayed until instantiation time. If a template is never
instantiated, it is never parsed.

This is terrible behavior for IWYU, where we must traverse code
in templates looking for uses, whether they're ever instantiated
or not. So we run a separate pass that force-parses all late-
parsed FunctionDecl, building their AST before IWYU analysis.

Fixes a number of prefix_header tests that were previously failing
on Windows.
2014-08-20 19:48:06 +00:00
Volodymyr Sapsai ceedc4efa4 Omit anonymous and inline namespaces in OneUse symbol names (fixes issue #133).
Instead of using NamedDecl full qualified name, suppress unwritten scopes.  It
makes libc++ symbol names the same as libstdc++.
2014-06-01 10:20:00 +00:00
Kim Gräsman 9145f59e2f Implement PrintableASTNode and PrintableStmt.
I miss these whenever I'm doing printf debugging, so I thought
I'd implement them once and for all. No functional change.
2014-05-03 21:04:51 +00:00
Volodymyr Sapsai d5b7c12e68 Introduce CHECK_UNREACHABLE_("message") instead of CHECK_(false && "message").
Some discussion regarding this change can be found in issue #117.
2013-12-31 15:38:47 +00:00
Volodymyr Sapsai c412fdad4c Fix -Wcovered-switch-default warnings (issue #117). 2013-12-30 19:21:43 +00:00
Kim Gräsman fd4d272e27 Fix issue 62: Covariant return type not detected
Trigger covariant return types on any method where derived return type is different from base return type.
2013-02-10 21:42:39 +00:00
Volodymyr Sapsai f79cbf30b0 Fixed reporting destructor usage for objects created with 'new' (issue #65). 2012-08-19 22:11:16 +00:00
FFabioFracassi b52e7fcf91 Fixed Constructor handling for clang post r150682 (solves issue 65) 2012-03-10 14:04:37 +00:00
csilvers+iwyu f7de7cb7f6 Monday morning, time for an integrate.
Changes of particular note:
* Resolved merge conflicts in:
third_party/llvm/libcxx/src/exception.cpp
third_party/llvm/llvm/tools/clang/lib/Driver/Tools.cpp
third_party/llvm/llvm/tools/clang/tools/driver/cc1_main.cpp
* Manual edits to
third_party/llvm/llvm/tools/clang/lib/Tooling/Tooling.cpp
due to diagnostic classes renaming
* Fixed up Cymbal, Grok and IWYU code for various class renamings

R=chandlerc,csilvers,chrsmith


Revision created by MOE tool push_codebase.
MOE_MIGRATION=3337
2011-09-26 19:46:13 +00:00
csilvers+iwyu 43fcb7fd19 Normalize the namespace qualifications of no_forward_declare symbols.
This fixes an issue I ran across where I couldn't inhibit the forward declaration
of a symbol defined in an anonymous namespace.

R=csilvers
DELTA=59  (53 added, 0 deleted, 6 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=3326
2011-09-26 19:45:57 +00:00
csilvers f7440f1379 Upstream renamed clang::ExplicitTemplateArgumentList; this breaks the
build for iwyu.

According to the comment this was just a rename.

Patch by lars.sch...@math.uni-erlangen.de

Resolves
   http://code.google.com/p/include-what-you-use/issues/detail?id=61
2011-09-23 18:47:27 +00:00
csilvers+iwyu c5a6d52e7b Belatedly making changes according to Chandler's comments.
I don't know how to word some of the comments -- in particular, I don't
know reasons besides not ever being instantiated for the definition
to be unknown at this point.
One big change here: GetDefinitionForClass always returns a RecordDecl.

R=csilvers,chandlerc
DELTA=43  (0 added, 24 deleted, 19 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=3312
2011-09-23 16:12:28 +00:00
csilvers+iwyu 66388e6410 iwyu was egregiously wrong in how it handled template
arguments using the 'precomputed cache'.  In such situations,
it totally ignored the currently active resugar_map, replacing
it with one of its own.  That worked fine for types outside of
templates, but not fine for types inside (such as a 'hash_map<T>'
inside a templated class).

I "fixed" this.  "Fixed" is in quotes because this turned up a
whole slew of other problems I don't even attempt to resolve
here (though I spent a few hours trying).  One is that it's
possible to have a type like hash_map that has some arguments
that are dependent and some that aren't; in theory, for these
types, we can correctly attribute the use to the template
author or template instantiator depending on which type it
is.  But I can't figure out how to get clang to do any
meaningful analysis of incomplete (dependent) types, so I've
punted on that for now.

The second thing wrong is I jumped through all sorts of hoops
to handle default template arguments correctly, so if a class
has a hash_map<T> and you instantiate T with string, you're
also made responsible for hash<string>.  This *should* work,
but clang is giving hash<string> a type I don't expect
(RecordType, not TemplateSpecializationType), and I don't know
how to deal with that -- I don't know how to extract the
'string' part of this RecordType.  Ugh.  I punt on this now,
as well.

Even in this incomplete form, it's enough to resolve a P1 bug,
so I figure it's worth putting in.

R=dsturtevant
DELTA=141  (97 added, 7 deleted, 37 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=3147
2011-08-31 11:42:23 +00:00
csilvers+iwyu c11ac95479 Opensource iwyu is failing to compile because of missing using
statements for cast, isa, and dyn_cast.  I don't know what's
changed (maybe upstream took out a using statement somewhere
that we were depending on?), but it was our bad in the first
place, so I'm happy to fix it.

Because we try not to use using statements in .h files, I just
prefixed ::llvm:: there when appropriate.

R=wan
DELTA=13  (8 added, 0 deleted, 5 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=2674
2011-07-20 22:45:48 +00:00
csilvers+iwyu 100ff1336b Ignore forward-declares of enums (legal, but not interesting
to iwyu).  Fixes a crashing bug when they occur, due to a
failed assert elsewhere in the code that we only
forward-declare classes.

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


Revision created by MOE tool push_codebase.
MOE_MIGRATION=2414
2011-06-27 20:45:07 +00:00
csilvers+iwyu 34494348e5 Include-what-you-use fixit over iwyu itself
R=csilvers
DELTA=32  (2 added, 16 deleted, 14 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=1982
2011-05-23 23:07:01 +00:00
csilvers+iwyu 33c7208a98 Avoid a couple of warnings found in opensource iwyu: class ->
struct, and an unused var in non-debug mode.

R=wan
DELTA=3  (0 added, 0 deleted, 3 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=1977
2011-05-23 23:03:57 +00: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 debefe0e5d Change on 2011-05-04 06:41:44-07:00 by dsturtevant
Remove duplicate forward declare suggestions. The problem arises if
	two analyses of the same file suggest forward declarations with
	differently-named template arguments.

	R=csilvers
	DELTA=54  (48 added, 0 deleted, 6 changed)

Change on 2011-05-04 10:05:05-07:00 by csilvers

	While exploring another bug regarding default template
	parameters, I ran across this one, where we wrongly required a
	full type when none was available.  This bug, at least, is
	easy to fix.

	R=dsturtevant
	DELTA=44  (36 added, 0 deleted, 8 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=1737
2011-05-04 18:33:53 +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 3f0a6a763e Add the ability to add arbitrary comments to the warning
messages that iwyu produces (and that are shown with
--mode=why for iwyu.py).  Use this ability to comment two
non-obvious warnings we give: when requiring a full use
because of autocasting (one-arg, not-explicit constructor),
and when requiring a full use for the return type of a
function declaration.  Update appropriate existing tests to
check for the comment when appropriate.

R=wan,dsturtevant
DELTA=173  (82 added, 25 deleted, 66 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=1726
2011-05-04 18:21:22 +00:00
csilvers+iwyu 2fdb2c53d2 Small cleanup: rename GetRedecls to GetNonclassRedecls, to
distinguish it farom GetClassRedecls.  I've decided to keep
the two separate since classes and not-classes are treated
very differently in iwyu, so iwyu code shouldn't (I don't
think) be calling a common function for both.  If that proves
to be wrong, we can combine them later, but I want us to at
least be thinking about whether it's the right thing to do.

R=wan
DELTA=14  (4 added, 0 deleted, 10 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=1607
2011-04-26 23:26:11 +00:00
csilvers+iwyu 24c18e03f2 First shot at allowing code-authors to use forward-declares as
a signal to iwyu that it should not use its
stricter-than-required rules for typedefs and autocasts (that
is, iwyu requires the full type for Foo in 'typedef Foo
MyTypedef' while C++ does not).

It's a 'first shot' because we make no attempt to deal with
template arguments that may appear in underlying types.  But
otherwise, it should be pretty complete.

Along the way -- not entirely related, but showed up in
testing -- fixed a place where we were declaring a use where
we shouldn't have been: when forward-declaring a template
type, we were were saying we 'used' the type we were
declaring.  This isn't true: a declaration isn't a use.
Normally it didn't cause any problems (the declaration and use
are in the same file!) but it did in the test, because it was
a forward-decalred explicit specialization, which is I guess
something I'd never done before.

R=wan,dsturtevant
DELTA=628  (567 added, 18 deleted, 43 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=1602
2011-04-26 23:23:56 +00:00
csilvers+iwyu c1e380afa6 Correctly deal with non-class types that can be redeclared:
functions, typedefs, etc.  We just require one of the redecls
to be visible, not all of them.

This fix isn't perfect -- we just check for redecls in the
same file as the use, and don't do all the complicated stuff
we do to pick the 'best' #include for a redecl if necessary,
like we do for forward-declarations.  (The situation is
different, since we are willing to suggest adding a new
forward-decl for a class, but not for these other types like
functions.)  But it's still better than it was before.

Submitting TBR since it's the weekend, and this is a
pre-requisite for getting the big typedef fix in.


Revision created by MOE tool push_codebase.
MOE_MIGRATION=1600
2011-04-26 23:23:09 +00:00
csilvers+iwyu 58bb27dbbe In preparation for my typedef-fixing work: GetClassRedecls()
should really just work on both normal classes and class
templates.  Changed the API so it does.

R=wan
DELTA=71  (30 added, 13 deleted, 28 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=1596
2011-04-26 23:16:24 +00:00
csilvers+iwyu 4813f2716e Handle dependencies on 'using' declarations properly. If we
use a type via a using declaration, we need to make sure to
use that using declaration as well.  It may be in a different
file from the type!

There may be corner cases we don't handle right yet, but we do
the right thing at least most of the time.  One case we don't
handle is when there's a using declaration but we ignore it
('using foo::a; foo::a = 1').  We'd do better if clang would
report whether a given decl-use was via a using declaration or
not, but right now it doesn't.  cf:
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-April/014564.html
(though that applies only to using vars, not functions).

In order to implement this reasonably, I had to (finally!)
unify the type and decl reporting in iwyu.cc, rather than
iwyu_output.cc.  This allows me to remove a bit of duplicated
code, and also makes the logic easier to follow.

R=dsturtevant
DELTA=358  (286 added, 71 deleted, 1 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=1576
2011-04-26 23:05:45 +00:00
csilvers+iwyu b43413113a Cleanups based on wan's suggestions:
* Refactored some ast-checking routines into iwyu_ast_util.
* Use more 'clang'-y logic to decide what decl comes first.
* Improved comments and readabilty a bit.

R=wan
DELTA=73  (49 added, 18 deleted, 6 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=1561
2011-04-26 22:58:17 +00:00
csilvers+iwyu 056e1acbb0 My check for whether a class was nested or not was entirely
broken -- it left out the common case that the class is being
used inside the outer class without a qualifier.  A new test
shows where we would do the wrong thing in that case.

Fixing this brought up more problems, that could all be traced
to the fact we 'cheat' and create fake uses of
forward-declares when we want to be sure not to delete them.
I get rid of the cheating and just say, when we see a
forward-decalare, whether we want to definitely-keep it or
not.  That yields much nicer code (I think).

I also don't know what I was thinking when I said "if there
are multiple fwd-decls in a class, just keep one arbitrarily."
Obviously we should keep the first one; the arbitrary one may
come too late.  These changes brought that bug to light too
(an existing test started failing), but now it's squashed.

Finally, I resolved a TODO, getting rid of
IsDeclNodeInsideFriend.  I had known this was possible for a
while, I just had never gotten around to actually doing it.
Doesn't affect any tests.

R=dsturtevant
DELTA=141  (75 added, 26 deleted, 40 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=1453
2011-04-14 04:48:03 +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 8957d078c0 The code that used the precomputed cache for template
instantiation was using the resugar-map wrong: it wasn't
treating compnent types properly.  In this case, we don't want
all component types, but only the actual template argument
types.  (However, we do want to do a *separate* full-use check
on each of the component types.)

This manifested as iwyu saying we need full-type information
for Foo in set<Foo*>.  This fixes that, and beefs up the
relevant tests.

It also fixes issue
http://code.google.com/p/include-what-you-use/issues/detail?id=27

R=wan,dsturtevant
DELTA=50  (39 added, 6 deleted, 5 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=1277
2011-04-06 20:08:20 +00:00
csilvers+iwyu 6fd385a7c7 Reporting template uses at TemplateName is the wrong place --
at that point we had already lost info about what
specialization of the template we might be using.  We have to
report at TemplateSpecializationType.

This seems like a small change, but was surprisingly difficult
to get right.  I ended up having to change from reporting it
as a type to reporting it as a decl, which shouldn't matter
but does, probably indicating some fragility elsewhere in
iwyu.  I did notice some other fragility problems, such as
GetClassDefinition() converting from a templated class to its
non-templated sibling, which I've fixed up.

I also fixed a bug in iwyu_output.cc where it would seem to
ignore definitions in the same file for things that only need
to be forward-declared.  I'm not sure why this never came up
before; probably some other part of the codebase covered for
us (at least usually).  But it seems obviously correct that if
we define a class in foo.cc, that should count the same as
defining it in one of the files foo.cc #includes.  That's done
now.

R=dsturtevant
DELTA=208  (131 added, 51 deleted, 26 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=1080
2011-03-26 22:20:26 +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 ae056dfcab Refactor iwyu_ast_util, moving most of the code into a .cc
file.  When you reach >1300 lines long, you deserve your own
.cc file. :-)

No functionality should change -- the only changes I made were
to get rid of the clang:: prefix now that I live in a .cc
file and to combine lines that got short enough as a result.

R=dsturtevant
DELTA=1738  (955 added, 714 deleted, 69 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=904
2011-03-18 06:59:00 +00:00
csilvers+iwyu 287cea3a5b Due to a logic-bug in GetFirstClassArgument, we weren't
correctly identifying when something was a class argument if
it happened to be a typedef.  Desugar first so we can make the
determination properly.  This makes badinc output a bit more
sensible since now operations that modify iterators actually
depend on the iterator type.

R=dsturtevant
DELTA=7  (4 added, 1 deleted, 2 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=896
2011-03-18 02:53:26 +00:00
csilvers+iwyu 55552e6cbe It turns out the problem with failing tests wasn't due to
handling of elaborated types at all, but instead was because
RecursiveASTVisitor changed from calling
TraverseNestedNameSpecifier to TraverseNestedNameSpecifierLoc
for most nns's.  We didn't subclass
TraverseNestedNameSpecifierLoc so we were missing a lot of
NNS's.

This CL backs out the previous change, and replaces it with code to
intercept and handle NNSLoc's.  The end result is the same --
badinc.cc is down to two failing tests (which are perhaps
unrelated to the clang upgrade, but instead due to changes to
iwyu itself).

I also fixed up the last two remaining badinc failures.
They were both caused by a type that I expected to be a
TemplateSpecializationType, but was actually an
ElaboratedType, because it was std::vector<...>.  (So maybe
there *was* a change wrt elaborated types in the clang code.)
I audited iwyu_ast_util.h to make sure I was putting
RemoveElaboration() calls in all the necessary places.
Hopefully I got them all...

In tracking this down, I found another bug in the same area
(nested template specializations), but I'll deal with that in
a different CL.

R=dsturtevant
DELTA=132  (75 added, 43 deleted, 14 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=895
2011-03-18 02:53:09 +00:00
csilvers+iwyu 1d3f11cfad The latest clang update changed the way elaborated types were
handled, which broke iwyu in several different ways.  We
didn't notice at the time because run_iwyu_tests was silently
broken and not running any tests.  Now that that's fixed, we
see the trouble.

This CL fixes a few of the problems -- more remain that I
haven't been able to figure out yet.  Basically, an elaborated
class type (a superclass in something like Foo::FooSubclass)
is now stored as an elaboratedtype that's a sibling to
FooSubclass, rather than as a NestedNameSpecifier that's a
parent to FooSubclass.  I'm not sure I understand why, but
that's not my job...

The main fix is to add a new IsClassElaborationQualifier()
function, which abstracts out the test for whether we're a
superclass in a context like Foo::FooSubclass.  We now use
that both for regular types and for template-argument types.

Another, seemingly unrelated fix -- that may be due to a
different change in clang -- fixes the handling of
typedefs-to-typedefs.  I don't know why they worked before,
actually, so maybe this was a bugfix in clang.

More or less unrelatedly, also do a few style cleanups in the
preprocessor file.

R=dsturtevant
DELTA=51  (39 added, 2 deleted, 10 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=892
2011-03-18 02:52:12 +00:00
csilvers+iwyu aad4c62b13 Fix up the handling of fwd-decls in some situations. These
situations are ones where iwyu requires a full definition but
the language allows a forward-declare.  This causes trouble in
cases like:
class Foo;
typedef Foo Bar;
class Foo { ... };

In this case, we require the full definition of Foo for the
typedef, which leads us to believe the forward-declaration is
extraneous, even though it's actually necessary.

I fix this by detecting when iwyu wants a definition that
occurs after the use, and making iwyu want the
forward-declaration then as well.

While testing this, I found some bugs in the existing code
that tries to handle forward-declarations inside classes -- it
wasn't handling uses in initializers (which should be treated
like method bodies) or the implicit destructor code.  I added
logic (and tests) around those.

I also discovered a bug where GetDefinitionAsWritten() was
sometimes converting templated class to the untemplated
CXXRecordDecl version.  GetDefinitionAsWritten() should
preserve the templated-ness of is argument.  It does so better
now.

R=dsturtevant
DELTA=159  (135 added, 5 deleted, 19 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=739
2011-03-04 00:30:28 +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+iwyu fe45cabe52 Attempting to get nested class forward declarations right.
R=csilvers,wan
DELTA=145  (96 added, 2 deleted, 47 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=731
2011-03-04 00:26:01 +00:00
csilvers+iwyu 1b9459749d Make sure ASTNode::ContentIs() always fails if the types don't
match.  This is necessary when the input is NULL.

R=dsturtevant,wan
DELTA=7  (3 added, 0 deleted, 4 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=724
2011-03-04 00:00:56 +00:00
csilvers c8053e734f 1. Update three tests to increase their coverage a bit:
sizeof_reference, varargs_and_references, template_function_arg.
2. Add code to print a given ASTNode, no matter what kind of node it is.
3. Print the node contents in the ast-node flattener, at debug level 7.

All code written by csilvers, and reviewed by wan and dsturtevant.
2011-02-15 23:23:27 +00:00
csilvers 4ba3299fc0 A few cleanups; no functionality change.
1) Removed the use of <tr1/tuple> -- it wasn't getting us that much,
and cost us in portability.  Resolves
   http://code.google.com/p/include-what-you-use/issues/detail?id=2

2) Removed unused 'using' statements, renamed some vars to be cleaner,
added 'const' in a few places I could, etc.

3) Refactored some logic into a new function GetCalleeFunctionType().

4) Made a few tests more robust by using better fakes (mostly in
more_tests, so not directly relevant to the opensource code).

5) Added a check to make sure we don't add any new include-mappings
after we were supposed to have finialized the mappings.

All code reviewed by wan and/or dstur...
2011-02-11 23:08:41 +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