Skip to content
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

fix: user-defined literal operator syntax (to make clang20 happy) #3992

Merged

Conversation

flg
Copy link
Contributor

@flg flg commented Dec 17, 2024

  • fix: user-defined literal operator syntax

Summary by CodeRabbit

  • New Features

    • Updated user-defined literal operators for various unit constants to enhance naming consistency.
    • Standardized the operator signature for the hashing function to improve clarity.
  • Bug Fixes

    • No specific bug fixes were addressed in this release.
  • Documentation

    • Changes in function signatures documented for better understanding of updates.

Copy link

coderabbitai bot commented Dec 17, 2024

Walkthrough

In the realm of code refinement, a subtle transformation has occurred within the Acts framework. The modifications focus on standardizing user-defined literal operator signatures across two key header files. Specifically, the changes remove the space between the quotation marks and the unit or hash suffixes, creating a more uniform and consistent method declaration syntax throughout the codebase.

Changes

File Change Summary
Core/include/Acts/Definitions/Units.hpp Removed spaces in unit literal operator signatures across multiple unit types (length, area, volume, time, angles, energy, charge)
Core/include/Acts/Utilities/HashedString.hpp Updated operator""_hash signature to remove space between quotes and suffix

Poem

Syntax dancing light and free,
Underscores slide, no space to see 🧘‍♂️
Literals aligned with grace divine,
Code's rhythm now more refined! ✨
A small change, yet wisdom bright 🌟

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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. (Beta)
  • @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.

@github-actions github-actions bot added this to the next milestone Dec 17, 2024
@github-actions github-actions bot added the Component - Core Affects the Core module label Dec 17, 2024
@flg flg changed the title fix user-defined literal operator syntax (to make clang20 happy) fix: user-defined literal operator syntax (to make clang20 happy) Dec 17, 2024
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: 0

🧹 Nitpick comments (1)
Core/include/Acts/Definitions/Units.hpp (1)

205-210: A suggestion for documentation, I have.

Document in comments, we should, that this syntax change for Clang 20 compatibility was made. Help future maintainers, it will.

 #define ACTS_DEFINE_UNIT_LITERAL(name)                        \
+  // Note: Syntax updated for Clang 20 compatibility          \
   constexpr double operator""_##name(long double x) {         \
     return ::Acts::UnitConstants::name * x;                   \
   }                                                           \
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2bb167c and 7697b27.

📒 Files selected for processing (2)
  • Core/include/Acts/Definitions/Units.hpp (1 hunks)
  • Core/include/Acts/Utilities/HashedString.hpp (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • Core/include/Acts/Utilities/HashedString.hpp
🔇 Additional comments (2)
Core/include/Acts/Definitions/Units.hpp (2)

205-210: Hmmmm, correct this syntax change is!

Align with Clang 20's requirements, this modification does. Remove the space between operator"" and the unit suffix, we must. A wise change, this is, for standards compliance it brings.


205-210: Verify the impact across the codebase, we should.

Though harmless this change appears, wise it would be to verify no breakage in older compiler versions exists.

✅ Verification successful

The pattern in my previous search was too strict with the whitespace. Let me search with more flexible patterns to find both the operator definitions and their usage in the codebase. This will help us determine if there are any compatibility concerns.


Safe, this change appears to be, hmmmm.

Searched extensively through the codebase, I have. The operator literal syntax used consistently across all files, it is. No old-style operator literals that could cause compiler issues, found I have. The pattern operator""_ followed by unit names, well-established throughout the codebase it is.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining old-style operator literals that might have been missed
rg 'operator"\s+_' 

Length of output: 20


Script:

#!/bin/bash
# Search for user-defined literals with a different pattern that might catch variations
rg 'operator""_' 

# Also search for any usage of these unit literals across the codebase
rg '[0-9]+_[a-zA-Z]+\b' 

# Look specifically in test files for unit literal usage
fd -e cpp -e hpp test | xargs rg '[0-9]+_[a-zA-Z]+'

Length of output: 109675

Copy link

github-actions bot commented Dec 18, 2024

📊: Physics performance monitoring for cb82fd5

Full contents

physmon summary

andiwand
andiwand previously approved these changes Dec 18, 2024
Copy link
Contributor

@andiwand andiwand left a comment

Choose a reason for hiding this comment

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

looks fine to me

@paulgessinger
Copy link
Member

@flg I invited you to the CI perms team. Can you accept the invite and then push an empty commit to retrigger the CI?

@flg
Copy link
Contributor Author

flg commented Dec 18, 2024

Thanks both. Invitation accepted. I pushed a commit that fixes formatting issue reported by lint job.

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: 0

🧹 Nitpick comments (1)
Core/include/Acts/Definitions/Units.hpp (1)

204-209: Additional documentation for the macro, suggest I do.

Helpful it would be, to add a brief comment explaining the macro's purpose and the syntax requirements for Clang 20, yes.

Add this documentation above the macro:

+// Macro to define user-defined literals for unit constants
+// Note: No space between quotation marks and suffix as per Clang 20 requirements
 #define ACTS_DEFINE_UNIT_LITERAL(name)                       \
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7697b27 and cb82fd5.

📒 Files selected for processing (1)
  • Core/include/Acts/Definitions/Units.hpp (1 hunks)
🔇 Additional comments (1)
Core/include/Acts/Definitions/Units.hpp (1)

204-209: Approve the syntax change for user-defined literals, I do!

Wise changes these are, hmm. Align with Clang 20's requirements, they do. Remove spaces between quotation marks and unit suffixes, we must. Maintain functionality while improving compatibility, this change does.

Verify the usage of these literals throughout the codebase, we shall:

✅ Verification successful

Verified the unit literals changes are, hmmmm!

Extensive usage throughout the codebase, I see. No old-style literals with spaces remain, and the new syntax widely adopted it is. The Force is strong with these changes:

  • The macro ACTS_DEFINE_UNIT_LITERAL properly defines all units, from femtometers to kilometers it does
  • Many test files and core components use these literals they do, showing their integration complete it is
  • No conflicts or issues with the new syntax found were

Trust in the changes we must, for working correctly they are. Hmmmm, yes!

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining old-style literal usage with spaces
rg -l 'operator""\s+_[a-zA-Z]+'

# Search for current usage of the literals to ensure they work as expected
rg 'using namespace Acts::UnitLiterals;[\s\S]*?[0-9]+_(fm|pm|nm|um|mm|cm|m|km|mm2|cm2|m2|mm3|cm3|m3|fs|ps|ns|us|ms|s|min|h|mrad|rad|degree|eV|keV|MeV|GeV|TeV|J|u|g|kg|e|T|Gauss|kGauss|mol)\b' -A 5

Length of output: 232


Script:

#!/bin/bash
# Search for any files that use the unit literals
rg -l '[0-9]+_(mm|cm|m|GeV|MeV|TeV|rad|degree)' --type cpp

# Check the actual implementation of unit literals in the codebase
rg 'ACTS_DEFINE_UNIT_LITERAL' -A 5 --type cpp

# Look for any test files that might be using these literals
fd -e cpp -e hpp test --exec rg -l '[0-9]+_(mm|cm|m|GeV|MeV|TeV|rad|degree)' {}

Length of output: 17239

@kodiakhq kodiakhq bot merged commit 9269562 into acts-project:main Dec 18, 2024
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component - Core Affects the Core module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants