Commit Graph

19 Commits

Author SHA1 Message Date
Kim Gräsman 8b3da1112e Better support CRLF line endings in custom lexer
Running the tests/cxx/comment_pragmas.cc test on Windows fails saying
that <some_system_header_file> is not diagnosed correctly.

Turns out to be because our custom lexer for GNU @headername comment
directives did not respect Windows line endings, and failed properly
identify the @headername.

Match on both CR and LF when attempting to find end of line.
2022-10-08 12:37:55 +02:00
Alexey Storozhev 56d20af4c7 Delete unused using declarations 2020-11-28 16:32:50 +01: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
Kim Grasman 7c2ec8f05b Rename port.h -> iwyu_port.h 2019-12-26 16:12:02 +01:00
Kim Grasman 2b596dae66 Simplify handling of defined() operator
Clang r350891 changed the raw lexer so it asserts for IWYU's use
case.

Instead of re-lexing to catch symbols inside defined(), use a
PPCallbacks::Defined override to capture the tokens directly
(presumably, Defined did not exist when the open-coded parser was
added).

This removes a lot of code, including the PPCallbacks for If and Elif,
which are no longer necessary.

No functional change.
2019-01-19 11:13:41 +01:00
Kristoffer Henriksson a2d8e28250 Allow IWYU pragma: keep on forward declarations as an escape hatch for cases where IWYU incorrectly concludes that a forward declaration is not necessary and recommends its removal. 2017-06-20 21:55:20 -07:00
Kim Grasman bb61a50408 Terminology: as-typed -> as-written
Clang uses mostly "as-written" in its APIs. Follow that convention
more consistently.
2016-09-04 17:06:41 +02:00
Kim Grasman 0cfdff27dc Increase log level for macro lexer
Log output from this code would dwarf everything else at level 7.
2016-08-02 22:19:00 -07:00
EugeneZelenko 137907952c Fix some Clang-tidy warnings
NULL/0 -> nullptr
C standard library include -> C++ counterparts
Use override keyword
Range for loops in selected places
Occasional use of auto
Remove unused usings
Remove unnecessary uses of c_str()
Closing comments for anonymous namespaces
2016-06-18 09:59:40 +02: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 f8fd069e44 Fixed file heading comments not matching the filename (issue #83). Patch by Ryan Pavlik.
Also made the length of the first line to be 80 characters where possible.
2012-11-25 22:09:37 +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 a126b698db Fix a renamed method.
R=chandlerc,csilvers


Revision created by MOE tool push_codebase.
MOE_MIGRATION=3290
2011-09-20 15:20:12 +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 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 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 dee92b5e0a Initial release! Grains of salt not included. 2011-02-04 22:28:15 +00:00