-
Notifications
You must be signed in to change notification settings - Fork 8
Fix statically linked library functions being filtered out #49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
mattgodbolt
wants to merge
3
commits into
main
Choose a base branch
from
claude/fix_filter
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| # CLAUDE.md | ||
|
|
||
| This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. | ||
|
|
||
| ## Project Overview | ||
|
|
||
| asm-parser is a C++ tool that categorizes and filters assembly code for Compiler Explorer. It processes both regular compiler assembly output and GNU objdump binary output, providing JSON or text output with filtered assembly suitable for display in CE. | ||
|
|
||
| ## Build Commands | ||
|
|
||
| **Initial Setup:** | ||
| ```bash | ||
| ./setup.sh # Sets up Python venv, installs Conan2, configures C++20 profile | ||
| ``` | ||
|
|
||
| **Development Build:** | ||
| ```bash | ||
| cd build | ||
| cmake .. -DCMAKE_BUILD_TYPE=Debug -G Ninja # Ninja preferred | ||
| cmake --build . --config Debug | ||
| ``` | ||
|
|
||
| **Production Build:** | ||
| ```bash | ||
| mkdir -p build && cd build | ||
| cmake -GNinja -DCMAKE_BUILD_TYPE=Release .. | ||
| cmake --build . --target asm-parser | ||
| ``` | ||
|
|
||
| **Running Tests:** | ||
| ```bash | ||
| make test # Via CMake/CTest | ||
| ./build/src/test/asm-parser-test # Direct execution | ||
| ``` | ||
|
|
||
| **Code Formatting:** | ||
| ```bash | ||
| clang-format -i src/*/*.cpp src/*/*.hpp | ||
| ``` | ||
|
|
||
| ## Architecture | ||
|
|
||
| **Core Components:** | ||
| - `src/assembly/parser.{cpp,hpp}` - Parses compiler assembly text output | ||
| - `src/objdump/parser.{cpp,hpp}` - Parses GNU objdump binary output | ||
| - `src/types/` - Core interfaces (IParser) and data structures (Filter, Line) | ||
| - `src/utils/` - JSON output, regex wrappers, library detection utilities | ||
|
|
||
| **Parser Architecture:** | ||
| Both parsers implement `IParser` interface with state machine-based parsing. The `Filter` struct controls which filtering operations are applied (directives, unused labels, comments, library functions, etc.). | ||
|
|
||
| **Key Features:** | ||
| - Binary mode: Processes objdump output with addresses, opcodes, relocations | ||
| - Assembly text mode: Processes compiler-generated assembly | ||
| - Label analysis: Identifies and removes unused labels/functions | ||
| - Library detection: Filters external library code based on file paths | ||
| - Multiple output formats: JSON (default) or filtered text | ||
|
|
||
| ## Testing Framework | ||
|
|
||
| Uses **Catch2** with **ApprovalTests** for regression testing. Test data in `/resources/` includes real-world assembly examples and bug reproduction cases from Compiler Explorer. | ||
|
|
||
| **Test file naming convention:** | ||
| - Input: `resources/example.asm` | ||
| - Expected output: `resources/asmtext_filter_tests.example.approved.txt` | ||
|
|
||
| Tests cover various architectures, compiler outputs, and edge cases from CE bug reports. | ||
|
|
||
| ## Dependencies | ||
|
|
||
| Managed via **Conan 2.x**: | ||
| - Catch2 2.13.10 (testing) | ||
| - ApprovalTests.cpp 10.12.2 (golden master testing) | ||
| - fmt 11.0.0 (string formatting) | ||
| - ctre 3.7.1 (compile-time regex) | ||
|
|
||
| ## Development Notes | ||
|
|
||
| - Requires GCC 12+ or equivalent with C++20 support | ||
| - Debug builds include sanitizers (AddressSanitizer, LeakSanitizer, UBSan) | ||
| - Release builds use -O3 with Link Time Optimization | ||
| - UTF-8 locale required for Unicode support | ||
| - Production deployment copies binary to `/usr/local/bin/asm-parser` | ||
|
|
||
| ## Common Usage Patterns | ||
|
|
||
| **Binary objdump processing:** | ||
| ```bash | ||
| objdump -d a.out -l --insn-width=16 | asm-parser -stdin -binary | ||
| ``` | ||
|
|
||
| **Assembly text filtering:** | ||
| ```bash | ||
| asm-parser -directives -unused_labels -comment_only file.asm | ||
| ``` | ||
|
|
||
| **Text output mode:** | ||
| ```bash | ||
| asm-parser -outputtext -library_functions input.asm | ||
| ``` |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.