Skip to content

octal notation, -Wall -Wextra -Werror -march=native#165

Merged
pointbazaar merged 5 commits intomasterfrom
octal-notation
Apr 20, 2025
Merged

octal notation, -Wall -Wextra -Werror -march=native#165
pointbazaar merged 5 commits intomasterfrom
octal-notation

Conversation

@pointbazaar
Copy link
Owner

@pointbazaar pointbazaar commented Apr 20, 2025

Summary by CodeRabbit

  • New Features

    • Added support for octal integer literals in the language and lexer.
    • Introduced an example demonstrating octal notation usage.
  • Bug Fixes

    • Improved type safety by updating loop index and buffer index types to unsigned where appropriate.
    • Corrected format specifiers for 64-bit integers in output and debug statements.
    • Fixed signed/unsigned comparison issues in various places.
  • Refactor

    • Simplified and cleaned up function signatures and removed unused parameters and variables across the codebase.
    • Streamlined architecture-specific register handling and reporting.
    • Removed special handling and tokenization for C-style #include directives.
  • Documentation

    • Updated or removed unnecessary include directives in example and standard library files.
  • Tests

    • Enhanced test assertions and buffer sizes for more robust test coverage.
    • Removed obsolete tests related to #include directive handling.
  • Chores

    • Removed redundant or unused build configuration options and variables.
    • Added GNU extensions macro where needed for compatibility.

probably leftovers when it was still transpiling to C code.
I had thought these were already enabled but apparently they were not.
Lots of fixes to repair all the mistakes found by these warnings.

The correct way to add these options in cmake seems to be
the 'add_compile_options' directive.

That should also apply then to any subdirecties below where it is set.

[1] https://cmake.org/cmake/help/latest/command/add_compile_options.html#command
@coderabbitai
Copy link

coderabbitai bot commented Apr 20, 2025

Walkthrough

This set of changes primarily focuses on code cleanup, modernization, and minor feature enhancements across the codebase. Major changes include removing unused variables, parameters, functions, and labels, as well as updating loop index types from int to size_t for type safety. The handling of octal integer literals is introduced in the lexer, and support for #include directives is removed from the lexer, parser, AST, and token handling. CMake build scripts are refactored to apply compile options globally rather than through shared variables. Numerous files add the _GNU_SOURCE macro to enable GNU extensions. Minor bug fixes, assertion improvements in tests, and interface simplifications are also present.

Changes

