Commit Graph

296 Commits

Author SHA1 Message Date
rdb 61665dc8ba cppparser: Remove unused `<list>` include 2024-03-29 16:12:01 +01:00
rdb 4430f16cda cppparser: Minor performance improvements 2024-03-29 16:04:04 +01:00
rdb 12a188b116 cppparser: Allow move semantics for CPPToken
This should make it a bit more efficient to move tokens around
2024-03-29 15:00:39 +01:00
rdb e1870047c6 cppparser: In preprocess mode, add newline when switching files 2024-03-29 14:59:50 +01:00
rdb 329fa728a7 cppparser: Change `check_keyword()` to an unordered_set lookup 2024-03-29 13:04:24 +01:00
rdb 04a9264e68 cppparser: Fix slow parser performance 2024-03-29 12:22:54 +01:00
rdb acf118c96a cppparser: Update prebuilt bison files 2024-03-29 12:19:48 +01:00
rdb c1e494c083 cppparser: Fix `volatile` keyword not being parsed in all places 2024-03-29 11:39:51 +01:00
rdb 6e81fb5cdf cppparser: Support `__restrict` and `__restrict__` keywords
To compile C code, you can do `-Drestrict=__restrict`
2024-03-29 11:36:14 +01:00
rdb e16cb8af98 cppparser: Add special __builtin_va_list type 2024-03-29 11:34:56 +01:00
rdb d1c277ef6a cppparser: prevent enum values having long chain of additions
See #1638

[skip ci]
2024-03-28 22:49:15 +01:00
rdb bddb7cb262 cppparser: fix escaping of string literals in preprocessor mode
[skip ci]
2024-03-28 22:17:49 +01:00
rdb ba51b2cdca cppparser: Fix wide character literals in `#if` 2024-03-28 21:55:36 +01:00
rdb e29b326dd8 cppparser: Parse macro directly following string literal
This allows the following C code to parse:

    #define SUFFIX "bar"
    const char *str = "foo"SUFFIX;

This is technically not valid C++ since C++ uses this syntax for custom string literals, but we might as well check if there is a macro defined with this name if we can't find a matching string literal and are about to throw an error
2024-03-28 21:09:40 +01:00
rdb ae8d643907 cppparser: Prefer function over type when searching symbol
This is meant to fix the "stat problem", which means you can define a function with the same name as a struct, which is allowed, since you can still refer to the struct with an explicit `struct stat`.

It can be reproduced with the following code:

struct stat;

void stat();

void *ptr = (void *)stat;
2024-03-28 21:02:32 +01:00
rdb 50538203ce cppparser: Fix regression parsing `defined MACRO` without parens 2024-03-28 20:00:47 +01:00
rdb 87d3a1d553 cppparser: Add missing include to fix non-unity build 2024-03-28 17:19:04 +01:00
rdb fb68f82c5b cppparser: Add preprocessor option (-E) to parse_file
This makes it easier to test the behaviour of the preprocessor
2024-03-28 17:15:24 +01:00
rdb a769808af0 cppparser: Add missing keywords to CPPToken::output() 2024-03-28 17:01:47 +01:00
rdb 360216656e cppparser: assorted preprocessor improvements:
* Fix function-like macro arguments being expanded even when they were participating in token expansion or stringification
* Fix __has_include with comma or closing parenthesis in angle-quoted filename
* Don't issue warning if macro is redefined with identical definition
* Fixes for extraneous spaces being added to expansions
* Assorted refactoring

This should resolve #1638.
2024-03-28 17:01:24 +01:00
rdb 78f1a5b15a cppparser: Fix crash redefining struct as typedef
This would crash on the following code:

    struct aaa;
    typedef struct {} aaa;
2024-03-28 11:18:41 +01:00
rdb 014fd97fef cppparser: Fix string handling in expansion of macro arguments
See #1638
2024-03-28 10:07:12 +01:00
rdb e63ba11af2 cppparser: Fix expansion of function macro used without parentheses 2024-03-28 01:18:19 +01:00
rdb 38a3048479 cppparser: Fix recursion in expanding function macro arguments
See #1635
2024-03-27 10:43:58 +01:00
rdb c923cf6ee5 cppparser: Perform macro expansion on macro arguments
Fixes #1638
2024-03-27 02:26:14 +01:00
rdb 674c037c50 cppparser: Trim whitespace around macro arguments 2024-03-27 02:25:56 +01:00
rdb c5ab6573b0 cppparser: Improve error messages involving macro expansion
Now shows the expansion of the macro if a parse error occurs in one.
2024-03-27 02:23:58 +01:00
rdb 6f6cbf318e Merge branch 'release/1.10.x' 2024-03-26 17:08:52 +01:00
rdb 80147990cc cppparser: Fix problems with recursive expansion in preprocessor
Other half of #1635
2024-03-26 15:55:50 +01:00
mingodad 685b98021c cppparser: Skip comments after preprocessor directive
See #1635
2024-03-26 15:54:33 +01:00
rdb 8cbf93162a cppparser: Backport enum scope fix to 1.10
From bc039a0476
2023-08-02 12:40:37 +02:00
rdb bc039a0476 cppparser: Allow referencing enumerant within enum scope 2023-08-02 11:06:32 +02:00
rdb 5e24e7347c cppparser: Implement is_trivially_copyable type trait 2023-02-20 21:04:36 +01:00
rdb 1c37522026 Merge branch 'release/1.10.x' into master 2023-02-12 14:07:49 +01:00
rdb aaabb6a652 Fix assorted issues uncovered by clang-tidy 2023-02-12 13:55:59 +01:00
rdb 9768cbb6c2 Merge branch 'release/1.10.x' 2022-10-25 16:44:24 +02:00
rdb 9a53a3bf31 cppparser: Fix an instance of pvector being used instead of `std::vector`
Also see #539 (but doesn't fully resolve this case because DSearchPath also uses pvector)

[skip ci]
2022-10-24 13:43:29 +02:00
rdb dd262c6715 cppparser: Properly record C++11 attributes 2022-10-24 13:23:05 +02:00
rdb dd662a6eaa cppparser: Fix syntax error with C++11 attributes in declarators 2022-10-23 17:01:02 +02:00
rdb a0be50c769 general: Fix assorted compiler warnings 2022-03-01 16:09:07 +01:00
rdb 807be99f10 cppparser: Parse parenthesised noexcept() and explicit() 2021-03-02 13:31:00 +01:00
rdb 8eccc9f569 cppparser: Support __VA_OPT__ in variadic preprocessor defs 2021-03-02 13:07:27 +01:00
rdb 684992cf8f cppparser: C++20 features: spaceship operator, char8_t, constinit/eval 2021-03-01 19:33:31 +01:00
rdb d01c53c2d8 Merge branch 'release/1.10.x' 2020-06-14 13:02:25 +02:00
rdb f295b28369 cppparser: update prebuilt cppBison files 2020-06-14 12:20:40 +02:00
rdb 16f2958adb cppparser: support sizeof operator with constexpr 2020-06-14 12:12:27 +02:00
rdb 97e6a314b1 cppparser: support arbitrary constant expression in bitfields 2020-06-14 11:31:58 +02:00
rdb e4573ef0fe cleanup: Remove more unnecessary nullptr checks before delete
Follow-up to #934
2020-05-05 14:46:30 +02:00
rdb 1b863ead55 cppparser: fix finding types in explicitly specialized template class 2019-11-09 20:26:33 +01:00
Sam Edwards 12c16eb9ff Merge branch 'master' into cmake 2019-10-15 23:43:25 -06:00