Skip to content

🧹 Refactor function-static labels and ordinals in lexer and lowering - #8

Open
jnorthrup wants to merge 1 commit into
mainfrom
fix-uninitialized-static-ordinal-929319608379097434
Open

jnorthrup wants to merge 1 commit into
mainfrom
fix-uninitialized-static-ordinal-929319608379097434

Conversation

@jnorthrup

Copy link
Copy Markdown
Owner

🎯 What:
Refactored the labelized_position and unnamed_type_param_name logic to eliminate the use of function-static variables (ordinal and labels).

💡 Why:
The use of static variables in these functions was marked with TODO: static. Moving this state into the cppfront context object avoids global state, which improves code maintainability and ensures that state is isolated to each translation instance.

Verification:

  • Successfully compiled the project using g++ -std=c++20 source/cppfront.cpp -o cppfront.
  • Ran core regression tests and verified that functionality is preserved.
  • Verified that no other parts of the codebase relied on the removed global functions.
  • Cleaned up all generated build artifacts and unrelated changes.

Result:
Improved the health of the codebase by following modern C++ practices of encapsulating state within context objects.


PR created automatically by Jules for task 929319608379097434 started by @jnorthrup

Moved `lowering_labels` and `lowering_ordinal` from function-static
variables in `source/lex.h` to member variables of the `cppfront`
class in `source/to_cpp1.h`.

The refactored logic ensures that translation state is properly
tracked within the compiler context rather than relying on global
static state, improving maintainability and supporting future
parallel or multi-file processing within the same process.

Call sites in `to_cpp1.h` were updated to use the new member
functions. Function-static-dependent free functions were removed
from `lex.h`.
@google-labs-jules

Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

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