Skip to content

Commit

Permalink
update formatter: clang-format-10, yapf 0.30.0 (#2149)
Browse files Browse the repository at this point in the history
  • Loading branch information
yxlao authored Aug 11, 2020
1 parent 970d9af commit 414a67a
Show file tree
Hide file tree
Showing 240 changed files with 1,293 additions and 1,047 deletions.
3 changes: 1 addition & 2 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ BasedOnStyle: Google
IndentWidth: 4
ColumnLimit: 80
UseTab: Never
Language: Cpp
Standard: Cpp11
Standard: c++14
ContinuationIndentWidth: 8
AccessModifierOffset: -4
BinPackParameters: false
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ matrix:
packages:
- cmake
- clang-7
- clang-format-5.0
- clang-format-10
install:
- ./util/install_deps_ubuntu.sh assume-yes
script:
- mkdir build
- cd build
- cmake ..
- pip install -U yapf==0.28.0 nbformat
- pip install -U yapf==0.30.0 nbformat
- make check-style

# Build headless and docs
Expand Down
100 changes: 100 additions & 0 deletions 3rdparty/clang-format/clang-foramt@10.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# BSD 2-Clause License
#
# Copyright (c) 2009-present, Homebrew contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Ref:
# https://github.com/Homebrew/homebrew-core/blob/7f9aa30778d3e3c391b0060a1ac4af230f351dcc/Formula/clang-format.rb#L1

class ClangFormatAT10 < Formula
desc "Formatting tools for C, C++, Obj-C, Java, JavaScript, TypeScript"
homepage "https://clang.llvm.org/docs/ClangFormat.html"
# The LLVM Project is under the Apache License v2.0 with LLVM Exceptions
license "Apache-2.0"
version "10.0.1"
head "https://github.com/llvm/llvm-project.git"

stable do
url "https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.1/llvm-10.0.1.src.tar.xz"
sha256 "c5d8e30b57cbded7128d78e5e8dad811bff97a8d471896812f57fa99ee82cdf3"

resource "clang" do
url "https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.1/clang-10.0.1.src.tar.xz"
sha256 "f99afc382b88e622c689b6d96cadfa6241ef55dca90e87fc170352e12ddb2b24"
end

resource "libcxx" do
url "https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.1/libcxx-10.0.1.src.tar.xz"
sha256 "def674535f22f83131353b3c382ccebfef4ba6a35c488bdb76f10b68b25be86c"
end
end

bottle do
cellar :any_skip_relocation
sha256 "65667bcca091df96d9f27b56a7726a41c9998ebbcd3b10bc2eb2d43aa871c216" => :catalina
sha256 "9b711f49db65634cb1dca8149804040f337ce3e68e66eeba7270c2aec66b90e0" => :mojave
sha256 "9bbc58f9d5afb228c2aeda8ea03d305d7912860f27941933d0824bee505752bd" => :high_sierra
end

depends_on "cmake" => :build
depends_on "ninja" => :build

uses_from_macos "libxml2"
uses_from_macos "ncurses"
uses_from_macos "zlib"

def install
if build.head?
ln_s buildpath/"libcxx", buildpath/"llvm/projects/libcxx"
ln_s buildpath/"clang", buildpath/"llvm/tools/clang"
else
(buildpath/"projects/libcxx").install resource("libcxx")
(buildpath/"tools/clang").install resource("clang")
end

llvmpath = build.head? ? buildpath/"llvm" : buildpath

mkdir llvmpath/"build" do
args = std_cmake_args
args << "-DLLVM_ENABLE_LIBCXX=ON"
args << ".."
system "cmake", "-G", "Ninja", *args
system "ninja", "clang-format"
end

bin.install llvmpath/"build/bin/clang-format"
bin.install llvmpath/"tools/clang/tools/clang-format/git-clang-format"
(share/"clang").install Dir[llvmpath/"tools/clang/tools/clang-format/clang-format*"]
end

test do
# NB: below C code is messily formatted on purpose.
(testpath/"test.c").write <<~EOS
int main(char *args) { \n \t printf("hello"); }
EOS

assert_equal "int main(char *args) { printf(\"hello\"); }\n",
shell_output("#{bin}/clang-format -style=Google test.c")
end
end
4 changes: 2 additions & 2 deletions cpp/benchmarks/core/Reduction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
// IN THE SOFTWARE.
// ----------------------------------------------------------------------------

#include <benchmark/benchmark.h>

#include "open3d/core/AdvancedIndexing.h"
#include "open3d/core/Dtype.h"
#include "open3d/core/MemoryManager.h"
#include "open3d/core/SizeVector.h"
#include "open3d/core/Tensor.h"
#include "open3d/core/kernel/Kernel.h"

#include <benchmark/benchmark.h>

namespace open3d {
namespace core {

Expand Down
5 changes: 3 additions & 2 deletions cpp/benchmarks/geometry/KDTreeFlann.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@
// ----------------------------------------------------------------------------

#include "open3d/geometry/KDTreeFlann.h"
#include "open3d/geometry/PointCloud.h"
#include "open3d/geometry/TriangleMesh.h"

#include <benchmark/benchmark.h>

#include "open3d/geometry/PointCloud.h"
#include "open3d/geometry/TriangleMesh.h"

namespace open3d {
namespace benchmarks {

Expand Down
4 changes: 2 additions & 2 deletions cpp/benchmarks/geometry/SamplePoints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
// IN THE SOFTWARE.
// ----------------------------------------------------------------------------

#include <benchmark/benchmark.h>

#include "open3d/geometry/TriangleMesh.h"
#include "open3d/io/TriangleMeshIO.h"

#include <benchmark/benchmark.h>

namespace open3d {
namespace benchmarks {

Expand Down
3 changes: 2 additions & 1 deletion cpp/benchmarks/io/PointCloudIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@
// ----------------------------------------------------------------------------

#include "open3d/io/PointCloudIO.h"
#include "open3d/utility/Console.h"

#include <benchmark/benchmark.h>

#include "open3d/utility/Console.h"

namespace open3d {
namespace benchmarks {

Expand Down
1 change: 1 addition & 0 deletions cpp/open3d/camera/PinholeCameraIntrinsic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "open3d/camera/PinholeCameraIntrinsic.h"

#include <json/json.h>

#include <Eigen/Dense>

#include "open3d/utility/Console.h"
Expand Down
1 change: 1 addition & 0 deletions cpp/open3d/core/CUDAState.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

#include <cuda.h>
#include <cuda_runtime_api.h>

#include <memory>
#include <vector>

Expand Down
2 changes: 1 addition & 1 deletion cpp/open3d/core/Dtype.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#pragma once

#include "string"
#include <string>

#include "open3d/core/Dispatch.h"
#include "open3d/utility/Console.h"
Expand Down
4 changes: 2 additions & 2 deletions cpp/open3d/core/Indexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@

#pragma once

#include <sstream>

#include "open3d/core/CUDAUtils.h"
#include "open3d/core/Dtype.h"
#include "open3d/core/ShapeUtil.h"
#include "open3d/core/SizeVector.h"
#include "open3d/core/Tensor.h"
#include "open3d/utility/Console.h"

#include <sstream>

namespace open3d {
namespace core {

Expand Down
4 changes: 2 additions & 2 deletions cpp/open3d/core/MemoryManagerCPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
// IN THE SOFTWARE.
// ----------------------------------------------------------------------------

#include "open3d/core/MemoryManager.h"

#include <cstdlib>

#include "open3d/core/MemoryManager.h"

namespace open3d {
namespace core {

Expand Down
3 changes: 1 addition & 2 deletions cpp/open3d/core/MemoryManagerCUDA.cu
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@
// IN THE SOFTWARE.
// ----------------------------------------------------------------------------

#include "open3d/core/MemoryManager.h"

#include <cuda.h>
#include <cuda_runtime.h>

#include "open3d/core/CUDAState.cuh"
#include "open3d/core/CUDAUtils.h"
#include "open3d/core/MemoryManager.h"

namespace open3d {
namespace core {
Expand Down
1 change: 1 addition & 0 deletions cpp/open3d/core/TensorKey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
// ----------------------------------------------------------------------------

#include "open3d/core/TensorKey.h"

#include "open3d/core/Tensor.h"
#include "open3d/utility/Console.h"

Expand Down
3 changes: 1 addition & 2 deletions cpp/open3d/core/kernel/BinaryEWCPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@
// IN THE SOFTWARE.
// ----------------------------------------------------------------------------

#include "open3d/core/kernel/BinaryEW.h"

#include "open3d/core/Dispatch.h"
#include "open3d/core/Dtype.h"
#include "open3d/core/MemoryManager.h"
#include "open3d/core/SizeVector.h"
#include "open3d/core/Tensor.h"
#include "open3d/core/kernel/BinaryEW.h"
#include "open3d/core/kernel/CPULauncher.h"
#include "open3d/utility/Console.h"

Expand Down
3 changes: 1 addition & 2 deletions cpp/open3d/core/kernel/BinaryEWCUDA.cu
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@
// IN THE SOFTWARE.
// ----------------------------------------------------------------------------

#include "open3d/core/kernel/BinaryEW.h"

#include "open3d/core/CUDAState.cuh"
#include "open3d/core/CUDAUtils.h"
#include "open3d/core/Dispatch.h"
#include "open3d/core/Tensor.h"
#include "open3d/core/kernel/BinaryEW.h"
#include "open3d/core/kernel/CUDALauncher.cuh"

namespace open3d {
Expand Down
3 changes: 1 addition & 2 deletions cpp/open3d/core/kernel/IndexGetSetCPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@
// IN THE SOFTWARE.
// ----------------------------------------------------------------------------

#include "open3d/core/kernel/IndexGetSet.h"

#include "open3d/core/AdvancedIndexing.h"
#include "open3d/core/Dispatch.h"
#include "open3d/core/Tensor.h"
#include "open3d/core/kernel/CPULauncher.h"
#include "open3d/core/kernel/IndexGetSet.h"
#include "open3d/utility/Console.h"

namespace open3d {
Expand Down
3 changes: 1 addition & 2 deletions cpp/open3d/core/kernel/IndexGetSetCUDA.cu
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@
// IN THE SOFTWARE.
// ----------------------------------------------------------------------------

#include "open3d/core/kernel/IndexGetSet.h"

#include "open3d/core/CUDAState.cuh"
#include "open3d/core/CUDAUtils.h"
#include "open3d/core/Dispatch.h"
#include "open3d/core/Tensor.h"
#include "open3d/core/kernel/CUDALauncher.cuh"
#include "open3d/core/kernel/IndexGetSet.h"

namespace open3d {
namespace core {
Expand Down
4 changes: 3 additions & 1 deletion cpp/open3d/core/kernel/Kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@
// IN THE SOFTWARE.
// ----------------------------------------------------------------------------

#include "open3d/core/kernel/Kernel.h"

#include <mkl.h>

#include <cmath>
#include <vector>

#include "open3d/core/kernel/Kernel.h"
#include "open3d/utility/Console.h"

namespace open3d {
Expand Down
3 changes: 1 addition & 2 deletions cpp/open3d/core/kernel/NonZeroCPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@
// IN THE SOFTWARE.
// ----------------------------------------------------------------------------

#include "open3d/core/kernel/NonZero.h"

#include "open3d/core/Indexer.h"
#include "open3d/core/kernel/NonZero.h"
#include "open3d/utility/Console.h"

namespace open3d {
Expand Down
3 changes: 1 addition & 2 deletions cpp/open3d/core/kernel/NonZeroCUDA.cu
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@
// IN THE SOFTWARE.
// ----------------------------------------------------------------------------

#include "open3d/core/kernel/NonZero.h"

#include <thrust/device_vector.h>
#include <thrust/execution_policy.h>
#include <thrust/for_each.h>
#include <thrust/iterator/zip_iterator.h>

#include "open3d/core/Indexer.h"
#include "open3d/core/kernel/NonZero.h"

namespace open3d {
namespace core {
Expand Down
1 change: 1 addition & 0 deletions cpp/open3d/core/kernel/Reduction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
// ----------------------------------------------------------------------------

#include "open3d/core/kernel/Reduction.h"

#include "open3d/core/SizeVector.h"

namespace open3d {
Expand Down
4 changes: 2 additions & 2 deletions cpp/open3d/core/kernel/Reduction.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@

#pragma once

#include <unordered_set>

#include "open3d/core/SizeVector.h"
#include "open3d/core/Tensor.h"
#include "open3d/utility/Console.h"
#include "open3d/utility/Helper.h"

#include <unordered_set>

namespace open3d {
namespace core {
namespace kernel {
Expand Down
Loading

0 comments on commit 414a67a

Please sign in to comment.