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

[clang-tidy] enable google-build-using-namespace #359

Merged
merged 11 commits into from
Dec 2, 2019
Merged

Conversation

msbaines
Copy link
Contributor

Motivation and Context

Enable one more clang-tidy check.

How Has This Been Tested

Build.

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have completed my CLA (see CONTRIBUTING)
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Nov 20, 2019
using esp::sensor::Sensor;
using esp::sensor::SensorSpec;
using esp::sensor::SensorSuite;
using esp::sensor::SensorType;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need this, considering we scatter the bindings across multiple modules again on the Python side? To make it easier on both sides, I would say best would be to have gfx, physics, scene, ... submodules generated in the bindings (without using using, so it's clear through which submodule should given API be exposed) and then making use of those on the Python side instead of have things manually cherry-picked via __all__.

Of course there's a question whether this should be done as a part of this PR or separately, but based on previous experience the tech debt TODOs tend to stay in the code forever and so I'd say it should be in this PR. After all, the purpose of this PR is to fix the root cause of the Clang Tidy warnings, not merely silencing them, right? :)

@@ -43,6 +43,7 @@ struct DepthUnprojectionTest : Mn::GL::OpenGLTester {
void benchmarkGpuUnprojectExisting();
};

// NOLINTNEXTLINE(google-build-using-namespace)
using namespace Mn::Math::Literals;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there anything I can do on the engine side to not need to have this annotation in every source file that uses the literals? How does Clang Tidy behave with using namespace std::chrono::literals? Do you need to do the same or is there something that whitelists that namespace?

@erikwijmans
Copy link
Contributor

You likely need to add

#include <pybind11/eigen.h>
#include <pybind11/stl.h>
#include <pybind11/functional.h>

everywhere

@msbaines
Copy link
Contributor Author

You likely need to add

#include <pybind11/eigen.h>
#include <pybind11/stl.h>
#include <pybind11/functional.h>

everywhere

Gotcha. Thanks!

@msbaines
Copy link
Contributor Author

All feedback addressed and tests now passing.

Copy link
Collaborator

@mosra mosra left a comment

Choose a reason for hiding this comment

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

Thank you!

Btw, did you notice any build speed improvements when the bindings got separated like this?

@@ -25,6 +25,9 @@
namespace Cr = Corrade;
namespace Mn = Magnum;

using Mn::Math::Literals::operator""_degf;
using Mn::Math::Literals::operator""_rgbf;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I still don't agree with Tidy about this one, but I guess we can't do any better.

Found https://reviews.llvm.org/D33010 that makes the check not complain for standard literals, but such hardcoded unextendable whitelisting makes me kinda angry :/

@erikwijmans
Copy link
Contributor

I think LTO is the most time consuming part of the bindings. Building the .o is peanuts compared to linking :)

@msbaines msbaines merged commit 175ea23 into master Dec 2, 2019
@msbaines msbaines deleted the using-namespace branch December 2, 2019 19:36
eundersander pushed a commit to eundersander/habitat-sim that referenced this pull request Aug 6, 2020
Ram81 pushed a commit to Ram81/habitat-web-sim that referenced this pull request Dec 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Do not delete this pull request or issue due to inactivity.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants