Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
203 commits
Select commit Hold shift + click to select a range
41825a1
GPL Code Rewrite
brightprogrammer Jun 18, 2025
b7aa210
Substitutable Types With Metadata About Number Of Parts
brightprogrammer Jun 27, 2025
87dc7f4
Return Types
brightprogrammer Jul 10, 2025
024d42e
Refactor trace graph result handling and input snippet creation
b1llow Nov 12, 2025
e311211
Add demangling type kind enumeration and extend vector functionality
b1llow Nov 13, 2025
8c4d6a5
Enhance vector functionality by adding parent type kinds handling
b1llow Nov 13, 2025
1fc3f3b
Refactor vector macros for improved readability and consistency
b1llow Nov 17, 2025
6006545
Fix typeinfo structure description for improved clarity
b1llow Nov 19, 2025
b495703
Split test cases with class (template, llvm)
b1llow Nov 19, 2025
8626380
Merge all v3_impl to v3.c
b1llow Nov 19, 2025
6497e50
Add support for extended qualifiers in C++ demangling and improve mem…
b1llow Nov 20, 2025
cfccd80
Rename substitution functions for consistency and improve qualifier h…
b1llow Nov 23, 2025
7025262
Add built-in type detection for improved type handling in demangling
b1llow Nov 23, 2025
509dc3a
Refactor dem_string functions for improved readability and safety
b1llow Nov 23, 2025
457f68a
Refactor nested_name rule to improve memory management and enhance CV…
b1llow Nov 23, 2025
4973070
Enhance handling of extended qualifiers in C++ demangling by appendin…
b1llow Nov 24, 2025
c0423ea
Fix type prefix comparison in C++ demangling and refactor base36 conv…
b1llow Nov 24, 2025
7f7f5b7
Add SPDX license headers to multiple source files
b1llow Nov 24, 2025
34925e1
Fix <substitution>
b1llow Nov 24, 2025
6f37651
Update file pattern for .clang-format in dep5
b1llow Nov 24, 2025
c368944
Add copyright information for .clang-format files in dep5
b1llow Nov 24, 2025
e9874ee
licenses: remove UNUSED LICENSES
b1llow Nov 24, 2025
34c80d6
refactor: update demangle functions to return char* and improve struc…
b1llow Nov 26, 2025
5a1b87f
refactor: update rule declarations to use static inline and adjust in…
b1llow Nov 26, 2025
e285257
test: add unit tests for demangle rule prefix functionality
b1llow Nov 26, 2025
723ceb6
feat: add AST node structure and associated functions for demangling
b1llow Nov 26, 2025
654d844
refactor: update match rules to use DemAstNode and return boolean values
b1llow Nov 26, 2025
a8fa2af
feat: enhance demangling rules with new AST node handling and improve…
b1llow Nov 26, 2025
d3dfd18
fix: ensure proper deinitialization of DemAstNode children in destructor
b1llow Nov 26, 2025
decfef0
fix: correct deinitialization calls and enhance rule definitions in d…
b1llow Nov 26, 2025
38fd3dd
feat: improve nested name handling and streamline rule matching in de…
b1llow Nov 26, 2025
fe85a74
fix: improve DemAstNode handling and ensure proper deinitialization i…
b1llow Nov 27, 2025
215bc1f
fix: enhance memory management and deinitialization in meta handling
b1llow Nov 27, 2025
5078ea2
fix: streamline meta handling and improve memory management in tempor…
b1llow Nov 27, 2025
555c466
stage
b1llow Nov 27, 2025
0215bb7
feat: add unit tests for vector implementation and memory management
b1llow Nov 27, 2025
bf67f94
fix: enhance memory management and ownership transfer in DemAstNode o…
b1llow Nov 27, 2025
5d28d0f
fix: improve memory management and deinitialization in meta handling
b1llow Nov 27, 2025
8d08259
fix: ensure proper deinitialization of class names and custom name st…
b1llow Nov 27, 2025
d3b8311
fix: refactor meta handling functions for improved memory management …
b1llow Nov 28, 2025
e07c355
refactor: remove unused function extract_last_unqualified_name for cl…
b1llow Nov 30, 2025
25db9d8
fix: correct formatting of cv qualifiers and improve output order in …
b1llow Nov 30, 2025
785c9eb
fix: update expected output for demangle_rule tests to reflect correc…
b1llow Nov 30, 2025
bf3dd2c
fix: enhance type handling in rule_type and rule_prefix_start for imp…
b1llow Nov 30, 2025
8f6a5e8
fix: enhance constructor and destructor name handling by appending la…
b1llow Nov 30, 2025
973826c
fix: improve formatting and readability of macros and rules in demang…
b1llow Nov 30, 2025
aa3a5a6
fix: add comments to clarify handling of AST nodes in name and prefix…
b1llow Nov 30, 2025
24e5e31
fix: add handling for substitutable function types in rule_function_type
b1llow Nov 30, 2025
8033ba3
fix: enhance rule_type to include AST_APPEND_TYPE for improved type h…
b1llow Nov 30, 2025
ab363f7
fix: enhance rule_nested_name to improve handling of template types a…
b1llow Nov 30, 2025
71b1b06
fix: add helper function to manage spacing for nested template closures
b1llow Dec 2, 2025
c37a4a9
fix: enhance template parameter handling and improve substitution logic
b1llow Dec 2, 2025
b370cfe
fix: update type appending logic to support multiple occurrences in s…
b1llow Dec 2, 2025
1e65518
fix: enhance meta handling by adding prefix_base_idx and current_pref…
b1llow Dec 5, 2025
7cdb63b
Align test data to llvm-cxxfilt
b1llow Dec 7, 2025
1a89035
fix: enhance function type handling to support void parameters and im…
b1llow Dec 7, 2025
b3496b4
apply `DEFN_RULE` macro for debug
b1llow Dec 22, 2025
83ae902
fix: improve function type handling by merging AST nodes and preservi…
b1llow Dec 22, 2025
c80cc3a
fix: enhance debug logging in append_type and refactor local name rul…
b1llow Dec 24, 2025
9fb946b
remove src/cplusplus/.clang-format and reformat
b1llow Dec 24, 2025
81b21d4
(void) -> ()
b1llow Dec 24, 2025
65b5271
Refactor code structure for improved readability and maintainability
b1llow Dec 24, 2025
d8976e3
fix: add AST_ macro for improved node access and refactor MATCH state…
b1llow Dec 27, 2025
697829c
feat: add DemAstNode_is_empty function and related macros for improve…
b1llow Dec 27, 2025
3bb987a
refactor: enhance function type handling and improve debug logging in…
b1llow Dec 27, 2025
b853a01
style: add clang-format rules for braces and function separation
b1llow Dec 29, 2025
ed90f6e
"> >" -> ">>"
b1llow Dec 29, 2025
4e863b9
fix: correct formatting of std::basic_string and improve lambda rule …
b1llow Dec 29, 2025
3d0880f
feat: add string comparison functions for improved string handling
b1llow Dec 29, 2025
77d2d88
fix: update function pointer handling to avoid pointer invalidation a…
b1llow Dec 29, 2025
8a5c5fc
fix: improve function pointer handling to prevent pointer invalidatio…
b1llow Dec 29, 2025
b4d2b9d
Refactor C++ demangling implementation in v2.c, v3.c, ast.c, meta.c, …
b1llow Dec 29, 2025
dd1a5dd
Fix C++ demangler type substitution and prefix handling
b1llow Dec 29, 2025
ab7d48d
fix: update type handling in rule_type and related functions for impr…
b1llow Dec 29, 2025
a45ead2
fix: enhance function pointer handling to support qualified types and…
b1llow Dec 31, 2025
679337c
fix: reorder template substitution logic for improved clarity and cor…
b1llow Jan 1, 2026
122382c
fix: improve template name substitution and meta state handling in ru…
b1llow Jan 1, 2026
0e99386
fix: streamline function pointer handling and improve qualified prefi…
b1llow Jan 1, 2026
3d8619b
fix: add AST_MATCH2 macro for improved function pointer handling and …
b1llow Jan 1, 2026
fa32172
fix: enhance mangled name matching and improve template detection logic
b1llow Jan 1, 2026
3188339
fix: enhance DemAstNode handling and improve function pointer extract…
b1llow Jan 2, 2026
a953a88
fix: simplify function pointer handling by consolidating type checks …
b1llow Jan 4, 2026
992f6d3
fix: improve formatting and streamline AST handling in demangling rules
b1llow Jan 4, 2026
ef0bbf1
fix: enhance function pointer handling by adding validation checks an…
b1llow Jan 4, 2026
b5c8122
fix: add subtag handling in DemAstNode and introduce QUALIFIED_TYPE enum
b1llow Jan 5, 2026
b1491e3
fix: refactor function pointer handling and improve type extraction l…
b1llow Jan 5, 2026
c99fd2c
fix: streamline type appending by removing redundant force append logic
b1llow Jan 5, 2026
bd349b0
fix: refactor DemAstNode constructor for improved initialization and …
b1llow Jan 6, 2026
dd25406
fix: improve nested name parsing and enhance template argument handling
b1llow Jan 6, 2026
0ead19e
refactor: simplifying the C++ name demangling parser by:
b1llow Jan 6, 2026
7dbd023
fix: enhance DemAstNode structure by adding parent linkage and improv…
b1llow Jan 7, 2026
082c44b
fix: add outer_template_params to Meta structure and update related f…
b1llow Jan 7, 2026
0389f0d
fix: enhance template argument handling by adding tag template detect…
b1llow Jan 7, 2026
17284aa
fix: simplify expression matching by introducing RULE_X macro for imp…
b1llow Jan 7, 2026
1d33084
fix: streamline C++ name demangling by replacing MATCH_AND_DO with MA…
b1llow Jan 7, 2026
5551cfd
fix: refactor Meta structure by replacing outer_template_params with …
b1llow Jan 7, 2026
81e5fa9
fix: refactor Meta structure by replacing outer_template_params with …
b1llow Jan 7, 2026
00ea023
fix: improve C++ name demangling by conditionally appending "::" for …
b1llow Jan 8, 2026
b77a653
fix: enhance error handling in rule_source_name and rule_nested_name …
b1llow Jan 8, 2026
b172a4e
fix: add detailed tracing for memory management and node deinitializa…
b1llow Jan 8, 2026
ceaa0d7
Fix std::function and std::char_traits template parsing
b1llow Jan 8, 2026
ea4b1d1
fix: enhance C++ demangling with substitution table support and add c…
b1llow Jan 9, 2026
129af22
fix: remove unnecessary tracing logs from DemAstNode and Meta structures
b1llow Jan 9, 2026
11de7c3
fix: set parent for node_template_args in rule_template_args function
b1llow Jan 9, 2026
95c357d
fix: streamline rule handling and enhance tracing for detected substi…
b1llow Jan 9, 2026
953a997
fix: correct dem_string_non_empty argument in function name check
b1llow Jan 9, 2026
c7c2c71
fix: simplify nv_offset rule by replacing manual digit parsing with d…
b1llow Jan 9, 2026
5b4d7b4
test: 'uint64_t' -> 'unsigned long long'
b1llow Jan 9, 2026
112295a
test: 'int64_t' -> 'long long'
b1llow Jan 9, 2026
35e5727
fix: add :: separators in srN scope resolution expressions
b1llow Jan 10, 2026
c31cd6c
fix: refactor context save and restore macros for improved clarity an…
b1llow Jan 13, 2026
15f5365
fix: remove unused macros and introduce MUST_MATCH for better error h…
b1llow Jan 13, 2026
62d98f6
fix: streamline demangling rules by removing commented code and enfor…
b1llow Jan 13, 2026
9d32a75
fix: enhance demangling rules by introducing CTX_MUST_MATCH for impro…
b1llow Jan 13, 2026
85546ce
fix: enhance function pointer handling and append qualifiers in encod…
b1llow Jan 13, 2026
05337d4
refactor: macros.h
b1llow Jan 13, 2026
d6ce800
fix: refactor rule_extended_qualifier and handle qualified type for i…
b1llow Jan 13, 2026
c75c387
fix: update RULE_X macro to use RULE_CALL_DEFER for improved function…
b1llow Jan 13, 2026
6615c64
fix: enhance demangling rules for unresolved names and operator handling
b1llow Jan 13, 2026
711c6be
fix: enhance handling of function pointer modifiers and qualified types
b1llow Jan 13, 2026
918e4bb
fix: improve array type handling and expression parsing in demangling
b1llow Jan 13, 2026
e59f28b
fix: implement array type formatting in demangling
b1llow Jan 14, 2026
2126e6c
fix: add handling for 'LZ' encoding in demangling process
b1llow Jan 14, 2026
6ca78f7
fix: improve handling of 'L' encoding and value number processing in …
b1llow Jan 14, 2026
804dab7
fix: enhance context handling and improve rule matching in demangling
b1llow Jan 14, 2026
623cd26
fix: improve handling of qualifiers and context management in demangling
b1llow Jan 14, 2026
9ba3754
fix: update context restoration logic in demangling process
b1llow Jan 14, 2026
cb460b5
fix: update matching macros to use RULE_CALL_DEFER for improved conte…
b1llow Jan 14, 2026
924ab52
fix: refactor base36 parsing and improve substitution rule matching
b1llow Jan 14, 2026
3814920
fix: optimize std identifier detection in substitution parsing
b1llow Jan 14, 2026
4254e25
fix: correct boundary checks in NodeList_make and enhance error handl…
b1llow Jan 14, 2026
c90530b
fix: enhance demangling output by adding space before cv-qualifiers a…
b1llow Jan 14, 2026
0dea830
fix: remove unused first rule parameter from rule macros for improved…
b1llow Jan 14, 2026
e87ab59
fix: refactor rule_name function to improve template argument handlin…
b1llow Jan 14, 2026
013bb98
fix: improve error handling in function pointer and qualified type pr…
b1llow Jan 14, 2026
278e175
Fix C++ demangler: array pointers, void return type placement
b1llow Jan 14, 2026
4a25a76
fix: implement unary NOT operator (nt) in C++ expression parser
b1llow Jan 14, 2026
6786ace
fix: add support for user-defined literals, ABI tags, and pack expansion
b1llow Jan 14, 2026
ef3602a
fix: add support for construction vtable (TC) special name
b1llow Jan 14, 2026
0ea4dc9
fix: enhance C++ demangler for pointer-to-member types
b1llow Jan 14, 2026
aeeeca8
fix: refactor type handling in C++ demangler for improved clarity and…
b1llow Jan 14, 2026
56c6d4f
fix: improve readability and logic in macros for rule matching
b1llow Jan 14, 2026
fe4f302
fix: add support for forward template references in C++ demangler
b1llow Jan 14, 2026
ca8f10c
fix: update context macros to handle multiple instances in C++ demangler
b1llow Jan 15, 2026
27243e4
fix: enhance C++ demangler to support conversion operators and improv…
b1llow Jan 15, 2026
5f6119a
fix: simplify context handling in C++ demangler for improved clarity
b1llow Jan 15, 2026
9fd6f76
fix: update forward template reference resolution in C++ demangler
b1llow Jan 15, 2026
be6c988
fix: remove unused macro and enhance vector iteration macro in C++ de…
b1llow Jan 16, 2026
9239b5d
fix: enhance qualified type handling and add pack expansion support i…
b1llow Jan 16, 2026
cf78cf1
fix: remove incorrect TRACE_RETURN_SUCCESS in qualified type handling
b1llow Jan 16, 2026
7cb701e
[skip ci] refactor: huge refactor
b1llow Jan 16, 2026
bc71d67
fix: refactor DemNode handling and improve primitive type creation
b1llow Jan 21, 2026
be825f5
fix: improve child node handling and remove unnecessary checks in Dem…
b1llow Jan 21, 2026
6e28b0e
fix: enhance primitive type handling and add utility function for tem…
b1llow Jan 21, 2026
e95056c
fix: mark unused variables and functions to avoid compiler warnings
b1llow Jan 21, 2026
52e5643
fix: update DemNode handling to improve error tracing and memory mana…
b1llow Jan 21, 2026
3cd2a79
fix: rename macro functions for clarity and enhance template paramete…
b1llow Jan 22, 2026
f9224cb
fix: refactor nested name handling and introduce NestedName struct fo…
b1llow Jan 22, 2026
578b4a6
fix: improve string comparison for global namespace detection
b1llow Jan 22, 2026
a3dcab0
fix: replace PASSTHRU_RULE with CALL_RULE for improved rule handling
b1llow Jan 22, 2026
286959a
fix: introduce parse_discriminator function and replace rule_discrimi…
b1llow Jan 22, 2026
23ca401
fix: enhance node type handling with additional types and improved la…
b1llow Jan 22, 2026
004d66e
fix: update AST_APPEND_TYPE1 to use result for improved type handling
b1llow Jan 22, 2026
f0d387c
fix: rename is_conversion_operator to is_conversion_ctor_dtor for cla…
b1llow Jan 22, 2026
74a4c98
fix: refactor constructor/destructor handling and introduce qualifier…
b1llow Jan 22, 2026
d0fecfd
fix: enhance handling of constructor/destructor names with new struct…
b1llow Jan 22, 2026
f0f5d41
fix: add break statement to improve control flow in node handling
b1llow Jan 22, 2026
f485cc9
fix: introduce OK_OR_FAIL macro for improved error handling and refac…
b1llow Jan 22, 2026
96c7571
fix: add is_end_of_encoding function to optimize parsing logic in rul…
b1llow Jan 22, 2026
b4eb32e
fix: refactor error handling macros and improve parsing logic in rule…
b1llow Jan 24, 2026
18c999e
fix: update string comparison to use correct size for global namespac…
b1llow Jan 24, 2026
7b1ce74
fix: refactor rule_special_name for improved parsing and control flow
b1llow Jan 24, 2026
e56fb07
fix: refactor READ_STR macro for improved readability and error handling
b1llow Jan 24, 2026
7cdd37a
fix: add extract_base_class_name function to simplify base class extr…
b1llow Jan 24, 2026
05b5734
fix: enhance forward template reference handling and improve function…
b1llow Jan 24, 2026
1caf5fd
fix: refactor base class name extraction and function pointer handlin…
b1llow Jan 24, 2026
36dfd17
fix: refactor context save/restore macros and improve function type h…
b1llow Jan 24, 2026
7d19542
fix: refactor context save/restore macros for improved clarity and fu…
b1llow Jan 24, 2026
f401c9d
fix: enhance array type handling and improve integer literal formatti…
b1llow Jan 24, 2026
9a8cce2
fix: refine pointer/reference to array handling and enhance non-virtu…
b1llow Jan 24, 2026
9d2d2a4
fix: enhance type and number formatting in demangler for improved cla…
b1llow Jan 24, 2026
3b6b7a5
fix: improve number formatting and enhance unresolved type handling i…
b1llow Jan 25, 2026
4b74028
fix: add conversion operator type handling and improve forward refere…
b1llow Jan 25, 2026
f2181f8
fix: simplify CV qualifier parsing and improve function parameter han…
b1llow Jan 25, 2026
0714112
fix: add operator symbol retrieval and improve prefix expression hand…
b1llow Jan 25, 2026
5fbb159
fix: streamline number parsing in demangler for improved readability
b1llow Jan 25, 2026
03a7800
fix: enhance unresolved name parsing and streamline rule handling in …
b1llow Jan 25, 2026
4cb7e23
fix: enhance demangler by introducing NameState for improved state ma…
b1llow Jan 25, 2026
3d206e1
fix: add support for template parameter packs and parameter pack expa…
b1llow Jan 26, 2026
44b2b04
fix: add handling for conversion operator types and parameter pack ex…
b1llow Jan 26, 2026
22d2f12
fix: implement pack expansion extraction and enhance type qualifier h…
b1llow Jan 26, 2026
3bcf704
Fix forward template reference resolution in C++ demangler
b1llow Jan 26, 2026
e6aa6c4
Fix binary operator rendering in expressions
b1llow Jan 26, 2026
8508e5e
fix: simplify argument handling in expression rules
b1llow Jan 26, 2026
b9a555f
fix: enhance pack expansion handling and improve operator symbol retr…
b1llow Jan 26, 2026
b064bf7
fix: improve operator handling by appending source name in expression…
b1llow Jan 26, 2026
35bde70
fix: refactor ABI tag handling and improve type node processing
b1llow Jan 26, 2026
0ac5990
fix: add handling for ABI tag type in demangling process
b1llow Jan 26, 2026
07beb43
fix: improve handling of forward template references in resolution pr…
b1llow Jan 26, 2026
6878ada
fix: update wrapper pointer for forward template references in demang…
b1llow Jan 26, 2026
6af3ef3
fix: enhance decltype handling and update nullptr representation in d…
b1llow Jan 26, 2026
08aa543
fix: add special substitution handling for demangling process
b1llow Jan 26, 2026
505501a
fix: '> >' -> '>>'
b1llow Jan 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ AllowShortIfStatementsOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Inline
AllowShortLoopsOnASingleLine: false
InsertBraces: true
SeparateDefinitionBlocks: Always
AlignAfterOpenBracket: DontAlign
AlignEscapedNewlines: DontAlign
AlignConsecutiveMacros: true
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
build*/
.cache/
debug_demangler
debug_demangler.c
debug_demangler.dSYM/
compile_commands.json
steps-grammars
**/*.dot
4 changes: 4 additions & 0 deletions .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ Files: .github/**
Copyright: 2021 RizinOrg <info@rizin.re>
License: LGPL-3.0-only

Files: **/.clang-format
Copyright: 2025 RizinOrg <info@rizin.re>
License: LGPL-3.0-only

