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

Remove warnings #2486

Merged
merged 4 commits into from
Aug 30, 2024
Merged

Remove warnings #2486

merged 4 commits into from
Aug 30, 2024

Conversation

digit-google
Copy link
Contributor

Remove multiple C++ compiler warnings

A small series of patches to remove annoying warnings that appear with recent compilers, e.g. Clang 16.0

  • status_printer.h: Add override statements to method declarations.
  • explanations.h: Remove unused private member Explanations::enabled_.
  • metrics.cc: Remove unused anonymous GetFrequence() function.
  • build.cc: Add override directives to CommandRunner subclasses.

This adds `override` statements, and removes an un-necessary
destructor declaration from status_printer.h in order to remove
annoying compiler warnings when building Ninja tests with CMake
with recent compilers. For example, clang 16.0 complains with:

```
/path/to/ninja/src/status_printer.h:29:16: warning: 'EdgeAddedToPlan' overrides a member function but is not marked 'override' [
-Winconsistent-missing-override]
  virtual void EdgeAddedToPlan(const Edge* edge);
               ^
```

The root issue is that while libninja is compiled explicitly for C++11,
which disable the warning, the tests themselves are not, since they rely
on GTest which now requires C++14, and thus the standard being used is
determined by the compiler's default configuration.
This field is unused. This patch removes compiler warnings when
building with recent compilers (e.g. Clang 16.0)
It was declared in an anonymous namespace, and nothing
uses it anymore, removes a compiler warning.
Technically, these are not required since Ninja is built with -std=c++11,
but using these directives is good practice to clarify the code and
avoid simple human errors.
@mcprat
Copy link
Contributor

mcprat commented Aug 29, 2024

looks good

I think it's useful to say whether whatever is removed was ever used before. I was asking myself "what happened to the destructors?"

It might be nice to have removal of destructors as a separate commit with relevant info

  • ~StatusPrinter was never used. (589f5b2)
  • same with ~RealCommandRunner (7cacd89)
  • same with ~DryRunCommandRunner (07171dd)

as you know enabled_ was never used... (986d844)

GetFrequency() was used in 72f1912
and is unused since dd8f62c

@jhasse jhasse added this to the 1.13.0 milestone Aug 30, 2024
@jhasse jhasse merged commit 4b7d399 into ninja-build:master Aug 30, 2024
11 checks passed
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