Commit Graph

29 Commits

Author SHA1 Message Date
Bolshakov 862812049a Avoid 'autocast' reporting for function definition
A function may just transmit passed-by-reference parameter somewhere.
Requirement to explicitly write forward declaration in the same file
(.cpp-file) to avoid '#include' suggestion is impractical when that type
is already fwd-declared in the corresponding header.
'Autocast' may still make sense for header-defined functions, due to
unlimited number of possible callers, so analysis of those fuctions
is kept.

Both function declaration site handling and call site handling
are changed.
2022-10-08 16:17:50 +02:00
Andrea Bocci 53487d2097 Add explicit conversion from llvm::StringRef to std::string
llvm/llvm-project@777180a makes the llvm::StringRef conversion operator
to std::string explicit.
These changes add a call to the str() method to perform the conversion.

Signed-off-by: Andrea Bocci <andrea.bocci@cern.ch>
2020-03-03 21:44:35 +01:00
Volodymyr Sapsai cf4d496319 Update to reflect changes in Clang.
In r283766 started using unique_ptr instead of raw pointers in the
late-parsed templates map.

In r283815 changed FileEntry::Name from raw pointer to StringRef.
2016-10-10 22:52:04 -07:00
EugeneZelenko e05d81f32d Fix some Clang-tidy warnings
NULL/0 -> nullptr
C standard library include -> C++ counterparts
Occasional use of auto
Explicit strcmp return value check
Remove unused usings
Closing comments for anonymous namespaces
2016-06-07 21:49:33 +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
Kim Grasman 178b04f014 Fix #127: Improve macro location logic
- Rename GetUseLocationForMacroExpansion -> GetCanonicalUseLocation
- Let macro authors forward-declare symbols to push responsibility
  to expansion
- Symbols passed as arguments to macros are now attributed to expansion

Second commit attempt, with explicit use of spelling-location for
uses attributed to macro definition.
2016-03-15 22:21:39 +01:00
Kim Grasman 380c96abb1 Revert "Fix #127: Improve macro location logic"
This reverts commit 32d04eecd5.

Unexpectedly broke the badinc test on Ubuntu/GCC.
2016-03-11 08:06:56 +01:00
Kim Grasman 32d04eecd5 Fix #127: Improve macro location logic
- Rename GetUseLocationForMacroExpansion -> GetCanonicalUseLocation
- Let macro authors forward-declare symbols to push responsbility to expansion
- Symbols passed as arguments to macros are now attributed to expansion
2016-03-10 19:18:59 +01:00
Kim Gräsman 2bcfc440d9 Remove some more unnecessary uses of FullSourceLoc. 2015-03-02 19:54:28 +00:00
Kim Gräsman e7309bc9e6 Rename GetFileEntry(FullSourceLoc) GetLocFileEntry
The use of FullSourceLoc in IWYU was confusing and error prone.
GetFileEntry was already templated on all AST node types and overloaded on
SourceLocation, so calling GetFileEntry with a FullSourceLoc would have a
completely different meaning than calling it with a plain SourceLocation.

Add comments to make it clearer that GetLocFileEntry does not do any magic.

Also inline a few pointless utility methods.

No functional change.
2015-03-02 19:54:02 +00:00
Volodymyr Sapsai fd4f7d163f Simplify handling include filename location in macro. 2012-12-02 21:50:10 +00:00
Volodymyr Sapsai 1e43b5df1a Instead of include location use included filename location in
GetIncludeNameAsTyped. In case of macro use spelling location (issue #67).
2012-06-12 20:40:02 +00:00
csilvers+iwyu 78b3e663dd Re-do instantiation->expansion change.
Revision created by MOE tool push_codebase.
MOE_MIGRATION=2891
2011-08-09 00:25:01 +00:00
csilvers+iwyu 93d9bdde25 Add IWYU mapping for exception_defines.h.
R=csilvers,dnovillo
DELTA=4  (4 added, 0 deleted, 0 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=2868
2011-08-09 00:22:22 +00:00
csilvers 1f6396449c 'Instantiation' was renamed to 'Expansion' in clang. This does the
minimal to get things compiling (and tests passing) again.  Better
would be to go through all the comments and functions here, too, and
make the same change.
2011-08-01 21:07:03 +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 3e2910e329 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. 2011-07-19 08:21:34 +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 58eaaf7d4d It turns out that clang's isBeforeInTranslationUnitThan
doesn't distinguish between symbols in the same macro (or if
it does, then not in a way that I'm able to take advantage of,
perhaps because I'm comparing a decl to a SourceLocation
rather than two decls).  Special-case that situation to just
always say "yes, a is before b".  This fixes the tests (which
I've also augmented to capture outside badinc.h).

Submitting TBR because it's the weekend and I'd like the build
to be green again.

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


Revision created by MOE tool push_codebase.
MOE_MIGRATION=1599
2011-04-26 23:22:43 +00:00
csilvers+iwyu 8c504ac106 Rather than comparing line numbers to say that one decl comes
before another, use isBeforeInTranslationUnitThan.  It's more
accurate; in particular, it will work better with macros
(which appear to be on one line).

I don't use this everywhere I can, yet; there are still some
places in iwyu.cc that would benefit.

This turned up a bug in a case where a use was also a
declaration -- in particular, when specialization a template:
the act of specializing uses the template that's being
specialized, but is itself a decl of the specialized template
-- we were saying instead that the specialized template was
using itself.  This bug turned up because
isBeforeInTranslationUnitThan(x, x) returns false, while the
line-number comparison, which used <=, returned true.

R=wan
DELTA=63  (41 added, 20 deleted, 2 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=1598
2011-04-26 23:22:21 +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 71ee6d294e Use intends-to-provide logic to guess whether the use of a
symbol in an expanded macro should be attributed to the macro
writer or the macro caller.  This can backfire: if the author
of the macro file isn't good about its #include hygenie, then
lots of callers will be made responsible for symbols that are
actually internal parts of the macro.  But hopefully if that
happens we can easily detect it and fix the file the macro is
written in.

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


Revision created by MOE tool push_codebase.
MOE_MIGRATION=903
2011-03-18 06:58:38 +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 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