Implement clang-format-ignore instead of manually using grep. Regenerate the bridge without formatting it. Bug: 528225104 Change-Id: If8d7e30dfcbecf5328cbb93e379efbc16a6a6964 Reviewed-on: https://gn-review.googlesource.com/c/gn/+/23901 Reviewed-by: Takuto Ikuta <tikuta@google.com> Commit-Queue: Matt Stark <msta@google.com>
diff --git a/.clang-format-ignore b/.clang-format-ignore new file mode 100644 index 0000000..62c8b2c --- /dev/null +++ b/.clang-format-ignore
@@ -0,0 +1,7 @@ +# Exclude third party and vendored code +**/third_party/** +src/gn/starlark/vendor/** + +# Exclude generated FFI bridge files +src/gn/ffi/bridge.cc +src/gn/ffi/bridge.h
diff --git a/src/gn/ffi/bridge.cc b/src/gn/ffi/bridge.cc index 81988fc..1346937 100644 --- a/src/gn/ffi/bridge.cc +++ b/src/gn/ffi/bridge.cc
@@ -1,5 +1,12 @@ // This file is generated by src/gn/ffi/update_bridge.sh. Do not edit manually. // Source: src/gn/ffi/starlark/crates/ffi/src/bridge.rs +#include "gn/ffi/test_with_scope.h" +#include "gn/label.h" +#include "gn/output_file.h" +#include "gn/scope.h" +#include "gn/settings.h" +#include "gn/source_dir.h" +#include "gn/test_with_scope.h" #include <array> #include <cstddef> #include <cstdint> @@ -8,13 +15,6 @@ #include <string> #include <type_traits> #include <utility> -#include "gn/ffi/test_with_scope.h" -#include "gn/label.h" -#include "gn/output_file.h" -#include "gn/scope.h" -#include "gn/settings.h" -#include "gn/source_dir.h" -#include "gn/test_with_scope.h" #if __cplusplus >= 201703L #include <string_view> #endif @@ -23,8 +23,8 @@ #pragma GCC diagnostic ignored "-Wmissing-declarations" #ifdef __clang__ #pragma clang diagnostic ignored "-Wdollar-in-identifier-extension" -#endif // __clang__ -#endif // __GNUC__ +#endif // __clang__ +#endif // __GNUC__ namespace rust { inline namespace cxxbridge1 { @@ -33,55 +33,55 @@ namespace { template <typename T> class impl; -} // namespace +} // namespace class String; #ifndef CXXBRIDGE1_RUST_STR #define CXXBRIDGE1_RUST_STR class Str final { - public: +public: Str() noexcept; - Str(const String&) noexcept; - Str(const std::string&); - Str(const char*); - Str(const char*, std::size_t); + Str(const String &) noexcept; + Str(const std::string &); + Str(const char *); + Str(const char *, std::size_t); #if __cplusplus >= 201703L Str(std::string_view s) : Str(s.data(), s.size()) {} #endif - Str& operator=(const Str&) & noexcept = default; + Str &operator=(const Str &) & noexcept = default; explicit operator std::string() const; #if __cplusplus >= 201703L explicit operator std::string_view() const; #endif - const char* data() const noexcept; + const char *data() const noexcept; std::size_t size() const noexcept; std::size_t length() const noexcept; bool empty() const noexcept; - Str(const Str&) noexcept = default; + Str(const Str &) noexcept = default; ~Str() noexcept = default; - using iterator = const char*; - using const_iterator = const char*; + using iterator = const char *; + using const_iterator = const char *; const_iterator begin() const noexcept; const_iterator end() const noexcept; const_iterator cbegin() const noexcept; const_iterator cend() const noexcept; - bool operator==(const Str&) const noexcept; - bool operator!=(const Str&) const noexcept; - bool operator<(const Str&) const noexcept; - bool operator<=(const Str&) const noexcept; - bool operator>(const Str&) const noexcept; - bool operator>=(const Str&) const noexcept; + bool operator==(const Str &) const noexcept; + bool operator!=(const Str &) const noexcept; + bool operator<(const Str &) const noexcept; + bool operator<=(const Str &) const noexcept; + bool operator>(const Str &) const noexcept; + bool operator>=(const Str &) const noexcept; - void swap(Str&) noexcept; + void swap(Str &) noexcept; - private: +private: class uninit; Str(uninit) noexcept; friend impl<Str>; @@ -90,15 +90,11 @@ }; #if __cplusplus >= 201703L -inline Str cxx_to_rust(std::string_view view) { - return Str(view); -} +inline Str cxx_to_rust(std::string_view view) { return Str(view); } #endif -inline Str cxx_to_rust(const std::string& s) { - return Str(s); -} -#endif // CXXBRIDGE1_RUST_STR +inline Str cxx_to_rust(const std::string &s) { return Str(s); } +#endif // CXXBRIDGE1_RUST_STR #ifndef CXXBRIDGE1_IS_COMPLETE #define CXXBRIDGE1_IS_COMPLETE @@ -108,26 +104,20 @@ struct is_complete : std::false_type {}; template <typename T> struct is_complete<T, decltype(sizeof(T))> : std::true_type {}; -} // namespace -} // namespace detail -#endif // CXXBRIDGE1_IS_COMPLETE +} // namespace +} // namespace detail +#endif // CXXBRIDGE1_IS_COMPLETE namespace { -template <bool> -struct deleter_if { - template <typename T> - void operator()(T*) {} +template <bool> struct deleter_if { + template <typename T> void operator()(T *) {} }; -template <> -struct deleter_if<true> { - template <typename T> - void operator()(T* ptr) { - ptr->~T(); - } +template <> struct deleter_if<true> { + template <typename T> void operator()(T *ptr) { ptr->~T(); } }; -} // namespace -} // namespace cxxbridge1 -} // namespace rust +} // namespace +} // namespace cxxbridge1 +} // namespace rust using OutputFile = ::OutputFile; using SourceDir = ::SourceDir; @@ -137,86 +127,62 @@ using TestWithScope = ::TestWithScope; extern "C" { -void cxxbridge1$196$OutputFile$value(::OutputFile const& self, - ::rust::Str* return$) noexcept { +void cxxbridge1$196$OutputFile$value(::OutputFile const &self, ::rust::Str *return$) noexcept { std::string_view (::OutputFile::*value$)() const = &::OutputFile::value; - new (return$)::rust::Str(::rust::cxx_to_rust((self.*value$)())); + new (return$) ::rust::Str(::rust::cxx_to_rust((self.*value$)())); } -void cxxbridge1$196$SourceDir$SourceWithNoTrailingSlash( - ::SourceDir const& self, - ::rust::Str* return$) noexcept { - std::string_view (::SourceDir::*SourceWithNoTrailingSlash$)() const = - &::SourceDir::SourceWithNoTrailingSlash; - new (return$)::rust::Str( - ::rust::cxx_to_rust((self.*SourceWithNoTrailingSlash$)())); +void cxxbridge1$196$SourceDir$SourceWithNoTrailingSlash(::SourceDir const &self, ::rust::Str *return$) noexcept { + std::string_view (::SourceDir::*SourceWithNoTrailingSlash$)() const = &::SourceDir::SourceWithNoTrailingSlash; + new (return$) ::rust::Str(::rust::cxx_to_rust((self.*SourceWithNoTrailingSlash$)())); } -void cxxbridge1$196$Label$dir(::Label const& self, - ::SourceDir const** return$) noexcept { - ::SourceDir const& (::Label::*dir$)() const = &::Label::dir; - new (return$)::SourceDir const*(&(self.*dir$)()); +void cxxbridge1$196$Label$dir(::Label const &self, ::SourceDir const **return$) noexcept { + ::SourceDir const &(::Label::*dir$)() const = &::Label::dir; + new (return$) ::SourceDir const *(&(self.*dir$)()); } -void cxxbridge1$196$Label$name(::Label const& self, - ::rust::Str* return$) noexcept { +void cxxbridge1$196$Label$name(::Label const &self, ::rust::Str *return$) noexcept { const std::string& (::Label::*name$)() const = &::Label::name; - new (return$)::rust::Str(::rust::cxx_to_rust((self.*name$)())); + new (return$) ::rust::Str(::rust::cxx_to_rust((self.*name$)())); } -void cxxbridge1$196$Settings$toolchain_label(::Settings const& self, - ::Label const** return$) noexcept { - ::Label const& (::Settings::*toolchain_label$)() const = - &::Settings::toolchain_label; - new (return$)::Label const*(&(self.*toolchain_label$)()); +void cxxbridge1$196$Settings$toolchain_label(::Settings const &self, ::Label const **return$) noexcept { + ::Label const &(::Settings::*toolchain_label$)() const = &::Settings::toolchain_label; + new (return$) ::Label const *(&(self.*toolchain_label$)()); } -::Settings const* cxxbridge1$196$Scope$settings_cxx( - ::Scope const& self) noexcept { - ::Settings const* (::Scope::*settings_cxx$)() const = &::Scope::settings; +::Settings const *cxxbridge1$196$Scope$settings_cxx(::Scope const &self) noexcept { + ::Settings const *(::Scope::*settings_cxx$)() const = &::Scope::settings; return (self.*settings_cxx$)(); } -::TestWithScope* cxxbridge1$196$NewTestWithScope() noexcept { - ::std::unique_ptr<::TestWithScope> (*NewTestWithScope$)() = - ::NewTestWithScope; +::TestWithScope *cxxbridge1$196$NewTestWithScope() noexcept { + ::std::unique_ptr<::TestWithScope> (*NewTestWithScope$)() = ::NewTestWithScope; return NewTestWithScope$().release(); } -::Scope* cxxbridge1$196$TestWithScope$scope_cxx( - ::TestWithScope& self) noexcept { - ::Scope* (::TestWithScope::*scope_cxx$)() = &::TestWithScope::scope; +::Scope *cxxbridge1$196$TestWithScope$scope_cxx(::TestWithScope &self) noexcept { + ::Scope *(::TestWithScope::*scope_cxx$)() = &::TestWithScope::scope; return (self.*scope_cxx$)(); } -static_assert(::rust::detail::is_complete< - ::std::remove_extent<::TestWithScope>::type>::value, - "definition of `::TestWithScope` is required"); -static_assert(sizeof(::std::unique_ptr<::TestWithScope>) == sizeof(void*), ""); -static_assert(alignof(::std::unique_ptr<::TestWithScope>) == alignof(void*), - ""); -void cxxbridge1$unique_ptr$TestWithScope$null( - ::std::unique_ptr<::TestWithScope>* ptr) noexcept { - ::new (ptr)::std::unique_ptr<::TestWithScope>(); +static_assert(::rust::detail::is_complete<::std::remove_extent<::TestWithScope>::type>::value, "definition of `::TestWithScope` is required"); +static_assert(sizeof(::std::unique_ptr<::TestWithScope>) == sizeof(void *), ""); +static_assert(alignof(::std::unique_ptr<::TestWithScope>) == alignof(void *), ""); +void cxxbridge1$unique_ptr$TestWithScope$null(::std::unique_ptr<::TestWithScope> *ptr) noexcept { + ::new (ptr) ::std::unique_ptr<::TestWithScope>(); } -void cxxbridge1$unique_ptr$TestWithScope$raw( - ::std::unique_ptr<::TestWithScope>* ptr, - ::std::unique_ptr<::TestWithScope>::pointer raw) noexcept { - ::new (ptr)::std::unique_ptr<::TestWithScope>(raw); +void cxxbridge1$unique_ptr$TestWithScope$raw(::std::unique_ptr<::TestWithScope> *ptr, ::std::unique_ptr<::TestWithScope>::pointer raw) noexcept { + ::new (ptr) ::std::unique_ptr<::TestWithScope>(raw); } -::std::unique_ptr<::TestWithScope>::element_type const* -cxxbridge1$unique_ptr$TestWithScope$get( - ::std::unique_ptr<::TestWithScope> const& ptr) noexcept { +::std::unique_ptr<::TestWithScope>::element_type const *cxxbridge1$unique_ptr$TestWithScope$get(::std::unique_ptr<::TestWithScope> const &ptr) noexcept { return ptr.get(); } -::std::unique_ptr<::TestWithScope>::pointer -cxxbridge1$unique_ptr$TestWithScope$release( - ::std::unique_ptr<::TestWithScope>& ptr) noexcept { +::std::unique_ptr<::TestWithScope>::pointer cxxbridge1$unique_ptr$TestWithScope$release(::std::unique_ptr<::TestWithScope> &ptr) noexcept { return ptr.release(); } -void cxxbridge1$unique_ptr$TestWithScope$drop( - ::std::unique_ptr<::TestWithScope>* ptr) noexcept { - ::rust::deleter_if<::rust::detail::is_complete<::TestWithScope>::value>{}( - ptr); +void cxxbridge1$unique_ptr$TestWithScope$drop(::std::unique_ptr<::TestWithScope> *ptr) noexcept { + ::rust::deleter_if<::rust::detail::is_complete<::TestWithScope>::value>{}(ptr); } -} // extern "C" +} // extern "C"
diff --git a/src/gn/ffi/bridge.h b/src/gn/ffi/bridge.h index d56352b..39ec711 100644 --- a/src/gn/ffi/bridge.h +++ b/src/gn/ffi/bridge.h
@@ -1,10 +1,6 @@ // This file is generated by src/gn/ffi/update_bridge.sh. Do not edit manually. // Source: src/gn/ffi/starlark/crates/ffi/src/bridge.rs #pragma once -#include <array> -#include <cstdint> -#include <memory> -#include <string> #include "gn/ffi/test_with_scope.h" #include "gn/label.h" #include "gn/output_file.h" @@ -12,6 +8,10 @@ #include "gn/settings.h" #include "gn/source_dir.h" #include "gn/test_with_scope.h" +#include <array> +#include <cstdint> +#include <memory> +#include <string> #if __cplusplus >= 201703L #include <string_view> #endif @@ -23,55 +23,55 @@ namespace { template <typename T> class impl; -} // namespace +} // namespace class String; #ifndef CXXBRIDGE1_RUST_STR #define CXXBRIDGE1_RUST_STR class Str final { - public: +public: Str() noexcept; - Str(const String&) noexcept; - Str(const std::string&); - Str(const char*); - Str(const char*, std::size_t); + Str(const String &) noexcept; + Str(const std::string &); + Str(const char *); + Str(const char *, std::size_t); #if __cplusplus >= 201703L Str(std::string_view s) : Str(s.data(), s.size()) {} #endif - Str& operator=(const Str&) & noexcept = default; + Str &operator=(const Str &) & noexcept = default; explicit operator std::string() const; #if __cplusplus >= 201703L explicit operator std::string_view() const; #endif - const char* data() const noexcept; + const char *data() const noexcept; std::size_t size() const noexcept; std::size_t length() const noexcept; bool empty() const noexcept; - Str(const Str&) noexcept = default; + Str(const Str &) noexcept = default; ~Str() noexcept = default; - using iterator = const char*; - using const_iterator = const char*; + using iterator = const char *; + using const_iterator = const char *; const_iterator begin() const noexcept; const_iterator end() const noexcept; const_iterator cbegin() const noexcept; const_iterator cend() const noexcept; - bool operator==(const Str&) const noexcept; - bool operator!=(const Str&) const noexcept; - bool operator<(const Str&) const noexcept; - bool operator<=(const Str&) const noexcept; - bool operator>(const Str&) const noexcept; - bool operator>=(const Str&) const noexcept; + bool operator==(const Str &) const noexcept; + bool operator!=(const Str &) const noexcept; + bool operator<(const Str &) const noexcept; + bool operator<=(const Str &) const noexcept; + bool operator>(const Str &) const noexcept; + bool operator>=(const Str &) const noexcept; - void swap(Str&) noexcept; + void swap(Str &) noexcept; - private: +private: class uninit; Str(uninit) noexcept; friend impl<Str>; @@ -80,17 +80,13 @@ }; #if __cplusplus >= 201703L -inline Str cxx_to_rust(std::string_view view) { - return Str(view); -} +inline Str cxx_to_rust(std::string_view view) { return Str(view); } #endif -inline Str cxx_to_rust(const std::string& s) { - return Str(s); -} -#endif // CXXBRIDGE1_RUST_STR -} // namespace cxxbridge1 -} // namespace rust +inline Str cxx_to_rust(const std::string &s) { return Str(s); } +#endif // CXXBRIDGE1_RUST_STR +} // namespace cxxbridge1 +} // namespace rust using OutputFile = ::OutputFile; using SourceDir = ::SourceDir;
diff --git a/tools/run_formatter.sh b/tools/run_formatter.sh index 82bdd5b..23466b1 100755 --- a/tools/run_formatter.sh +++ b/tools/run_formatter.sh
@@ -18,8 +18,7 @@ CLANG_FORMAT="./clang/bin/clang-format" fi -git ls-files | egrep '\.(h|cc)$' | grep -Ev 'third_party|vendor' |\ - xargs "$CLANG_FORMAT" $opts +git ls-files | egrep '\.(h|cc)$' | xargs "$CLANG_FORMAT" $opts if command -v cargo >/dev/null 2>&1; then cargo_cmd="cargo"