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
This commit is contained in:
Christian Blichmann 2019-11-20 04:39:44 -08:00 committed by Copybara-Service
parent 8a7d0d1cb3
commit ae2954f598
16 changed files with 35 additions and 63 deletions

View File

@ -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)

View File

@ -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

View File

@ -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_

View File

@ -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 <class T>
@ -168,7 +167,6 @@ class ConstCStr : public Array<const char> {
}
};
} // namespace v
} // namespace sapi
} // namespace sapi::v
#endif // SANDBOXED_API_VAR_ARRAY_H_

View File

@ -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

View File

@ -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_

View File

@ -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

View File

@ -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 T>
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_

View File

@ -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

View File

@ -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, PtrDeleter> ptr_after_;
};
} // namespace v
} // namespace sapi
} // namespace sapi::v
#endif // SANDBOXED_API_VAR_POINTABLE_H_

View File

@ -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 <typename T>
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_

View File

@ -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<void*> pointed_obj_;
};
} // namespace v
} // namespace sapi
} // namespace sapi::v
#endif // SANDBOXED_API_VAR_PTR_H_

View File

@ -21,8 +21,7 @@
#include <glog/logging.h>
#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_

View File

@ -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 <class T>
@ -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_

View File

@ -17,8 +17,7 @@
#include <ostream>
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<int>(type);
}
} // namespace v
} // namespace sapi
} // namespace sapi::v
#endif // SANDBOXED_API_TYPE_H_

View File

@ -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_