Commit Graph

991 Commits

Author SHA1 Message Date
Kim Grasman 216258e16a [mappings] Add generated mappings for python3.8 2021-03-07 15:43:09 +01:00
Kim Grasman 8808107f79 [mappings] Add mapping generator for Python C API 2021-03-07 15:43:09 +01:00
Alexey Storozhev a2a92b6c6d Delete unused `using` declarations 2021-02-08 07:08:24 +01:00
Alexey Storozhev e4a715626b [travis] Workaround missing libomptarget.so.13 2021-02-04 19:41:34 +01:00
Alexey Storozhev 9eff9f3a53 Revert "[travis] Work around missing libomptarget.so.12"
This reverts commit d835c7bdb9.

LLVM bumped to `llvm-13` so `llvm-12` path is now invalid.
2021-02-04 19:41:34 +01:00
Alexey Storozhev 8343f0ce8a Replace dynamically created test cases with test functions
Currently each test source file `{dir}/{name}.{ext}` creates a test case
with `{name}` name. Files in different root `{dir}`s but with same {name}s
can end up with a name collision, so test runner just adds suffix '2'
to the name of test suite to avoid collisions. If a developer wants to
only run a specific test using `run_iwyu_tests.py {name}` it might be
difficult to figure out which exactly test failed.

This change adds extra layer of hierarchy (scoping) for tests.

Having 'C' and 'Cxx' tests this change introduces 'c' and 'cxx' TestCase
classes. As before, test runner walks down the `tests/` subtree, and
populates test case classes with `test_{filename}` methods automatically.

Test name examples before and after this change:
+---------------------+---------------+-----------------------
| File Name           | Test Before   | Test After
+---------------------+---------------+-----------------------
| c/keep_includes.c   | keep_includes | c.test_keep_includes
| cxx/using_unused.cc | using_unused  | cxx.test_using_unused

It also becomes possible to run C or Cxx tests only:
```
run_iwyu_tests.py c
run_iwyu_tests.py cxx
```
2021-02-01 20:00:44 +01:00
Kim Grasman 114248722d Remove unused local variable begin_exports_location
Found by Clang's -Wunused-variable.
2021-01-31 12:16:56 +01:00
Alexey Storozhev cb259fdd27 Delete IWYU launch arguments editing from test runner
This functionality is fully covered with IWYU_ARGS.
2021-01-31 11:07:48 +01:00
Alexey Storozhev 810c5b2de7 Migrate test launch arguments to IWYU_ARGS 2021-01-31 11:07:48 +01:00
Alexey Storozhev bc0ec65ec0 Parse IWYU arguments from test files.
Some of source files require extra Clang or IWYU arguments like
`-std=c++17` or `--mapping_file=...`.

Before this change all these args were stored in `run_iwyu_tests.py`.

This change adds the concept of "ARGS lines" so the launch arguments
could be specified directly in a source file that represents a test case.

Inspired by RUN lines of `lit` in LLVM:
https://llvm.org/docs/TestingGuide.html, "Writing new regression tests".
2021-01-31 11:07:48 +01:00
Kim Grasman d835c7bdb9 [travis] Work around missing libomptarget.so.12
We don't use this library, this is just necessary to get CMake to ignore
the missing file.
2021-01-30 11:51:49 +01:00
Kim Grasman 36d437e08e Remove references to LLVM/Clang 'trunk'
LLVM and Clang have been in Git for a while now, so avoid 'trunk' in
favor of the actual branch name 'main'.

Update cmake command example for local build tree to use something more
akin to a real directory path.
2020-12-28 12:57:17 +01:00
Kim Grasman f0240b92f3 Update references to Clang master -> main
The llvm-project repository just changed name of its mainline branch
from 'master' to 'main'.

Update our docs accordingly.
2020-12-28 12:57:17 +01:00
Omer Anson a7499e4a2b [iwyu_tool] Notify success/failure via exit code
Modify the exit code of iwyu_tool.py so that it returns 0 only
when include-what-you-use does make any recommendations.