Files: .clang-format
Copyright: 2020 RizinOrg <info@rizin.re>
License: LGPL-3.0-only
Expand Down
117 changes: 0 additions & 117 deletions LICENSES/GPL-2.0-or-later.txt

This file was deleted.

174 changes: 0 additions & 174 deletions LICENSES/LGPL-2.0-or-later.txt

This file was deleted.

65 changes: 65 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,68 @@ demangle -s pascal 'OUTPUT_$$_init'
meson --prefix=/usr -Dinstall_lib=true build
ninja -C build install
```

## Demangler

## Graphviz Tracing

The C++ demangler now supports visual tracing via Graphviz for debugging complex parsing scenarios. Instead of text-based trace logs, the system generates `.dot` files that can be rendered as visual graphs showing the parsing tree.

### Features

- **Visual parsing tree**: Each rule invocation becomes a node in the graph
- **Success/failure tracking**: Nodes are color-coded:
- 🟢 **Green**: Successful rule matches
- 🔴 **Red**: Failed rule matches
- 🟠 **Orange**: Backtracked attempts (dashed border)
- 🔵 **Blue**: Currently running rules
- **Position tracking**: Shows parsing position and input snippets
- **Result display**: Successful nodes show their output
- **Parent-child relationships**: Edges show rule call hierarchy
- **Backtracking visualization**: Clearly shows which paths were abandoned

### Usage

Enable tracing by setting the `DEMANGLE_TRACE` environment variable:

```bash
export DEMANGLE_TRACE=1
./your_demangler _ZN4llvm8DenseMapIPKN5clang4DeclEPNS_6WeakVHEE
```

Or compile with `-DENABLE_GRAPHVIZ_TRACE` to always enable tracing.

This will generate a file like `demangle_trace__ZN4llvm8DenseMapIPKN5clang4DeclEPNS_6WeakVHE.dot`.

### Generating Images

Convert the `.dot` file to a visual format:

```bash
# PNG image
dot -Tpng demangle_trace.dot -o parsing_tree.png

