Skip to content

Conversation

@dj-jayu
Copy link
Member

@dj-jayu dj-jayu commented Nov 12, 2025

These changes improve code safety and follow C++ Core Guidelines without altering functionality.

Type Safety Improvements:

  • Added explicit keyword to single-argument constructors in gs_pattern.h to prevent implicit conversions
  • Added std::move semantics to error class constructors (GSError, GSFileError, GSDataError, GSAllocError) for efficient string handling

Modern C++ Keywords:

  • Added override keyword to virtual destructors and methods for compile-time checking
  • Added default keyword to default constructors and destructors where applicable

Const-Correctness:

  • Marked Metrics getter functions as const (get_pattern_size(), type_as_string())
  • Marked name getter functions as const (getName(), getShortName(), getShortNameLower())

Initialization:

  • Added default initialization (-1) to previously uninitialized member variables in InstrWindow class (iaddr, maddr_prev, maddr)

… 'iaddr', 'maddr_prev', and 'maddr' of the 'InstrWindow' class
These functions are read-only and return by value, making them
safe to call on const objects:
- get_pattern_size()
- type_as_string()
- getName(), getShortName(), getShortNameLower()
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request improves type safety and code quality by applying modern C++ best practices and const-correctness improvements without changing functionality.

  • Adds explicit keyword to single-argument constructors to prevent implicit conversions
  • Implements move semantics for exception class string parameters
  • Adds const qualifiers to getter methods that don't modify object state
  • Initializes previously uninitialized InstrWindow member variables to sentinel values

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

@jyoung3131 jyoung3131 left a comment

Choose a reason for hiding this comment

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

We are reviewing but are not quite sure if we need the override=default line on the destructor. Common C++ guidance seems to indicate this might result in a nop if the code compiles without error (so the line would not be needed at all).

Will review and share some more resources here.

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.

3 participants