Commit Graph

5 Commits

Author SHA1 Message Date
Bolshakov f9f4fd2eef Test reporting types hidden in tpl arguments
The full type use reporting in the three covered cases is ensured
with excessive `CanIgnoreType` calls which check not only the type
to be reported but also the type before dereferencing (which occurs
to be in the resugaring map). This approach should be refactored
in subsequent commits.
2023-02-01 21:26:28 +01:00
Alexey Storozhev 810c5b2de7 Migrate test launch arguments to IWYU_ARGS 2021-01-31 11:07:48 +01:00
Kim Grasman a85cea1b30 Improve handling of placement new
Instead of 'IsDefaultNewOrDelete' which uses heuristics and string
parsing, use FunctionDecl::isReplaceableGlobalAllocationFunction from
the Clang API. It returns true for any replaceable allocation function,
which happens to coincide nicely with all allocation functions except
placement new.

Fixes #777 and improves behavior for the modern allocation functions:

- Sized deallocation in C++14
- Aligned allocation in C++17

This small improvement fixes a number of TODOs in the new placement_new
testcase, and makes it possible to add a testcase for implicit aligned
allocation in operator_new, as aligned allocation no longer requires
<new>.

Patch based on work and lots of good input from Adar Dembo.
2020-05-02 11:42:24 +02:00
Kim Grasman 03ace073e8 Add more complete testing for placement new
Placement new is special in that using it requires including <new>.

badinc.cc had some test coverage for placement new, but it was
relatively free-standing from the rest of the badinc machinery, so move
it to a dedicated test file. In the process lost one seemingly-pointless
test that 'delete (((newed_int)));' does not require <new>.

Add test cases to cover placement new:
* of builtin types in normal code
* of user-defined types in normal code
* in a macro
* in an uninstantiated function template
* of an instantiated class template

Add testcases for new(std::nothrow) and new(std::align_val_t), which
uncovered a bug: they should not require <new> for operator new, but
they _should_ do so for the placement symbols. Mark undesirable
diagnostics with TODOs for now, will be fixed in upcoming patch.
2020-05-02 11:42:24 +02:00
Kim Grasman 21168b218e Add more complete testing for operator new
This replaces builtins_new_included.cc with operator_new.cc, and covers
all variants of operator new that do _not_ require <new> to be
included:

- Raw explicit ::operator new/::operator delete calls
- New expressions, both of builtin and user-defined types
2020-05-02 11:42:24 +02:00