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

Linter Warning in src/main/cpp/blaze.cc for option_processor, passed by reference object #22469

Closed
Sittiphat opened this issue May 21, 2024 · 2 comments
Labels
team-Performance Issues for Performance teams type: bug untriaged

Comments

@Sittiphat
Copy link

Description of the bug:

Discovered a Google C++ Linter Warning in src/main/cpp/blaze.cc at line 1092 (see image below)

The official Google C++ guideline say that the options are to either make the reference parameter const if the parameter is not meant to be modified, or use a pointer instead of a non-const reference if the parameter is intended to be modified. Since "option_processor" is modified in the function definition, the change I believe should be opted to pass by pointer.

OptionProcessor_pass_by_ref

Which category does this issue belong to?

C++ Rules

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

No response

Which operating system are you running Bazel on?

No response

What is the output of bazel info release?

No response

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse HEAD ?

No response

Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.

No response

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

Is this a non-const reference? If so, make const or use a pointer: OptionProcessor &option_processor cpplint(warning:runtime/references)
&option_processor
OptionProcessor_pass_by_ref

@Sittiphat
Copy link
Author

My potential fix:
#22470

@tjgq
Copy link
Contributor

tjgq commented May 21, 2024

The Google C++ style guide changed a few years ago, and use of pointers for input/output parameters is no longer required; non-const references are fine if the parameter is never null. See https://google.github.io/styleguide/cppguide.html#Inputs_and_Outputs.

@comius comius added team-Performance Issues for Performance teams and removed team-Rules-CPP Issues for C++ rules labels May 23, 2024
@wilwell wilwell closed this as completed May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-Performance Issues for Performance teams type: bug untriaged
Projects
None yet
Development

No branches or pull requests

7 participants