Commit Graph

1277 Commits

Author SHA1 Message Date
Kim Gräsman 9926eb2192 Use [[noreturn]] instead of LLVM_ATTRIBUTE_NORETURN
A recent change to LLVM removed LLVM_ATTRIBUTE_NORETURN in favor of plain C++11
[[noreturn]]. Since we require C++14 to build these days, just assume that
the [[noreturn]] attribute is available.
2021-08-06 13:52:19 +02:00
Kim Gräsman a5d8408c5f Use std::regex instead of llvm::Regex
llvm::Regex does not support negative lookaround, so there was no way to do
negative assertions such as:

    "@\"((?!.*/internal/).*)-inl.h\""

as part of mapping rules.

Switch to std::regex (which defaults to ECMAScript regex dialect) to allow these
constructs.
2021-08-04 09:53:25 +02:00
Kim Gräsman 718e698755 Link with all target libraries
In the parent commit, I forgot to update the build so that include-what-you-use
links with all targets, which led to link failures for builds against LLVM build
trees (as opposed to the Debian packages).

While troubleshooting this, I found a patch by @Romain-Geissler-1A that I had
previously misunderstood/overlooked:
https://github.com/include-what-you-use/include-what-you-use/pull/854#issuecomment-732487734

Borrowing the link dependencies from that patch to complete my accidental
plagiarism fixes the build again.
2021-07-25 11:04:54 +02:00
Kim Gräsman 0de60d8a27 Initialize all LLVM targets on startup
It used to be the case that the MS inline assembly parser in Clang crashed if an
X86 target was not registered and initialized.

The error handling there has been improved, so now Clang complains and says it
needs X86 target support to continue, and raises an error.

That's good news for IWYU, as the majority of code we analyze has no MS inline
assembly (fingers crossed!). So instead of requiring an X86 target to be
included, initialize _all_ registered LLVM targets and assume that X86 is
available in any configuration intended for use with MS inline assembly.

This makes it possible to build a fully non-X86 toolchain including IWYU.
2021-07-21 09:46:21 +02:00
Kim Gräsman 2fd98b13f6 Use primary function template declaration for macro author intent
We already have a rule that if a decl is used entirely inside a macro, and it's
forward-declared in the macro file, the use is attributed to the expansion
location. This, however, did not cover template specializations, as described in
issue 847.

So now we treat a primary function template declaration in the macro file as a
regular forward-declaration, which means that function template specializations
used in macros will be attributed to the expansion location iff the primary
template has a declaration in the macro file.
2021-07-21 09:44:55 +02:00
Kim Gräsman b1c44fe97b Support class template argument deduction
CTAD is a C++17 feature that allows template arguments to be deduced from
constructor expressions. For example:

    A a(10, 20);

is shorthand for:

    A<int, int> a(10, 20);

This should fix issue #826.
2021-07-21 09:44:30 +02:00
Alejandro Colomar 9e0d33d828 Add more mappings for 'va_list'
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
2021-07-11 09:03:34 +02:00
Alejandro Colomar b6eb039187 Add mappings for 'uintmax_t'
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
2021-07-11 09:03:34 +02:00
Alejandro Colomar 4c187d46aa Reorder (alphabetically) mappings for 'uid_t'
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
2021-07-11 09:03:34 +02:00
Alejandro Colomar de49a862c8 Add more mappings for (struct) 'timeval'
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
2021-07-11 09:03:34 +02:00
Alejandro Colomar dc2acabc58 Add more mappings for (struct) 'timespec'
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
2021-07-11 09:03:34 +02:00
Alejandro Colomar 029d045f1a Add mappings for 'timer_t'
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
2021-07-11 09:03:34 +02:00
Alejandro Colomar 2499d91c45 Add more mappings for 'time_t'
Use <time.h> as the primary header for portability to non-POSIX systems.

Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
2021-07-11 09:03:34 +02:00
Alejandro Colomar 96b7299340 Reorder (alphabetically) mappings for 'suseconds_t'
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
2021-07-11 09:03:34 +02:00
Alejandro Colomar e89c3c1638 Add more mappings for 'ssize_t'
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
2021-07-11 09:03:34 +02:00
Alejandro Colomar 289e0d3856 Fix mappings for 'socklen_t'
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
2021-07-11 09:03:34 +02:00
Alejandro Colomar bcdd338d4d Add mappings for 'struct sockaddr'
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
2021-07-11 09:03:34 +02:00
Alejandro Colomar d50530f319 Add more mappings for 'size_t'
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
2021-07-11 09:03:34 +02:00
Alejandro Colomar c19ae5ef07 Add mappings for 'union sigval'
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
2021-07-11 09:03:34 +02:00
Alejandro Colomar e109386c09 Fix mappings for 'sigset_t'
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
2021-07-11 09:03:34 +02:00
Alejandro Colomar d83f42cd46 Add mappings for 'siginfo_t'
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
2021-07-11 09:03:34 +02:00
Alejandro Colomar 291e1c7ae3 Add mappings for 'struct sigevent'
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
2021-07-11 09:03:34 +02:00
Alejandro Colomar 3a2b81eb94 Add mappings for 'regoff_t'
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
2021-07-11 09:03:34 +02:00
Alejandro Colomar 12e6971de4 Add mappings for 'regmatch_t'
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
2021-07-11 09:03:34 +02:00
Alejandro Colomar 17ee1d337d Add mappings for 'regex_t'
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
2021-07-11 09:03:34 +02:00
Alejandro Colomar 9bdc2bb869 Add more mappings for 'pid_t'
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
2021-07-11 09:03:34 +02:00
Alejandro Colomar 2c4a2ac7b1 Add more mappings for 'off_t'
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
2021-07-11 09:03:34 +02:00
Alejandro Colomar 5a683775e9 Add more mappings for 'mode_t'
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
2021-07-11 09:03:34 +02:00
Alejandro Colomar d860e3cd5c Add mappings for [l]ldiv_t
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
2021-07-11 09:03:34 +02:00
Alejandro Colomar c934d8d290 Add mappings for 'struct lconv'
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
2021-07-11 09:03:34 +02:00
Alejandro Colomar ba0b231cfe Remove incorrect mapping for 'intptr_t'
If a library defines intptr_t in <unistd.h> that's a bug.
It shall only be defined in <stdint.h> and <inttypes.h>.

Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
2021-07-11 09:03:34 +02:00
Alejandro Colomar 24f9fdf0af Add more mappings for [u]intptr_t
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
2021-07-11 09:03:34 +02:00
Alejandro Colomar 58bd50401c Add more mappings for [u]intN_t types
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
2021-07-11 09:03:34 +02:00
Alejandro Colomar f0b94379b3 Remove incorrect mapping for 'int8_t'
If some library defines int8_t in <sys/types.h>, that's a bug.
The standard only defines it in <stdint.h> and <inttypes.h>.

Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
2021-07-11 09:03:34 +02:00
Alejandro Colomar dcd77be4ea Add mappings for 'intmax_t'
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
2021-07-11 09:03:34 +02:00
Alejandro Colomar 4edca3eedf Add mappings for 'imaxdiv_t'
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
2021-07-11 09:03:34 +02:00
Alejandro Colomar c139dd8991 Add more mappings for 'gid_t'
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
2021-07-11 09:03:34 +02:00
Alejandro Colomar f7efbd721e Add mappings for 'float_t'
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
2021-07-11 09:03:34 +02:00
Alejandro Colomar 748bdded08 Add mappings for 'FILE'
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
2021-07-11 09:03:34 +02:00
Alejandro Colomar aba2bf38a6 Add mappings for 'fexcept_t'
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
2021-07-11 09:03:34 +02:00
Alejandro Colomar cbedecd8bd Add mappings for 'fenv_t'
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
2021-07-11 09:03:34 +02:00
Alejandro Colomar 522c74e5ee Add mappings for 'fd_set'
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
2021-07-11 09:03:34 +02:00
Alejandro Colomar abf40ce89c Add mappings for 'double_t'
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
2021-07-11 09:03:34 +02:00
Alejandro Colomar 7fe55162dd Add mappings for 'div_t'
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
2021-07-11 09:03:34 +02:00
Alejandro Colomar ca8da19e35 Add more mappings for 'clock_t'
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
2021-07-11 09:03:34 +02:00
Alejandro Colomar 314ec724f0 Add mappings for 'cc_t'
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
2021-07-11 09:03:34 +02:00
Alejandro Colomar 09eebcfd0f Add mappings for 'struct aiocb'
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
2021-07-11 09:03:34 +02:00
Alejandro Colomar cafeef5efd Reorder mappings for 'blkcnt_t' and 'blksize_t'
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
2021-07-11 09:03:34 +02:00
Alejandro Colomar 19c224e5a8 Add mappings for 'clockid_t'
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
2021-07-11 09:03:34 +02:00
Kim Grasman a295184e3e Remove /EHsc from MSVC build args
Slightly different /EH flags are now provided by LLVM's CMake system,
and MSVC warns that they're inconsistent.

They're the same in spirit, so let LLVM decide.
2021-07-06 19:28:26 +02:00