Related: #440
2020-12-07 07:41:37 +01:00
Alexey Storozhev edd7f96fb2 Simplify _StripCommentFromLine 2020-12-06 18:15:02 +01:00
Alexey Storozhev 838f9f48a5 Handle missing enumeration values in iwyu.cc
`CK_FloatingToFixedPoint` and `CK_FixedPointToFloating` added in `9fa7f48`;
`CK_IntegralToFixedPoint` and `CK_FixedPointToIntegral` added in `8f7caae`;
`CK_LValueToRValueBitCast` added in `74ce711`.
2020-11-30 18:12:02 +01:00
Alexey Storozhev 42825de9fa Fix reference-to-temporary in header-search
The map range iterator returns a `const pair<const string, ...>&`, not the
expected `const pair<string, ...>&`, and the compiler helpfully converts
to a temporary. Make the types match.

Found by Clang's -Wrange-loop-construct
2020-11-30 18:12:02 +01:00
Alexey Storozhev 56d20af4c7 Delete unused using declarations 2020-11-28 16:32:50 +01:00
Alexey Storozhev e3eaf07cb9 Use higher-level approach to build, test and install the project on CI
`cmake --build`, `cmake --install` and `ctest` hide the implementation
details about which exactly Generator was used on configuration step.
2020-11-28 15:37:40 +01:00
Kim Grasman 71220d36ea Update README for 0.15
Also clean up the state of 'master' --

* Clang is all Git now, so refer to its master instead of 'trunk'
* IWYU master does not have a version
2020-11-21 22:29:01 +01:00
Kim Grasman 9fbae16e7e Bump version to 0.16 on master 2020-11-21 21:50:10 +01:00
Kim Grasman d2bb9462e9 [cmake] Clarify comment around dynamic linking
In 3e2ebc3729, the logic changed, but the
comment grew stale. Rephrase.

No functional change.
2020-11-21 21:26:40 +01:00
David Callu 48f9c54156 [qt] Move module header mappings to the end
QtCore header is a global header that should be included only if no
other solution is available to fix symbol definition. So move this
mapping at the end of list and use it only as a last resort
2020-11-19 18:45:35 +01:00
David Callu 495a416f30 [qt] Add manual overrides for everything in QObject 2020-11-19 18:45:35 +01:00
David Callu 4fcff6c90e [qt] Add manual override for qnamespace header
Also ignore QInternal to get rid of mapping from qnamespace.h to
QInternal in favor of this manual one.
2020-11-19 18:45:35 +01:00
David Callu fc35de176c [qt] Add manual override for qDebug symbol 2020-11-19 18:45:35 +01:00
Kim Grasman 32b941cb4b [qt] Add QtHeader class to represent Qt module/header
Move the responsibility for cracking the headername into module/class
and parsing headers looking for private includes into a helper class.

This makes the main flow much more obvious.

No functional change.
2020-11-19 18:45:35 +01:00
Kim Grasman ba96d75b7c [qt] Separate yaml/json formatting from structure building
Rather than formatting mapping strings as they are traversed, parse
directory tree and generate an in-memory structure, and then render
that to .imp format using the json module.

This cuts down on quote escaping, and makes the major flow cleaner.

No functional change, but formatting is a little more packed.
2020-11-19 18:45:35 +01:00
Kim Grasman 4d78034fb1 [qt] Add commentary for main
Add both a doc comment for the function and some guiding comments to
describe the main flow.
2020-11-19 18:45:35 +01:00
Kim Grasman e20379c0d5 [qt] Rename f to outfile
Most linters frown on one-letter names.
2020-11-19 18:45:35 +01:00
Kim Grasman 51865e65a6 [qt] Use arguments instead of global args 2020-11-19 18:45:35 +01:00
Kim Grasman 5f6783f6cc [qt] Add global constant for outfile header
No functional change.
2020-11-19 18:45:35 +01:00
Kim Grasman a0b7da3b9f [qt] Explicitly return zero exit code from main 2020-11-19 18:45:35 +01:00
Romain Geissler 3e2ebc3729 Correctly detect link with LLVM/CLANG shared libraries. 2020-11-12 21:39:08 +01:00
Kim Grasman fefce689c4 Remove portability shim for snprintf
Microsoft's _snprintf was never a drop-in replacement for snprintf (it
could leave resulting string un-terminated if it wouldn't fit).

As of Visual Studio 2015, the Microsoft C runtime ships with an actual
C99-compliant snprintf. LLVM requires VS2017, so we can just assume it
exists.
2020-11-08 20:20:07 +01:00
Kim Grasman 56f08640fc Clarify comments for edits to boost-1.64-all-private.imp
Some of these were confusing because without syntax highlighting they
looked like actual mappings.