# SVG (scalable)
dot -Tsvg demangle_trace.dot -o parsing_tree.svg

# PDF
dot -Tpdf demangle_trace.dot -o parsing_tree.pdf
```

### Graph Structure

The generated graph shows:
- **Root node**: The initial `mangled_name` rule
- **Child nodes**: All rules called during parsing
- **Edge colors**: Match the node status (green for success, red for failure, etc.)
- **Node labels**: Include rule name, position, input snippet, and result
- **Legend**: Explains the color coding

This visual representation makes it much easier to understand complex backtracking scenarios and identify where parsing issues occur.

## Building

```
meson -Dbuildtype=debugoptimized -Db_sanitize=address,undefined build
ninja -C build test
```
218 changes: 146 additions & 72 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,104 +1,178 @@
project('libdemangle', 'c', meson_version: '>=0.49.0')
project('libdemangle', 'c', meson_version : '>=0.49.0')

cc = meson.get_compiler('c')

common_c_args = []
libdemangle_c_args = []
libdemangle_src = [
'src' / 'cxx' / 'borland.c',
'src' / 'cxx.c',
'src' / 'demangler.c',
'src' / 'demangler_util.c',
'src' / 'java.c',
'src' / 'microsoft_demangle.c',
'src' / 'msvc.c',
'src' / 'objc.c',
'src' / 'pascal' / 'pascal.c',
'src' / 'rust' / 'punycode.c',
'src' / 'rust' / 'rust.c',
'src' / 'rust' / 'rust_legacy.c',
'src' / 'rust' / 'rust_v0.c',
'src' / 'borland.c',
'src' / 'cxx.c',

'src' / 'cplusplus' / 'demangle.c',
'src' / 'cplusplus' / 'common.c',
'src' / 'cplusplus' / 'param.c',
'src' / 'cplusplus' / 'meta.c',
'src' / 'cplusplus' / 'parser_combinator.c',
'src' / 'cplusplus' / 'ast.c',
'src' / 'cplusplus' / 'dot_graph.c',
'src' / 'cplusplus' / 'v2.c',
'src' / 'cplusplus' / 'v3.c',

'src' / 'demangler.c',
'src' / 'demangler_util.c',
'src' / 'java.c',
'src' / 'microsoft_demangle.c',
'src' / 'msvc.c',
'src' / 'objc.c',
'src' / 'pascal' / 'pascal.c',
'src' / 'rust' / 'punycode.c',
'src' / 'rust' / 'rust.c',
'src' / 'rust' / 'rust_legacy.c',
'src' / 'rust' / 'rust_v0.c',
]

tests = [
'borland',
'java',
'msvc',
'objc',
'pascal',
'rust',
'borland',
'java',
'msvc',
'objc',
'pascal',
'rust',

'subs', # Substitution table tests

'cxx.00',
'cxx.01',
'cxx.02',
'cxx.03',
'cxx.04',
'cxx.05',
'cxx.06',
'cxx.07',
'cxx.08',
'cxx.09',
'cxx.10',
'cxx.11',
'cxx.12',
'cxx.13',
'cxx.14',
'cxx.15',
'cxx.16',
'cxx.17',
'cxx.18',
'cxx.19',
'cxx.20',
'cxx.21',
'cxx.22',
'cxx.23',
'cxx.24',
'cxx.25',
'cxx.26',

'cxx_base',
'cxx_gnu_v2',
'cxx_gnu_v3_type',
'cxx_gnu_v3_template',
'cxx_gnu_v3_llvm',
]

if get_option('use_gpl')
libdemangle_src += 'src' / 'cxx' / 'cp-demangle.c'
libdemangle_src += 'src' / 'gnu_v2' / 'cplus-dem.c'
common_c_args += '-DWITH_GPL=1'
tests += 'cxx'
tests += 'cxx_base'
tests += 'cxx_gnu_v2'
endif
unit_tests = [
'cxx_rules',
'vec_impl'
]

if get_option('use_swift_demangler')
libdemangle_src += 'src' / 'swift.c'
common_c_args += '-DWITH_SWIFT_DEMANGLER=1'
tests += 'swift'
libdemangle_src += 'src' / 'swift.c'
common_c_args += '-DWITH_SWIFT_DEMANGLER=1'
tests += 'swift'
endif

if get_option('default_library') == 'shared'
if cc.has_argument('-fvisibility=hidden')
libdemangle_c_args += '-fvisibility=hidden'
endif
if cc.has_argument('-fvisibility=hidden')
libdemangle_c_args += '-fvisibility=hidden'
endif
endif

if cc.has_argument('--std=gnu99')
add_project_arguments('--std=gnu99', language: 'c')
add_project_arguments('--std=gnu99', language : 'c')
elif cc.has_argument('--std=c99')
add_project_arguments('--std=c99', language: 'c')
add_project_arguments('--std=c99', language : 'c')
endif

libdemangle = library('demangle', libdemangle_src,
libdemangle = both_libraries(
'demangle',
libdemangle_src,
c_args : common_c_args + libdemangle_c_args,
dependencies: [],
implicit_include_directories: false,
install: get_option('install_lib'),
include_directories: include_directories(['include', 'src']))
dependencies : [],
implicit_include_directories : false,
install : get_option('install_lib'),
include_directories : include_directories(['include', 'src']),
)

libdemangle_dep = declare_dependency(
link_with: libdemangle,
dependencies: [],
include_directories: include_directories('include'),
link_with : libdemangle,
dependencies : [],
include_directories : include_directories('include'),
)

if get_option('enable_cli')
bin_demangle = [
'bin' / 'demangle.c',
]
executable('demangle', bin_demangle,
c_args : common_c_args,
dependencies: [libdemangle_dep],
include_directories: include_directories(['include', 'src']),
implicit_include_directories: false,
install: true,
)
bin_demangle = [
'bin' / 'demangle.c',
]
executable(
'demangle',
bin_demangle,
c_args : common_c_args,
dependencies : [libdemangle_dep],
include_directories : include_directories(['include', 'src']),
implicit_include_directories : false,
install : true,
)
endif

if get_option('enable_tests') and not meson.is_subproject()
test_dependencies = [libdemangle_dep]
if get_option('b_sanitize').contains('address')
test_dependencies += cc.find_library('asan')
endif
if get_option('b_sanitize').contains('undefined')
test_dependencies += cc.find_library('ubsan')
endif
foreach test : tests
exe = executable('test_@0@'.format(test), 'test/test_@0@.c'.format(test),
include_directories: include_directories(['include', 'test']),
dependencies: test_dependencies,
c_args : common_c_args,
install: false,
install_rpath: '',
implicit_include_directories: false
)
test(test, exe)
endforeach
test_dependencies = []
if get_option('b_sanitize').contains('address')
test_dependencies += cc.find_library('asan')
endif
if get_option('b_sanitize').contains('undefined')
test_dependencies += cc.find_library('ubsan')
endif
# Tests that need longer timeout due to large number of test cases
# (especially when running with sanitizers like ASAN)
slow_tests = ['cxx_base']

foreach test : tests
exe = executable(
'test_@0@'.format(test),
'test/test_@0@.c'.format(test),
link_whole : libdemangle.get_static_lib(),
include_directories : include_directories(['include', 'test']),
dependencies : test_dependencies,
c_args : common_c_args,
install : false,
install_rpath : '',
implicit_include_directories : false,
)
if test in slow_tests
test(test, exe, timeout : 120)
else
test(test, exe)
endif
endforeach

foreach test : unit_tests
exe = executable(
'test_@0@'.format(test),
'test/unit/test_@0@.c'.format(test),
link_whole : libdemangle.get_static_lib(),
include_directories : include_directories(['include', 'test']),
dependencies : test_dependencies,
c_args : common_c_args,
install : false,
install_rpath : '',
implicit_include_directories : false,
)
test(test, exe)
endforeach
endif
3 changes: 1 addition & 2 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
option('use_gpl', type: 'boolean', value: true, description: 'Set to false when you want to disable gpl code')
option('use_swift_demangler', type: 'boolean', value: true, description: 'If false, disables the swift demangler')
option('install_lib', type: 'boolean', value: false, description: 'install libdemangle in the specified prefix path.')
option('enable_cli', type: 'boolean', value: false, description: 'install a cli to demangle symbols.')
option('enable_tests', type: 'boolean', value: true, description: 'Build unit tests in test/')
option('enable_tests', type: 'boolean', value: true, description: 'Build unit tests in test/')
File renamed without changes.
Loading
Loading