simplecpp
simplecpp copied to clipboard
C++ preprocessor
`realFilename()` does nothing on non-Windows platforms but that leads to inconsistent behavior with case insensitive filesystems. File on disk: `lower.cpp` Result on Windows (case insensitive filesystem) for `Lower.cpp`: `lower.cpp` Result...
The check in `simplecpp::preprocess` obviously didn't work if `gnu++` or another alias were used. Also the simplification should only be performed if supported. This does not fix the hang tracked...
The MacOS filesystem is case insensitive by default but we treat it like Linux which is case insensitive by default.
Instead of duplicating the macro references into each token we should just keep references to the tokens in the macros.
``` [build] Address 0x12b7dc2f5198 is a wild pointer inside of access range of size 0x000000000008. [build] SUMMARY: AddressSanitizer: unknown-crash C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\xstring:2294 in std::_String_val::_String_val(void) [build] Shadow bytes around the...
Use std::size_t to make build bit-width agnostic. On Windows, suppress warning about assignment in a conditional expression.
Example code: ``` #define bar(x) x % 2 #define foo(x) printf(#x "\n") foo(bar(3)); ``` gcc output: ``` printf("bar(3)" "\n"); ``` simplecpp output: ``` printf("3%2" "\n"); ```
Reported here: https://sourceforge.net/p/cppcheck/discussion/general/thread/5f665265d7/ Example code: ``` #define IS_ENABLED(config_macro) Z_IS_ENABLED1(config_macro) #define Z_IS_ENABLED1(config_macro) Z_IS_ENABLED2(_XXXX##config_macro) #define _XXXX1 _YYYY, #define Z_IS_ENABLED2(one_or_two_args) Z_IS_ENABLED3(one_or_two_args 1, 0) #define Z_IS_ENABLED3(ignore_this, val, ...) val #define FOO 1 int main()...
Currently `DUI` only contains `includePaths` which are used for any include no matter if local or system. There's also no support for `-isystem` in the `simplecpp` command-line tool.
The `new`/`delete` calls for the `Token` allocations make up more than 30% of the Ir count when profiling with `callgrind`. It might make sense to implement a custom allocator or...