Wording and spacing also needed some improvements.
2020-11-08 20:06:44 +01:00
pppyx dc26ddaab8 Remove circular boost/numeric mappings 2020-11-08 20:02:16 +01:00
Florian Schmaus 60b2ea7050 Do not provide arguments when calling Decl.isReplaceableGlobalAllocationFunction()
LLVM added a second boolean argument to
isReplaceableGlobalAllocationFunction() with 3dd5a298bfff ("[clang]
Annotating C++'s `operator new` with more attributes"). However both
parameters define a default argument. Hence there is no need to
explicitly state the argument, if it is already the default argument,
which is nullptr is isReplaceableGlobalAllocationFunction() case. This
also increases readability.
2020-11-08 19:41:04 +01:00
pppyx 4bb651bf46 Removing boost/python mappings
Removing boost/python mappings in boost-1.64-all-private.imp to avoid circular dependencies.
2020-11-01 19:03:36 +01:00
Kim Grasman f050226101 Add mapping from <bits/time.h> to <time.h>
This makes <time.h> a valid provider of CLOCKS_PER_SEC and other symbols
declared in <bits/time.h>.

Not entirely sure how this fares with older glibc versions, but my
suspicion is <time.h> is a better candidate than <sys/time.h> in the
general case.
2020-11-01 18:59:43 +01:00
Kim Grasman a78944dabc Fix clang-headers copy for locally built LLVM/Clang
LLVM_INSTALL_PREFIX is only set for the packaged LLVM.

When there's a local build dir, LLVM_LIBRARY_DIR points to the same
place (give or take some library suffix stuff that I will ignore for
now).

Using the latter makes the synthetic 'clang-headers' cmake target work
when the prefix path points to a local LLVM build tree.
2020-10-27 18:55:51 +01:00
pppyx 4fc988650d Removing self-mapping in boost/variant
Removing self-mapping in boost/variant (and adding a comment)
2020-10-27 18:50:26 +01:00
Tim Gates a95999b244 docs: fix simple typo, proceded -> preceded
There is a small typo in fix_includes.py.

Should read `preceded` rather than `proceded`.
2020-10-10 10:38:32 +02:00
Omar Sandoval 595bd95699 Add mappings for max_align_t, ptrdiff_t, and wchar_t
According to C11, these are all provided by stddef.h, and wchar_t is
also provided by stdlib.h.
2020-09-26 16:45:11 +02:00
Liam Keegan 600732203a Update table of clang versions in README.md 2020-09-26 16:38:55 +02:00
Kim Grasman fbffd6e3be Remove source manager from ASTNode constructor
ASTNode was consistently instantiated using GlobalSourceManager(). The
passed-in source manager was only used in ASTNode::GetLocation().

Use GlobalSourceManager() there directly instead to keep the constructor
interface simpler.

No functional change.
2020-09-22 20:18:35 +02:00
Kim Grasman bff9327eb2 Use std::to_string instead of snprintf 2020-08-01 14:13:40 +02:00
Kim Grasman 2d9bd45816 Remove now-redundant InstantiateImplicitMethods calls
Now that shouldVisitImplicitCode is on, implicit constructors are properly
visited and we don't need to instantiate them explicitly.

No functional change.
2020-08-01 13:59:30 +02:00
Kim Grasman 8774126c67 Use shouldVisitImplicitCode instead of reinventing it
RecursiveASTVisitor::shouldVisitImplicitCode was added to Clang after
IWYU introduced workarounds for implicit code. Using it makes it possible
to remove some boilerplate code.

There are still a few places where special handling is necessary:

* VisitTagDecl needs to explicitly ignore the injected class name
* TraverseCXXDestructorDecl still needs to invoke
  TraverseImplicitDestructorCall, which reports usage of fields and bases
  for classes with destructors.
* TraverseCXXRecordDecl still needs to call InstantiateImplicitMethods
  because Clang does not instantiate _unused_ methods, and so otherwise there
  will be nothing to visit.

No high-level functional change.
2020-08-01 13:59:30 +02:00
Kim Grasman 30549c6931 Implement Stmt printing with ASTDumper
The Clang API changed in commit 473fbc90d1fbf17e so that Stmt::dump
takes an ASTContext instead of a SourceManager.

Rather than wire a global ASTContext, reimplement PrintableStmt and
PrintStmt to duplicate the most trivial implementations not requiring
ASTContext.

No functional change.
2020-07-12 16:46:30 +02:00