Files / Groups Change Summary
CMakeLists.txt, */CMakeLists.txt Refactored to remove use of COMMON_OPTS variable and apply compile options directly or not at all; many targets no longer explicitly set compile options.
ast/ast.h, ast/util/free_ast.c, ast/util/copy_ast.c, ast/util/str_ast.c, ast/visitor/visitor.c Namespace struct fields for includes removed; count fields updated to size_t; related free, copy, and visitor logic updated accordingly; _GNU_SOURCE macro added in some utility files; buffer sizes and unused variables adjusted.
compiler/main/avr_code_gen/cg_avr_basic_block.c, .../compile_ir/compile_tac_binary_op.c, .../compile_ir/compile_tac_const_value.c, .../compile_ir/compile_tac_label.c, .../compile_ir/compile_tac_load_local_addr.c, .../compile_ir/compile_tac_unary_op.c, .../compile_ir/compile_tac_call.c, .../compile_ir/compile_tac_icall.c, .../x86_code_gen/allocate_registers_x86.c, .../x86_code_gen/compile_ir/compile_tac_binary_op.c, .../x86_code_gen/compile_ir/compile_tac_label.c, .../x86_code_gen/compile_ir/compile_tac_const_data.c, .../x86_code_gen/compile_ir/compile_tac_const_value.c, .../x86_code_gen/cg_x86_single_function.c Unused variables and functions removed; loop indices updated to size_t; improvements to type safety and clarity; some function signatures changed to remove unused parameters; added _GNU_SOURCE macro in several files.
compiler/main/basic_block/basicblock.c, .../basicblock_printer.c Type casts and _GNU_SOURCE macro added for type safety and GNU extensions.
compiler/main/analyzer/dead/dead_analyzer.c, .../lv/lv_analyzer.c Loop indices updated to size_t; _GNU_SOURCE macro added.
compiler/main/cli/main.c, .../flags/flags.c Architecture selection in rat_ctor made dynamic; _GNU_SOURCE macro added.
compiler/main/gen_tac/gen_tac_assignstmt.c, .../gen_tac/gen_tac_call.c, .../gen_tac/gen_tac_expr.c, .../gen_tac/gen_tac_forstmt.c, .../gen_tac/gen_tac_term.c Unused variables and functions removed; loop indices updated.
compiler/main/typechecker/*, compiler/main/typeinference/typeinfer_expr.c _GNU_SOURCE macro added in all files; function signatures simplified by removing unused parameters.
compiler/main/typechecker/type_contains/tc_primitivetype_contains.c Function signature updated to remove unused parameter.
ibuffer/ibuffer_write.c, ibuffer/ibuffer_x86.h Printf format specifiers updated for 64-bit integers; function parameter comment made const char*.
lexer/src/lexer.c, lexer/src/lexer_main.c, lexer/test/*, lexer/test/test.h, lexer/test/testcases/tests_include_decl.c Octal literals parsing added; support for #include directives removed from lexer, parser, AST, and token definitions; unused variables and functions removed; indices changed to size_t.
parser/main/astnodes/*, parser/main/util/parser.c _GNU_SOURCE macro added in many files; error labels removed; function signatures simplified.
rat/rat.c, rat/rat_x86.c, rat/rat_x86.h Register allocation logic improved for boundary checks and architecture awareness; function signatures simplified.
tables//lvst.c, tables//sst.c, tables//sst_fill.c, tables//sst_print.c, tables//stst.c, tables//stst_print.c, tables/*/symtable.c Loop indices updated to size_t or unsigned; unused parameters marked with (void); _GNU_SOURCE macro added.
tac/tacbuffer.c, tac/tacbuffer.h, tac/tacbuffer_optimize.c, tac/test/test_tac.c Buffer index types changed from int to size_t; format specifiers updated; unused variables removed; _GNU_SOURCE macro added.
token/TokenKeys.h, token/token/token.c, token/list/TokenList.c Token kind for INCLUDE_DECL removed; token string mapping updated; token dumping prints all tokens.
stdlib/base/math.dg, stdlib/collections/*.dg, examples/other/everything.dg, examples/tc_err.dg, examples/typeinference/localvartypeinference.dg Unused #include directives removed from example and stdlib files.
examples/octal/octal_notation.dg, examples/octal/octal_notation.exitcode New example demonstrating octal integer literals and expected output file added.
examples/stdlib/syscalls/write_file/write_file.dg File permission mode changed from hexadecimal to octal notation.
compiler/test/*, tables/test/test.c, compiler/test/x86_code_gen/test_x86_code_gen_util.c Buffer sizes increased in tests; assertions improved; loop indices updated; unused variables and labels removed; _GNU_SOURCE macro added in some tests.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Lexer
    participant Parser
    participant AST

    User->>Lexer: Provide source code with integer literals (including octal)
    Lexer->>Lexer: Detect integer literals
    alt Starts with "0"
        Lexer->>Lexer: Parse as octal literal
        Lexer->>Parser: Output decimal value token
    else
        Lexer->>Parser: Output decimal/hex token as normal
    end
    Parser->>AST: Build AST (no includes handled)
    AST->>User: AST without include declarations
Loading

Possibly related PRs

  • pointbazaar/espl1000#147: Modifies the same AVR code generator file (cg_avr_basic_block.c) by adding return types and error handling to register allocation functions, closely related to the cleanup and removal of unused variables in this PR.

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 19cbe4a and ad2b48e.

📒 Files selected for processing (36)
  • ast/util/copy_ast.c (1 hunks)
  • ast/util/str_ast.c (3 hunks)
  • compiler/main/analyzer/lv/lv_analyzer.c (1 hunks)
  • compiler/main/basic_block/basicblock_printer.c (1 hunks)
  • compiler/main/cli/flags/flags.c (1 hunks)
  • compiler/main/compiler.c (4 hunks)
  • compiler/main/typechecker/tc_address_of.c (1 hunks)
  • compiler/main/typechecker/tc_assignstmt.c (1 hunks)
  • compiler/main/typechecker/tc_deref.c (1 hunks)
  • compiler/main/typechecker/tc_expr.c (1 hunks)
  • compiler/main/typechecker/tc_ifstmt.c (1 hunks)
  • compiler/main/typechecker/tc_methodcall.c (1 hunks)
  • compiler/main/typechecker/tc_retstmt.c (1 hunks)
  • compiler/main/typechecker/tc_whilestmt.c (1 hunks)
  • compiler/main/typeinference/typeinfer_expr.c (1 hunks)
  • compiler/main/x86_code_gen/cg_x86_single_function.c (1 hunks)
  • compiler/main/x86_code_gen/compile_ir/compile_tac_const_data.c (1 hunks)
  • compiler/main/x86_code_gen/compile_ir/compile_tac_const_value.c (1 hunks)
  • compiler/test/test.c (1 hunks)
  • compiler/test/x86_code_gen/fake_lvst.c (2 hunks)
  • ibuffer/ibuffer_x86.h (1 hunks)
  • lexer/src/lexer.c (8 hunks)
  • parser/main/astnodes/EnumMember.c (1 hunks)
  • parser/main/astnodes/Identifier.c (1 hunks)
  • parser/main/astnodes/Namespace.c (3 hunks)
  • parser/main/astnodes/statements/ForStmt.c (1 hunks)
  • parser/main/astnodes/statements/LocalVarDeclStmt.c (1 hunks)
  • parser/main/astnodes/struct/StructMember.c (1 hunks)
  • parser/main/astnodes/subr/DeclArg.c (1 hunks)
  • parser/main/astnodes/subr/MethodDecl.c (1 hunks)
  • parser/main/astnodes/types/StructType.c (1 hunks)
  • parser/main/astnodes/var/SimpleVar.c (2 hunks)
  • tables/cc/cc.c (1 hunks)
  • tables/sst/sst.c (7 hunks)
  • tables/stst/stst.c (4 hunks)
  • tac/test/test_tac.c (1 hunks)
✅ Files skipped from review due to trivial changes (21)
  • compiler/main/typechecker/tc_assignstmt.c
  • tables/stst/stst.c
  • compiler/test/test.c
  • compiler/main/analyzer/lv/lv_analyzer.c
  • parser/main/astnodes/Identifier.c
  • compiler/main/typechecker/tc_expr.c
  • parser/main/astnodes/statements/LocalVarDeclStmt.c
  • compiler/main/x86_code_gen/compile_ir/compile_tac_const_data.c
  • parser/main/astnodes/subr/DeclArg.c
  • tables/cc/cc.c
  • compiler/main/x86_code_gen/compile_ir/compile_tac_const_value.c
  • compiler/main/cli/flags/flags.c
  • ast/util/copy_ast.c
  • parser/main/astnodes/struct/StructMember.c
  • compiler/main/compiler.c
  • compiler/main/typeinference/typeinfer_expr.c
  • compiler/main/typechecker/tc_retstmt.c
  • compiler/main/typechecker/tc_methodcall.c
  • parser/main/astnodes/types/StructType.c
  • ibuffer/ibuffer_x86.h
  • compiler/main/basic_block/basicblock_printer.c
🚧 Files skipped from review as they are similar to previous changes (12)
  • compiler/main/typechecker/tc_deref.c
  • compiler/test/x86_code_gen/fake_lvst.c
  • parser/main/astnodes/statements/ForStmt.c
  • parser/main/astnodes/EnumMember.c
  • parser/main/astnodes/var/SimpleVar.c
  • parser/main/astnodes/subr/MethodDecl.c
  • compiler/main/x86_code_gen/cg_x86_single_function.c
  • compiler/main/typechecker/tc_address_of.c
  • tac/test/test_tac.c
  • ast/util/str_ast.c
  • parser/main/astnodes/Namespace.c
  • tables/sst/sst.c
🧰 Additional context used
🧬 Code Graph Analysis (1)
lexer/src/lexer.c (2)
lexer/src/driver.h (1)
  • out_length (10-10)
lexer/src/driver.c (1)
  • out_length (30-41)
🔇 Additional comments (11)
compiler/main/typechecker/tc_whilestmt.c (1)

1-2: Good addition of _GNU_SOURCE macro.

Adding the _GNU_SOURCE macro definition is appropriate since this file uses the GNU extension asprintf() on line 34. This change aligns with the PR objective to comply with stricter compiler flags (-Wall -Wextra -Werror), as it properly declares the intent to use GNU extensions.

compiler/main/typechecker/tc_ifstmt.c (1)

1-1: Addition of _GNU_SOURCE macro is appropriate.

The added _GNU_SOURCE macro definition is correctly placed at the top of the file before any includes. This macro enables GNU-specific extensions in the C standard library, which is necessary for using functions like asprintf() (used on line 34) that are not part of the standard C library.

This change is consistent with the PR's pattern of adding this definition across multiple files to standardize feature test macros throughout the codebase.

lexer/src/lexer.c (9)

54-58: Improved type safety with size_t

Good change using size_t instead of int for the index variable. This is more appropriate for array indices and length calculations, providing better type safety and consistency with standard library functions.


93-96: Improved type safety with size_t

Good change using size_t instead of int for the index variable in the binary constant handler. This provides better type safety when dealing with string lengths and indices.


103-106: Improved type safety with size_t

Good change using size_t instead of int for the index variable in the hexadecimal constant handler. This provides better type safety when dealing with string lengths and indices.


113-121: Improved type safety with size_t

Good change using size_t instead of int for the temporary length variable. This is more appropriate for string length calculations and provides better type safety.


137-137: Improved type safety with size_t

Good change using size_t instead of int for the loop index when processing string constants. This provides better type safety and is more appropriate for iterating through arrays.


166-167: Explicitly mark unused parameter

Good practice to explicitly mark the unused parameter with (void) to silence compiler warnings and make the intention clear in the code.


188-189: Improved type safety and unused parameter handling

Good changes:

  1. Explicitly marking the unused TokenList parameter with (void)
  2. Using size_t instead of int for the index variable

Both improve code quality by making intentions clear and using appropriate types.


198-199: Improved type safety and unused parameter handling

Good changes:

  1. Explicitly marking the unused TokenList parameter with (void)
  2. Using size_t instead of int for the index variable

Both improve code quality by making intentions clear and using appropriate types.


208-210: Properly mark all unused parameters

Good practice to explicitly mark all unused parameters with (void) casts. This silences compiler warnings and clearly indicates that these parameters are intentionally unused in this function that only increments the global line counter.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@netlify
Copy link

netlify bot commented Apr 20, 2025

Deploy Preview for espl1000 ready!

Name Link
🔨 Latest commit ad2b48e
🔍 Latest deploy log https://app.netlify.com/sites/espl1000/deploys/6805030a2593760008a6143c
😎 Deploy Preview https://deploy-preview-165--espl1000.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 20

🔭 Outside diff range comments (3)
examples/other/everything.dg (1)

20-20: ⚠️ Potential issue

Fix the return type arrow syntax.

The main function signature uses ~> but the DSL elsewhere (e.g., sub1, sub2) uses -> for return types. Update to match the expected syntax:

-fn main () ~> int {
+fn main () -> int {
tables/stst/stst.c (1)

158-159: ⚠️ Potential issue

Fix implicit declaration of asprintf function

There's a pipeline failure due to the implicit declaration of the asprintf function. Although this isn't part of your changes, it's causing the build to fail.

Add the following include at the top of the file to fix this issue:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
+
+// For asprintf function
+#define _GNU_SOURCE
+#include <stdio.h>

Alternatively, you could replace the asprintf calls with more portable code:

-asprintf(&(line->_namespace), "%s", _namespace);
-asprintf(&(line->name), "%s", s->type->struct_type->type_name);
+line->_namespace = strdup(_namespace);
+line->name = strdup(s->type->struct_type->type_name);
🧰 Tools
🪛 CircleCI: build-job-ubuntu-2004

[error] 158-158: Implicit declaration of function 'asprintf'; did you mean 'vsprintf'? (error due to -Werror=implicit-function-declaration)

🪛 CircleCI: valgrind

[error] 158-158: implicit declaration of function ‘asprintf’; did you mean ‘vsprintf’? (gcc -Werror=implicit-function-declaration)

tables/lvst/lvst.c (1)

169-171: 🛠️ Refactor suggestion

Update printf format specifiers after switching to size_t

Loop indices & counters were migrated to size_t, but the related
printf statements still use %d / %ld.
With -Wall -Wextra -Werror this will raise
-Wformat errors on some platforms. Use the portable C99 specifier %zu.

-	fprintf(stderr, "lvst has %ld local vars, %ld args\n", nvars, nargs);
+	fprintf(stderr, "lvst has %zu local vars, %zu args\n", nvars, nargs);

-	printf(fmt, "name", "is_arg", "Type");
+	printf(fmt, "name", "is_arg", "Type");

-	for (size_t i = 0; i < lvst->count; i++) {
+	for (size_t i = 0; i < lvst->count; i++) {
     ...
-	printf("[LVST][Error] index %d not found in LVST\n", index);
+	printf("[LVST][Error] index %u not found in LVST\n", index);

(same change applies to other %ld/%d printing size_t or uint32_t
values in this file.)

Also applies to: 200-207, 330-338

🧹 Nitpick comments (2)
examples/other/everything.dg (1)

1-1: Complete or refine the example description comment.

The opening comment //The goal of this example is to ends abruptly and leaves the reader guessing. Consider finishing the sentence to clearly communicate the example’s purpose. For instance:

-//The goal of this example is to
+// The goal of this example is to showcase all statement types and Smalldragon features for comprehensive testing
rat/rat.c (1)

374-374: Added default return value for rat_base_ptr

The addition of a default return value for this function ensures it always returns something valid, even in unexpected cases. However, returning 0 instead of SD_REGISTER_END is inconsistent with the pattern used in other similar functions.

Consider using SD_REGISTER_END as the default return value for consistency with the other architecture-specific register functions:

-	return 0;
+	return SD_REGISTER_END;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 986067b and 5adf5d7.

📒 Files selected for processing (99)
  • CMakeLists.txt (1 hunks)
  • ast/CMakeLists.txt (0 hunks)
  • ast/ast.h (1 hunks)
  • ast/test/CMakeLists.txt (0 hunks)
  • ast/util/free_ast.c (1 hunks)
  • ast/util/str_ast.c (2 hunks)
  • ast/visitor/visitor.c (1 hunks)
  • compiler/main/CMakeLists.txt (0 hunks)
  • compiler/main/analyzer/dead/dead_analyzer.c (1 hunks)
  • compiler/main/avr_code_gen/cg_avr_basic_block.c (0 hunks)
  • compiler/main/avr_code_gen/compile_ir/compile_tac_binary_op.c (0 hunks)
  • compiler/main/avr_code_gen/compile_ir/compile_tac_const_value.c (1 hunks)
  • compiler/main/avr_code_gen/compile_ir/compile_tac_label.c (1 hunks)
  • compiler/main/basic_block/basicblock.c (2 hunks)
  • compiler/main/cli/main.c (1 hunks)
  • compiler/main/compiler.c (3 hunks)
  • compiler/main/gen_tac/gen_tac_assignstmt.c (0 hunks)
  • compiler/main/gen_tac/gen_tac_call.c (1 hunks)
  • compiler/main/gen_tac/gen_tac_expr.c (0 hunks)
  • compiler/main/gen_tac/gen_tac_forstmt.c (0 hunks)
  • compiler/main/gen_tac/gen_tac_term.c (0 hunks)
  • compiler/main/liveness/liveness.c (6 hunks)
  • compiler/main/typechecker/type_contains/tc_primitivetype_contains.c (2 hunks)
  • compiler/main/typeinference/infer_in_context.c (0 hunks)
  • compiler/main/x86_code_gen/allocate_registers_x86.c (3 hunks)
  • compiler/main/x86_code_gen/compile_ir/compile_tac_binary_op.c (0 hunks)
  • compiler/main/x86_code_gen/compile_ir/compile_tac_call.c (1 hunks)
  • compiler/main/x86_code_gen/compile_ir/compile_tac_icall.c (1 hunks)
  • compiler/main/x86_code_gen/compile_ir/compile_tac_label.c (1 hunks)
  • compiler/main/x86_code_gen/compile_ir/compile_tac_load_local_addr.c (0 hunks)
  • compiler/main/x86_code_gen/compile_ir/compile_tac_param.c (1 hunks)
  • compiler/main/x86_code_gen/compile_ir/compile_tac_unary_op.c (0 hunks)
  • compiler/test/CMakeLists.txt (0 hunks)
  • compiler/test/avr_code_gen/compile_ir/test_compile_tac_store.c (1 hunks)
  • compiler/test/avr_code_gen/timer/test_avr_code_gen_timer.c (0 hunks)
  • compiler/test/gen_tac/test_gen_tac_simplevar.c (1 hunks)
  • compiler/test/gen_tac/util/test_gen_tac_util.c (0 hunks)
  • compiler/test/libvmcu_utils/libvmcu_utils.c (0 hunks)
  • compiler/test/testcases.c (0 hunks)
  • compiler/test/x86_code_gen/compile_ir/test_compile_tac_binary_op.c (4 hunks)
  • compiler/test/x86_code_gen/compile_ir/test_compile_tac_if_cmp_goto.c (1 hunks)
  • compiler/test/x86_code_gen/compile_ir/test_compile_tac_if_goto.c (2 hunks)
  • compiler/test/x86_code_gen/compile_ir/test_compile_tac_return.c (1 hunks)
  • compiler/test/x86_code_gen/compile_ir/test_compile_tac_unary_op.c (1 hunks)
  • compiler/test/x86_code_gen/fake_lvst.c (1 hunks)
  • compiler/test/x86_code_gen/test_x86_code_gen_util.c (6 hunks)
  • examples/octal/octal_notation.dg (1 hunks)
  • examples/octal/octal_notation.exitcode (1 hunks)
  • examples/other/everything.dg (1 hunks)
  • examples/stdlib/syscalls/write_file/write_file.dg (1 hunks)
  • examples/tc_err.dg (0 hunks)
  • examples/typeinference/localvartypeinference.dg (0 hunks)
  • ibuffer/CMakeLists.txt (0 hunks)
  • ibuffer/ibuffer_write.c (2 hunks)
  • lexer/src/CMakeLists.txt (0 hunks)
  • lexer/src/lexer.c (8 hunks)
  • lexer/src/lexer_main.c (0 hunks)
  • lexer/test/CMakeLists.txt (0 hunks)
  • lexer/test/test.h (0 hunks)
  • lexer/test/testcases/tests_include_decl.c (0 hunks)
  • lexer/test/testcases/tests_other.c (1 hunks)
  • parser/main/CMakeLists.txt (0 hunks)
  • parser/main/astnodes/Namespace.c (2 hunks)
  • parser/main/astnodes/expr/Term.c (1 hunks)
  • parser/main/astnodes/statements/AssignStmt.c (3 hunks)
  • parser/main/astnodes/types/Type.c (0 hunks)
  • parser/main/astnodes/var/SimpleVar.c (1 hunks)
  • parser/main/util/parser.c (0 hunks)
  • parser/test/CMakeLists.txt (0 hunks)
  • rat/CMakeLists.txt (0 hunks)
  • rat/rat.c (6 hunks)
  • rat/rat_x86.c (1 hunks)
  • rat/rat_x86.h (1 hunks)
  • rat/test/CMakeLists.txt (0 hunks)
  • stdlib/base/math.dg (0 hunks)
  • stdlib/collections/array.dg (0 hunks)
  • stdlib/collections/linkedlist.dg (0 hunks)
  • stdlib/collections/set.dg (0 hunks)
  • stdlib/collections/stack.dg (0 hunks)
  • tables/CMakeLists.txt (0 hunks)
  • tables/lvst/lvst.c (21 hunks)
  • tables/sst/sst.c (6 hunks)
  • tables/sst/sst_fill.c (1 hunks)
  • tables/sst/sst_print.c (1 hunks)
  • tables/stst/stst.c (3 hunks)
  • tables/stst/stst_print.c (1 hunks)
  • tables/symtable/symtable.c (1 hunks)
  • tables/test/CMakeLists.txt (0 hunks)
  • tables/test/test.c (0 hunks)
  • tac/CMakeLists.txt (0 hunks)
  • tac/tacbuffer.c (2 hunks)
  • tac/tacbuffer.h (1 hunks)
  • tac/tacbuffer_optimize.c (1 hunks)
  • tac/test/test_tac.c (0 hunks)
  • token/CMakeLists.txt (0 hunks)
  • token/TokenKeys.h (0 hunks)
  • token/list/TokenList.c (1 hunks)
  • token/token/token.c (1 hunks)
  • util/CMakeLists.txt (0 hunks)
💤 Files with no reviewable changes (45)
  • examples/typeinference/localvartypeinference.dg
  • compiler/test/testcases.c
  • tables/test/CMakeLists.txt
  • stdlib/collections/stack.dg
  • stdlib/collections/set.dg
  • lexer/src/lexer_main.c
  • lexer/test/test.h
  • stdlib/collections/linkedlist.dg
  • rat/CMakeLists.txt
  • rat/test/CMakeLists.txt
  • lexer/src/CMakeLists.txt
  • stdlib/base/math.dg
  • tac/CMakeLists.txt
  • token/CMakeLists.txt
  • compiler/main/typeinference/infer_in_context.c
  • compiler/main/CMakeLists.txt
  • ast/CMakeLists.txt
  • compiler/main/gen_tac/gen_tac_forstmt.c
  • parser/main/util/parser.c
  • parser/test/CMakeLists.txt
  • compiler/main/gen_tac/gen_tac_term.c
  • ast/test/CMakeLists.txt
  • util/CMakeLists.txt
  • token/TokenKeys.h
  • examples/tc_err.dg
  • ibuffer/CMakeLists.txt
  • tables/test/test.c
  • tables/CMakeLists.txt
  • parser/main/CMakeLists.txt
  • stdlib/collections/array.dg
  • compiler/main/x86_code_gen/compile_ir/compile_tac_unary_op.c
  • tac/test/test_tac.c
  • compiler/test/gen_tac/util/test_gen_tac_util.c
  • parser/main/astnodes/types/Type.c
  • compiler/main/gen_tac/gen_tac_assignstmt.c
  • compiler/test/libvmcu_utils/libvmcu_utils.c
  • lexer/test/CMakeLists.txt
  • compiler/main/x86_code_gen/compile_ir/compile_tac_load_local_addr.c
  • compiler/test/CMakeLists.txt
  • compiler/main/avr_code_gen/compile_ir/compile_tac_binary_op.c
  • lexer/test/testcases/tests_include_decl.c
  • compiler/main/avr_code_gen/cg_avr_basic_block.c
  • compiler/main/gen_tac/gen_tac_expr.c
  • compiler/test/avr_code_gen/timer/test_avr_code_gen_timer.c
  • compiler/main/x86_code_gen/compile_ir/compile_tac_binary_op.c
🧰 Additional context used
🧬 Code Graph Analysis (12)
tables/stst/stst_print.c (2)
tables/stst/stst.c (1)
  • stst_size (122-124)
tables/stst/stst.h (1)
  • stst_size (39-39)
tables/sst/sst_print.c (2)
tables/sst/sst.c (1)
  • sst_size (180-182)
tables/sst/sst.h (1)
  • sst_size (67-67)
ast/util/free_ast.c (1)
ast/util/free_ast.h (2)
  • free_enum_decl (32-32)
  • free_method (22-22)
compiler/test/x86_code_gen/compile_ir/test_compile_tac_return.c (2)
compiler/test/x86_code_gen/test_x86_code_gen_util.c (1)
  • sd_uc_reg_read (536-538)
compiler/test/x86_code_gen/test_x86_code_gen_util.h (1)
  • sd_uc_reg_read (35-35)
token/list/TokenList.c (1)
token/list/TokenList.h (2)
  • list_size (36-36)
  • list_get (30-30)
compiler/main/cli/main.c (2)
rat/rat.c (1)
  • rat_ctor (21-43)
rat/rat.h (1)
  • rat_ctor (18-18)
tac/tacbuffer.c (1)
tac/tacbuffer.h (2)
  • tacbuffer_set (27-27)
  • tacbuffer_get (30-30)
rat/rat_x86.c (1)
rat/rat_x86.h (1)
  • rat_print_regname_x86 (29-29)
compiler/main/x86_code_gen/allocate_registers_x86.c (3)
compiler/main/avr_code_gen/cg_avr_basic_block.c (1)
  • allocate_registers_single_tac (101-183)
tac/tacbuffer.h (2)
  • tacbuffer_count (34-34)
  • tacbuffer_get (30-30)
tac/tacbuffer.c (2)
  • tacbuffer_count (122-124)
  • tacbuffer_get (40-48)
parser/main/astnodes/Namespace.c (2)
token/list/TokenList.c (1)
  • list_copy (130-155)
token/list/TokenList.h (1)
  • list_copy (24-24)
rat/rat.c (3)
rat/rat_x86.h (1)
  • rat_print_regname_x86 (29-29)
rat/rat_x86.c (1)
  • rat_print_regname_x86 (203-208)
rat/rat.h (2)
  • rat_capacity (73-73)
  • rat_occupant (38-38)
lexer/src/lexer.c (2)
lexer/src/driver.h (1)
  • out_length (10-10)
lexer/src/driver.c (1)
  • out_length (30-41)
🪛 CircleCI: build-job-ubuntu-2004
tables/stst/stst.c

[error] 158-158: Implicit declaration of function 'asprintf'; did you mean 'vsprintf'? (error due to -Werror=implicit-function-declaration)

tables/sst/sst.c

[error] 90-90: Implicit declaration of function 'asprintf'; did you mean 'vsprintf'? (error due to -Werror=implicit-function-declaration)

🪛 CircleCI: valgrind
tables/stst/stst.c

[error] 158-158: implicit declaration of function ‘asprintf’; did you mean ‘vsprintf’? (gcc -Werror=implicit-function-declaration)

tables/sst/sst.c

[error] 90-90: implicit declaration of function ‘asprintf’; did you mean ‘vsprintf’? (gcc -Werror=implicit-function-declaration)

🔇 Additional comments (82)
tac/tacbuffer_optimize.c (1)

11-11: Good addition to suppress compiler warnings.

Adding (void)debug; explicitly marks the unused parameter to prevent compiler warnings when using strict compilation flags like -Wall -Wextra -Werror mentioned in the PR title.

parser/main/astnodes/var/SimpleVar.c (1)

72-72: LGTM: Clean whitespace removal.

This change simply removes an unnecessary blank line, improving code readability.

compiler/main/avr_code_gen/compile_ir/compile_tac_const_value.c (1)

19-19: Good buffer size increase to prevent potential overflows.

Increasing the character buffer size from 30 to 60 bytes helps prevent buffer overflow when formatting debug strings with longer constant values.

lexer/test/testcases/tests_other.c (1)

228-228: Good type consistency improvement.

Changing the loop index from int to size_t aligns with the type of expect_count, improving type safety by preventing potential signed/unsigned comparison issues.

tables/symtable/symtable.c (1)

50-50: Good type consistency fix.

Changing the loop index from int to size_t properly aligns with the type of st->inferred_types_count, preventing potential issues with signed/unsigned comparisons during iteration.

compiler/test/avr_code_gen/compile_ir/test_compile_tac_store.c (1)

49-49: Good addition - missing assertion was added.

This assertion ensures the test verifies that the stored value matches the expected value, which all other similar tests already had. This improves test coverage and consistency.

examples/stdlib/syscalls/write_file/write_file.dg (1)

5-5: Improved to standard octal notation for file permissions.

The change from hexadecimal to octal notation (0666) for file permissions follows Unix/Linux convention and improves readability. Both 0x1B6 and 0666 represent the same permissions (rw-rw-rw-), but octal is the standard format for representing file modes.

compiler/test/x86_code_gen/fake_lvst.c (1)

55-55: Good type consistency improvement.

Changed loop counters from int to size_t to match the type of nlocals and stackframe_nargs. This prevents potential signed/unsigned comparison warnings and follows best practices for iteration variables.

Also applies to: 58-58

CMakeLists.txt (1)

11-11: Simplified compiler flags application.

Replaced variable-based flags with direct application using add_compile_options. The flags enable:

  • Debug symbols (-g)
  • CPU architecture optimization (-march=native)
  • Comprehensive warnings (-Wall -Wextra)
  • Treating warnings as errors (-Werror)

This enforces strict code quality standards across the project.

examples/octal/octal_notation.exitcode (1)

1-2: Exit code file looks good

This file correctly specifies the expected exit code (54) for the octal notation example program, which aligns with the PR objective of adding octal notation support.

parser/main/astnodes/expr/Term.c (1)

96-100: Control flow simplified by removing unused label

The removal of the exit_error: label simplifies the control flow while preserving the same error handling logic. This is a good cleanup that aligns with the overall code simplification goals in the PR.

tables/stst/stst_print.c (1)

18-18: Improved type safety for loop index

Changing the loop index from int to size_t improves type safety by using the appropriate unsigned type for array indices. This aligns with the return type of stst_size() (which is uint32_t) and prevents potential signed/unsigned comparison issues.

compiler/main/x86_code_gen/compile_ir/compile_tac_icall.c (1)

17-18: Good practice: Explicit unused parameter marking

Adding the (void) casts to explicitly mark unused parameters is a good practice when working with strict compiler flags like -Wall -Wextra -Werror. This suppresses unused parameter warnings without changing the function behavior.

compiler/main/compiler.c (3)

63-63: Loop index type aligned with size_t count variable

Changing the loop index from int to size_t properly aligns the types and prevents potential issues with signed/unsigned comparisons, since count_filenames is declared as size_t.


93-93: Consistent size_t loop index for array iteration

Good consistency in changing this loop index to size_t to match the type of the count variable and the previous loop.


168-168: Completed size_t conversion for all loops

The conversion of all loop indices in this file to size_t ensures consistent type usage throughout the token list processing loops.

tables/sst/sst_print.c (1)

20-20: Improved type safety with size_t loop index

Changing the loop index from int to size_t eliminates potential signed/unsigned comparison issues since sst_size() returns a uint32_t value.

tables/sst/sst_fill.c (1)

11-11: Loop index type matches Namespace count_methods type

Changing the loop index from int to size_t correctly aligns with the updated type of ns->count_methods which was changed from uint16_t to size_t in the Namespace struct.

compiler/main/avr_code_gen/compile_ir/compile_tac_label.c (1)

27-27: Type safety improvement for better comparison

The cast of tac_dest(tac) to size_t ensures consistent unsigned comparison with sst_size(), which likely returns an unsigned size type. This eliminates potential issues from comparing signed and unsigned values.

compiler/main/x86_code_gen/compile_ir/compile_tac_label.c (1)

27-27: Type safety improvement in comparison logic

The cast of sst_size() to int32_t ensures a consistent signed comparison with tac_dest(tac). This approach differs from the AVR implementation (which casts to unsigned) but both achieve the same goal of type-consistent comparisons.

compiler/main/analyzer/dead/dead_analyzer.c (1)

60-60: Improved type safety for loop counter

Changing the loop variable type from int to size_t is appropriate when iterating over collection sizes. This matches the likely type of ns->count_methods and prevents potential issues with signed/unsigned comparisons.

compiler/main/x86_code_gen/compile_ir/compile_tac_call.c (1)

21-22: Suppressing unused parameter warning

Explicitly marking the unused parameter with (void)current_function_name; is a good practice to silence compiler warnings while maintaining the function signature for consistency with other implementations.

token/token/token.c (1)

75-75: Use of size_t improves type safety for string iteration

Changing the loop index from int to size_t is a good improvement as it properly matches the type of len (which is already defined as size_t on line 73). This change avoids potential signed/unsigned comparison issues when iterating over string data.

ast/util/free_ast.c (1)

61-62: Type consistency improvement for loop indices

Changing the loop counters from int to size_t is a positive improvement that makes the code more type-safe when working with the count fields in the Namespace struct. This change helps prevent potential signed/unsigned comparison issues and aligns with modern C programming practices.

Also applies to: 65-66, 69-70

compiler/test/x86_code_gen/compile_ir/test_compile_tac_return.c (2)

43-43: Added critical error checking for emulator initialization

Adding this assertion is a good defensive programming practice. It ensures that the Unicorn emulator successfully starts before continuing with the test, making the test more robust by failing early if there's an initialization problem.


48-48: Added critical error checking for register read operation

This assertion properly validates that the register read operation succeeded before checking the register value. This makes the test more robust by ensuring that failures in the emulator API are caught explicitly rather than potentially leading to misleading test results.

rat/rat_x86.h (1)

29-29: Function signature simplified by removing unused parameter

The removal of the struct RAT* rat parameter simplifies the function interface. This is a good refactoring since it makes the function more focused on its actual responsibility - printing an x86 register name. The removed parameter was likely unnecessary as the function can determine the register name solely from the register index.

examples/octal/octal_notation.dg (1)

1-11: LGTM! Good example of octal notation

This is a clean, concise example demonstrating the use of octal notation in the language. The function correctly initializes a uint64 with octal literal 0666 (438 decimal), subtracts 0600 (384 decimal), and returns the result 066 (54 decimal).

token/list/TokenList.c (2)

265-265: Improved token list dumping by removing the 10 token limit

The function now iterates through all tokens in the list instead of just the first 10, which aligns with the removal of special token handling across the codebase.


271-271: Better token value formatting with space prefix

Adding a space before printing the token's value improves readability in the output by ensuring proper separation between token kind and value.

compiler/test/gen_tac/test_gen_tac_simplevar.c (2)

85-85: Increased buffer size for safer string operations

Increasing the snippet buffer from 200 to 400 bytes helps prevent potential buffer overflows when dealing with larger code fragments.


87-87: Increased buffer size for safer string operations

Increasing the snippet2 buffer from 200 to 300 bytes helps prevent potential buffer overflows when dealing with larger code fragments.

tables/stst/stst.c (3)

52-52: Improved type safety with size_t for array indexing

Changing the loop index from int to size_t ensures type consistency with the unsigned count_structs variable used for array indexing, preventing potential signed/unsigned comparison issues.


64-64: Improved type safety with size_t for array indexing

Changing the loop index from int to size_t ensures type consistency with the unsigned count variable used for array indexing, preventing potential signed/unsigned comparison issues.


134-134: Improved type safety with size_t for array indexing

Changing the loop index from int to size_t ensures type consistency with the unsigned count variable used for array indexing, preventing potential signed/unsigned comparison issues.

compiler/main/cli/main.c (1)

22-22: Architecture selection improvement

The code now passes the dynamically selected architecture to rat_ctor instead of hardcoding RAT_ARCH_X86. This aligns with the earlier architecture determination in the function where arch is conditionally set based on flags.

ast/visitor/visitor.c (3)

86-86: Type safety improvement for loop counters

Changing from int to size_t for the loop counter aligns with the type of n->count_enums and follows best practices for array indexing, preventing potential issues with large arrays and negative indices.


90-90: Type safety improvement for loop counters

Changing from int to size_t for the loop counter aligns with the type of n->count_structs and follows best practices for array indexing.


94-94: Type safety improvement for loop counters

Changing from int to size_t for the loop counter aligns with the type of n->count_methods and follows best practices for array indexing.

compiler/main/gen_tac/gen_tac_call.c (1)

30-30: Type safety improvement for loop counters

Changed from int to size_t for the loop counter to match the count parameter type, avoiding potential signed/unsigned comparison issues and maintaining consistency with other similar changes throughout the codebase.

ast/util/str_ast.c (2)

306-306: Increased buffer size for type parameters

Increased malloc size from 4 to 6 bytes, likely to accommodate larger formatted output in the sprintf call at line 311. This prevents potential buffer overflow issues when formatting larger type parameter indices.


639-639: Added support for enum value terms

Added missing case to handle TERM_KIND_ENUM_VALUE by returning a duplicate of the enum value string. This properly handles enum values in the AST string representation, completing the switch statement implementation.

compiler/test/x86_code_gen/compile_ir/test_compile_tac_unary_op.c (1)

37-37: Good type safety fix with explicit cast.

Adding the explicit cast to int ensures proper signed comparison with the negated start value. This prevents potential assertion failures when comparing unsigned uint64_t with signed values.

compiler/test/x86_code_gen/compile_ir/test_compile_tac_if_cmp_goto.c (1)

19-20: Improved type consistency.

Changing these constants from int8_t to uint64_t properly aligns them with the 64-bit register and memory operations used in the tests. This prevents potential issues with type promotion during comparisons on lines 70-75.

compiler/test/x86_code_gen/compile_ir/test_compile_tac_if_goto.c (2)

19-19: Type consistency improvement.

Changing from int8_t to uint64_t aligns with the overall pattern of using consistent types for register values and ensures proper comparison with the read variable on line 50.


89-89: Explicit casts prevent signed/unsigned comparison issues.

Adding explicit casts to int ensures the comparison is done between values of the same signedness, preventing unexpected behavior when comparing signed and unsigned values.

ast/ast.h (2)

42-42: Appropriate type changes for count fields.

Changing from uint16_t to size_t for count variables is a good practice. size_t is the standard type for sizes and counts in C, and this change aligns with the use of size_t for the corresponding capacity fields.

This also prepares the code for potentially larger collections and ensures consistency with loop counters elsewhere in the codebase.

Also applies to: 47-48, 51-52


31-53: Removed include-related fields from Namespace struct.

The removal of count_includes and includes fields from the Namespace struct is consistent with the PR's goal of removing support for handling #include directives. This simplifies the AST structure.

compiler/test/x86_code_gen/compile_ir/test_compile_tac_binary_op.c (4)

42-42: Type cast ensures consistent comparison.

The addition of the (int) cast properly ensures that the 64-bit register value is compared correctly with the 8-bit expected value. This fix prevents potential sign extension issues when comparing different integer sizes.


74-74: Type cast ensures consistent comparison.

Similarly, this cast properly handles the comparison between the 64-bit register value and the 8-bit expected value, ensuring sign is correctly interpreted.


105-105: Type cast ensures consistent comparison.

This cast addresses the same issue - ensuring proper comparison between the 64-bit rax register value and the 8-bit expected value in a bitwise AND operation.


136-136: Type cast ensures consistent comparison.

This type cast provides consistency with the other binary operations, ensuring proper comparison between different integer sizes in the OR operation test.

rat/rat_x86.c (1)

203-203: Function signature simplified by removing unused parameter.

The struct RAT* rat parameter has been removed from the function signature, which is a good simplification since the parameter wasn't being used. This matches the declaration in rat/rat_x86.h.

tables/sst/sst.c (6)

54-54: Loop index type changed to match container size type.

Changing the loop index from int to uint32_t to match the type of sst->count (which is uint32_t) prevents potential signed/unsigned comparison warnings.


69-69: Loop index type changed to match container size type.

Similarly, this change aligns the loop counter type with sst->count for type consistency.


85-86: Explicitly cast unused parameter to void.

This change properly suppresses compiler warnings about the unused isLibC parameter.


169-169: Loop index type changed to match container size type.

This change to uint32_t maintains consistency with the type of sst->count.


195-195: Loop index type changed to match container size type.

Using size_t instead of int for the loop counter is appropriate when iterating through array indices.


226-226: Loop index type changed to match container size type.

Using size_t for index variables is a good practice when iterating through arrays.

tac/tacbuffer.c (3)

29-29: Parameter type changed from int to size_t.

Changing the index parameter type from int to size_t aligns with the function declaration in the header file and is more appropriate for array indices which should always be non-negative.


40-40: Parameter type changed from int to size_t.

Similarly, this type change ensures consistency between the function implementation and its declaration in the header.


43-43: Format specifier updated to match size_t.

The format specifier has been correctly updated from %d to %ld to match the size_t type of the index parameter.

compiler/main/basic_block/basicblock.c (2)

81-81: Good explicit type cast for signedness compatibility.

Adding this explicit cast to ssize_t ensures proper comparison between the signed return value from tacbuffer_indexof and the unsigned result of tacbuffer_count(buffer) - 1, preventing potential issues with signed/unsigned comparisons.


100-100: Appropriate cast for comparing different integer types.

This explicit cast from uint32_t to int32_t ensures type correctness when comparing with the result of tac_label_index(). This prevents potential compiler warnings and subtle bugs from signed/unsigned comparisons.

compiler/test/x86_code_gen/test_x86_code_gen_util.c (6)

57-57: Good explicit void cast for unused parameter.

Marking the unused parameter with (void) suppresses compiler warnings while making the intention clear that this parameter is deliberately unused in the function.


72-73: Good explicit void casts for unused parameters.

Properly marking both unused parameters with (void) casts suppresses compiler warnings. This is especially important when compiling with -Wall -Wextra flags.


191-191: Improved loop index type from int to size_t.

Using size_t for array iteration is more appropriate since you're comparing against the result of a sizeof expression, which returns size_t. This eliminates potential signed/unsigned comparison warnings.


350-350: Appropriate use of size_t for loop counter.

Changed from int to size_t to match the type of nargs, which is consistent with best practices for iterating over collections with non-negative indices.


372-372: Proper index type for array iteration.

Using size_t instead of int for the loop counter matches the type of nargs and follows best practices for array iteration with non-negative indices.


565-565: Consistent use of size_t for array iteration.

Using size_t for the loop index is appropriate when calculating array length with sizeof. This provides type consistency and prevents signed/unsigned comparison warnings.

tac/tacbuffer.h (2)

27-27: Improved parameter type for array indexing.

Changed index parameter from int to size_t, which is the appropriate type for array indices. This provides better type safety and consistency with the standard library.


30-30: Consistent use of size_t for index parameter.

The parameter type change from int to size_t for the index aligns with best practices for array indexing and maintains consistency with the tacbuffer_set function's signature change.

compiler/main/x86_code_gen/allocate_registers_x86.c (4)

16-16: Simplified function signature by removing unused parameter.

Removing the unused struct ST* st parameter from the function declaration reduces the function's complexity and dependency on the symbol table structure.


32-33: Properly marked unused parameter with void cast.

Adding (void)st; explicitly acknowledges that the parameter is deliberately unused, which suppresses compiler warnings when building with -Wall -Wextra -Werror flags.


39-39: Updated function call to match new signature.

The function call has been updated to remove the st parameter, maintaining consistency with the new function signature defined on line 16.


88-88: Updated function implementation to match new declaration.

The function implementation has been correctly updated to match the new signature without the struct ST* st parameter, consistent with its declaration on line 16.

rat/rat.c (6)

80-80: Function call updated to match new signature

The call to rat_print_regname_x86 has been updated to remove the rat parameter, matching the new function signature in rat/rat_x86.c (line 203). This simplifies the interface by removing an unnecessary parameter that wasn't being used in the implementation.


268-278: Improved boundary checking and logic in rat_is_wide

The rewritten function now has better boundary and occupancy checks with a more logical flow:

  1. Check if the next register is within bounds
  2. Verify that the next register is occupied
  3. Confirm that the occupant is the same temporary variable

This is clearer than the previous implementation and correctly identifies when a temporary uses a register pair.


350-351: Added explicit default return value

Adding an explicit default return value for rat_scratch_reg ensures the function always returns a value even if the architecture is not handled in the switch statement. This is good defensive programming that prevents undefined behavior.


362-363: Added explicit default return value

Similar to the previous change, adding a default return for rat_return_reg ensures proper handling of unexpected architecture values.


386-387: Added explicit default return value

Adding an explicit default return value for rat_stack_ptr is consistent with the other changes and prevents undefined behavior.


392-398: Architecture-specific register capacity handling

The rat_capacity function now returns architecture-specific register capacity constants (SD_REG_END_X86 for x86 and SD_REGISTER_END for AVR), which correctly reflects the actual register constraints for each architecture.

This is a better approach than using a hardcoded value, as it makes the code more maintainable and adaptable to changes in the register definitions for each architecture.

@pointbazaar pointbazaar force-pushed the octal-notation branch 11 times, most recently from 8e6d4fa to 5dc935e Compare April 20, 2025 13:52
Fixes for issues found in code review
@pointbazaar pointbazaar merged commit 36f87cb into master Apr 20, 2025
15 checks passed
@pointbazaar pointbazaar deleted the octal-notation branch April 20, 2025 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant