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.
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>
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.
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
- 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
- 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.
- 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
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.
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.
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
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
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
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
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
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