From ae2954f598cb9bb7ac6e75dd023d6ec60c1d76e9 Mon Sep 17 00:00:00 2001 From: Christian Blichmann Date: Wed, 20 Nov 2019 04:39:44 -0800 Subject: [PATCH] Build in C++17 mode. Practically all current compilers fully support C++17 by now, with the exception of `filesystem` (which we won't use). PiperOrigin-RevId: 281494879 Change-Id: Ia0ef650ede4e5907e4a6421b8ad11743c8bae88f --- CMakeLists.txt | 2 +- sandboxed_api/var_abstract.cc | 6 ++---- sandboxed_api/var_abstract.h | 12 ++++++------ sandboxed_api/var_array.h | 6 ++---- sandboxed_api/var_int.cc | 6 ++---- sandboxed_api/var_int.h | 6 ++---- sandboxed_api/var_lenval.cc | 6 ++---- sandboxed_api/var_lenval.h | 6 ++---- sandboxed_api/var_pointable.cc | 6 ++---- sandboxed_api/var_pointable.h | 6 ++---- sandboxed_api/var_proto.h | 6 ++---- sandboxed_api/var_ptr.h | 6 ++---- sandboxed_api/var_reg.h | 6 ++---- sandboxed_api/var_struct.h | 6 ++---- sandboxed_api/var_type.h | 6 ++---- sandboxed_api/var_void.h | 6 ++---- 16 files changed, 35 insertions(+), 63 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cdb480c..80e988b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,7 @@ cmake_minimum_required(VERSION 3.10) project(SandboxedAPI C CXX ASM) # SAPI-wide setting for the language level -set(SAPI_CXX_STANDARD 11) +set(SAPI_CXX_STANDARD 17) set(SAPI_BINARY_DIR "${PROJECT_BINARY_DIR}" CACHE INTERNAL "" FORCE) set(SAPI_SOURCE_DIR "${PROJECT_SOURCE_DIR}" CACHE INTERNAL "" FORCE) diff --git a/sandboxed_api/var_abstract.cc b/sandboxed_api/var_abstract.cc index 2bfc9ca..51f7bef 100644 --- a/sandboxed_api/var_abstract.cc +++ b/sandboxed_api/var_abstract.cc @@ -25,8 +25,7 @@ #include "sandboxed_api/util/canonical_errors.h" #include "sandboxed_api/util/status_macros.h" -namespace sapi { -namespace v { +namespace sapi::v { Var::~Var() { if (free_rpc_channel_ && GetRemote()) { @@ -130,5 +129,4 @@ sapi::Status Var::TransferFromSandboxee(RPCChannel* rpc_channel, pid_t pid) { return sapi::OkStatus(); } -} // namespace v -} // namespace sapi +} // namespace sapi::v diff --git a/sandboxed_api/var_abstract.h b/sandboxed_api/var_abstract.h index a9371c2..17c402a 100644 --- a/sandboxed_api/var_abstract.h +++ b/sandboxed_api/var_abstract.h @@ -25,13 +25,14 @@ namespace sandbox2 { class Comms; -} +} // namespace sandbox2 namespace sapi { class Sandbox; class RPCChannel; +} // namespace sapi -namespace v { +namespace sapi::v { class Ptr; @@ -71,8 +72,8 @@ class Var { void SetLocal(void* local) { local_ = local; } // Setter/Getter for the address of a Comms object which can be used to - // remotely free allocated memory backing up this variable, upon this object's - // end of life-time + // remotely free allocated memory backing up this variable, upon this + // object's end of life-time void SetFreeRPCChannel(RPCChannel* rpc_channel) { free_rpc_channel_ = rpc_channel; } @@ -108,7 +109,6 @@ class Var { friend class ::sapi::Sandbox; }; -} // namespace v -} // namespace sapi +} // namespace sapi::v #endif // SANDBOXED_API_VAR_ABSTRACT_H_ diff --git a/sandboxed_api/var_array.h b/sandboxed_api/var_array.h index 363a5de..2aa299a 100644 --- a/sandboxed_api/var_array.h +++ b/sandboxed_api/var_array.h @@ -27,8 +27,7 @@ #include "sandboxed_api/util/canonical_errors.h" #include "sandboxed_api/util/status_macros.h" -namespace sapi { -namespace v { +namespace sapi::v { // Class representing an array. template @@ -168,7 +167,6 @@ class ConstCStr : public Array { } }; -} // namespace v -} // namespace sapi +} // namespace sapi::v #endif // SANDBOXED_API_VAR_ARRAY_H_ diff --git a/sandboxed_api/var_int.cc b/sandboxed_api/var_int.cc index db739b9..5d53e55 100644 --- a/sandboxed_api/var_int.cc +++ b/sandboxed_api/var_int.cc @@ -17,8 +17,7 @@ #include "sandboxed_api/util/canonical_errors.h" #include "sandboxed_api/util/status_macros.h" -namespace sapi { -namespace v { +namespace sapi::v { Fd::~Fd() { if (GetFreeRPCChannel() && GetRemoteFd() >= 0 && own_remote_) { @@ -92,5 +91,4 @@ sapi::Status Fd::TransferFromSandboxee(RPCChannel* rpc_channel, return sapi::OkStatus(); } -} // namespace v -} // namespace sapi +} // namespace sapi::v diff --git a/sandboxed_api/var_int.h b/sandboxed_api/var_int.h index 2197bee..2626747 100644 --- a/sandboxed_api/var_int.h +++ b/sandboxed_api/var_int.h @@ -22,8 +22,7 @@ #include "sandboxed_api/var_ptr.h" #include "sandboxed_api/var_reg.h" -namespace sapi { -namespace v { +namespace sapi::v { // Intermediate class for register sized variables // so we don't have to implement ptr() everywhere. @@ -101,7 +100,6 @@ class Fd : public Int { bool own_remote_; }; -} // namespace v -} // namespace sapi +} // namespace sapi::v #endif // SANDBOXED_API_VAR_INT_H_ diff --git a/sandboxed_api/var_lenval.cc b/sandboxed_api/var_lenval.cc index 7aa6ec5..c5cb803 100644 --- a/sandboxed_api/var_lenval.cc +++ b/sandboxed_api/var_lenval.cc @@ -22,8 +22,7 @@ #include "sandboxed_api/sandbox2/comms.h" #include "sandboxed_api/rpcchannel.h" -namespace sapi { -namespace v { +namespace sapi::v { sapi::Status LenVal::Allocate(RPCChannel* rpc_channel, bool automatic_free) { SAPI_RETURN_IF_ERROR(struct_.Allocate(rpc_channel, automatic_free)); @@ -69,5 +68,4 @@ sapi::Status LenVal::ResizeData(RPCChannel* rpc_channel, size_t size) { return sapi::OkStatus(); } -} // namespace v -} // namespace sapi +} // namespace sapi::v diff --git a/sandboxed_api/var_lenval.h b/sandboxed_api/var_lenval.h index 3b7d038..73966f1 100644 --- a/sandboxed_api/var_lenval.h +++ b/sandboxed_api/var_lenval.h @@ -27,8 +27,7 @@ #include "sandboxed_api/var_ptr.h" #include "sandboxed_api/var_struct.h" -namespace sapi { -namespace v { +namespace sapi::v { template class Proto; @@ -79,7 +78,6 @@ class LenVal : public Var, public Pointable { friend class Proto; }; -} // namespace v -} // namespace sapi +} // namespace sapi::v #endif // SANDBOXED_API_VAR_LENVAL_H_ diff --git a/sandboxed_api/var_pointable.cc b/sandboxed_api/var_pointable.cc index f5a8b96..6838529 100644 --- a/sandboxed_api/var_pointable.cc +++ b/sandboxed_api/var_pointable.cc @@ -15,10 +15,8 @@ #include "sandboxed_api/var_pointable.h" #include "sandboxed_api/var_ptr.h" -namespace sapi { -namespace v { +namespace sapi::v { void PtrDeleter::operator()(Ptr *p) { delete p; } -} // namespace v -} // namespace sapi +} // namespace sapi::v diff --git a/sandboxed_api/var_pointable.h b/sandboxed_api/var_pointable.h index f8820b5..fa5b239 100644 --- a/sandboxed_api/var_pointable.h +++ b/sandboxed_api/var_pointable.h @@ -19,8 +19,7 @@ #include "sandboxed_api/var_reg.h" -namespace sapi { -namespace v { +namespace sapi::v { class Ptr; @@ -93,7 +92,6 @@ class Pointable { std::unique_ptr ptr_after_; }; -} // namespace v -} // namespace sapi +} // namespace sapi::v #endif // SANDBOXED_API_VAR_POINTABLE_H_ diff --git a/sandboxed_api/var_proto.h b/sandboxed_api/var_proto.h index 11e32f9..73e96f7 100644 --- a/sandboxed_api/var_proto.h +++ b/sandboxed_api/var_proto.h @@ -29,8 +29,7 @@ #include "sandboxed_api/var_ptr.h" #include "sandboxed_api/util/status_macros.h" -namespace sapi { -namespace v { +namespace sapi::v { template class Proto : public Pointable, public Var { @@ -110,7 +109,6 @@ class Proto : public Pointable, public Var { LenVal wrapped_var_; }; -} // namespace v -} // namespace sapi +} // namespace sapi::v #endif // SANDBOXED_API_VAR_PROTO_H_ diff --git a/sandboxed_api/var_ptr.h b/sandboxed_api/var_ptr.h index 644c959..f84737b 100644 --- a/sandboxed_api/var_ptr.h +++ b/sandboxed_api/var_ptr.h @@ -22,8 +22,7 @@ #include "sandboxed_api/var_pointable.h" #include "sandboxed_api/var_reg.h" -namespace sapi { -namespace v { +namespace sapi::v { // Class representing a pointer. Takes both Var* and regular pointers in the // initializers. @@ -100,7 +99,6 @@ class RemotePtr : public Ptr { Reg pointed_obj_; }; -} // namespace v -} // namespace sapi +} // namespace sapi::v #endif // SANDBOXED_API_VAR_PTR_H_ diff --git a/sandboxed_api/var_reg.h b/sandboxed_api/var_reg.h index bb33375..56c8564 100644 --- a/sandboxed_api/var_reg.h +++ b/sandboxed_api/var_reg.h @@ -21,8 +21,7 @@ #include #include "sandboxed_api/var_abstract.h" -namespace sapi { -namespace v { +namespace sapi::v { // The super-class for Reg. Specified as a class, so it can be used as a // type specifier in methods. @@ -177,7 +176,6 @@ class Reg : public Callable { } }; -} // namespace v -} // namespace sapi +} // namespace sapi::v #endif // SANDBOXED_API_VAR_REG_H_ diff --git a/sandboxed_api/var_struct.h b/sandboxed_api/var_struct.h index 0476b15..6883509 100644 --- a/sandboxed_api/var_struct.h +++ b/sandboxed_api/var_struct.h @@ -22,8 +22,7 @@ #include "sandboxed_api/var_pointable.h" #include "sandboxed_api/var_ptr.h" -namespace sapi { -namespace v { +namespace sapi::v { // Class representing a structure. template @@ -55,7 +54,6 @@ class Struct : public Var, public Pointable { friend class LenVal; }; -} // namespace v -} // namespace sapi +} // namespace sapi::v #endif // SANDBOXED_API_VAR_STRUCT_H_ diff --git a/sandboxed_api/var_type.h b/sandboxed_api/var_type.h index e1f254f..a0dbae2 100644 --- a/sandboxed_api/var_type.h +++ b/sandboxed_api/var_type.h @@ -17,8 +17,7 @@ #include -namespace sapi { -namespace v { +namespace sapi::v { enum class Type { kVoid, // Void @@ -36,7 +35,6 @@ inline std::ostream& operator<<(std::ostream& os, const Type& type) { return os << static_cast(type); } -} // namespace v -} // namespace sapi +} // namespace sapi::v #endif // SANDBOXED_API_TYPE_H_ diff --git a/sandboxed_api/var_void.h b/sandboxed_api/var_void.h index 2a3779c..747d1b5 100644 --- a/sandboxed_api/var_void.h +++ b/sandboxed_api/var_void.h @@ -20,8 +20,7 @@ #include "sandboxed_api/var_ptr.h" #include "sandboxed_api/var_reg.h" -namespace sapi { -namespace v { +namespace sapi::v { // Good, old void. class Void : public Callable, public Pointable { @@ -44,7 +43,6 @@ class Void : public Callable, public Pointable { } }; -} // namespace v -} // namespace sapi +} // namespace sapi::v #endif // SANDBOXED_API_VAR_VOID_H_