summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Gampe <agampe@google.com>2018-10-01 19:30:57 -0700
committerAndreas Gampe <agampe@google.com>2018-10-01 19:30:57 -0700
commit44b3174732f8fb1fd7efe7a73cb03bbbbf151f18 (patch)
treeee00d1e253e18fe8ef7c21c4786390d1446e8390
parentd6266f3292eab5b043262c6366ed6b8131e152c5 (diff)
downloadandroid_art-44b3174732f8fb1fd7efe7a73cb03bbbbf151f18.tar.gz
android_art-44b3174732f8fb1fd7efe7a73cb03bbbbf151f18.tar.bz2
android_art-44b3174732f8fb1fd7efe7a73cb03bbbbf151f18.zip
ART: Mark move constructors with noexcept
As libc++ is pessimized even under -fno-exception, revert our previous opinion on clang-tidy warnings and add noexcept keywords. Bug: 117098004 Test: WITH_TIDY=1 mmma art Change-Id: I4ab3ad1976f6feb6da98d36e62490e31dbe6a6b2
-rw-r--r--build/Android.bp5
-rw-r--r--libartbase/base/common_art_test.cc4
-rw-r--r--libartbase/base/common_art_test.h4
-rw-r--r--libartbase/base/mem_map.cc2
-rw-r--r--libartbase/base/mem_map.h4
-rw-r--r--libartbase/base/scoped_arena_allocator.cc2
-rw-r--r--libartbase/base/scoped_arena_allocator.h2
-rw-r--r--libartbase/base/unix_file/fd_file.cc4
-rw-r--r--libartbase/base/unix_file/fd_file.h4
-rw-r--r--openjdkjvmti/ti_class.cc2
-rw-r--r--openjdkjvmti/ti_stack.cc2
-rw-r--r--runtime/jni/check_jni.cc2
-rw-r--r--runtime/reference_table.cc2
-rw-r--r--runtime/ti/agent.cc4
-rw-r--r--runtime/ti/agent.h4
-rw-r--r--tools/titrace/titrace.cc4
16 files changed, 25 insertions, 26 deletions
diff --git a/build/Android.bp b/build/Android.bp
index 3eb4aaff79..78fd21a627 100644
--- a/build/Android.bp
+++ b/build/Android.bp
@@ -27,6 +27,7 @@ art_clang_tidy_errors = [
"performance-faster-string-find",
"performance-for-range-copy",
"performance-implicit-conversion-in-loop",
+ "performance-noexcept-move-constructor",
"performance-unnecessary-copy-initialization",
"performance-unnecessary-value-param",
"misc-unused-using-decls",
@@ -42,6 +43,7 @@ art_clang_tidy_errors_str = "bugprone-lambda-function-name"
+ ",performance-faster-string-find"
+ ",performance-for-range-copy"
+ ",performance-implicit-conversion-in-loop"
+ + ",performance-noexcept-move-constructor"
+ ",performance-unnecessary-copy-initialization"
+ ",performance-unnecessary-value-param"
+ ",misc-unused-using-decls"
@@ -55,9 +57,6 @@ art_clang_tidy_disabled = [
// We have lots of C-style variadic functions, and are OK with them. JNI ensures
// that working around this warning would be extra-painful.
"-cert-dcl50-cpp",
- // No exceptions.
- "-misc-noexcept-move-constructor",
- "-performance-noexcept-move-constructor",
// "Modernization" we don't agree with.
"-modernize-use-auto",
"-modernize-return-braced-init-list",
diff --git a/libartbase/base/common_art_test.cc b/libartbase/base/common_art_test.cc
index 6dd2381c7e..b65710bc00 100644
--- a/libartbase/base/common_art_test.cc
+++ b/libartbase/base/common_art_test.cc
@@ -73,11 +73,11 @@ ScratchFile::ScratchFile(File* file) {
file_.reset(file);
}
-ScratchFile::ScratchFile(ScratchFile&& other) {
+ScratchFile::ScratchFile(ScratchFile&& other) noexcept {
*this = std::move(other);
}
-ScratchFile& ScratchFile::operator=(ScratchFile&& other) {
+ScratchFile& ScratchFile::operator=(ScratchFile&& other) noexcept {
if (GetFile() != other.GetFile()) {
std::swap(filename_, other.filename_);
std::swap(file_, other.file_);
diff --git a/libartbase/base/common_art_test.h b/libartbase/base/common_art_test.h
index d645fa11a4..32a2628fe6 100644
--- a/libartbase/base/common_art_test.h
+++ b/libartbase/base/common_art_test.h
@@ -54,9 +54,9 @@ class ScratchFile {
ScratchFile(const ScratchFile& other, const char* suffix);
- ScratchFile(ScratchFile&& other);
+ ScratchFile(ScratchFile&& other) noexcept;
- ScratchFile& operator=(ScratchFile&& other);
+ ScratchFile& operator=(ScratchFile&& other) noexcept;
explicit ScratchFile(File* file);
diff --git a/libartbase/base/mem_map.cc b/libartbase/base/mem_map.cc
index 1bf553d293..d4094153b9 100644
--- a/libartbase/base/mem_map.cc
+++ b/libartbase/base/mem_map.cc
@@ -585,7 +585,7 @@ MemMap MemMap::MapFileAtAddress(uint8_t* expected_ptr,
redzone_size);
}
-MemMap::MemMap(MemMap&& other)
+MemMap::MemMap(MemMap&& other) noexcept
: MemMap() {
swap(other);
}
diff --git a/libartbase/base/mem_map.h b/libartbase/base/mem_map.h
index 20eda324e1..9b23a7d49e 100644
--- a/libartbase/base/mem_map.h
+++ b/libartbase/base/mem_map.h
@@ -68,8 +68,8 @@ class MemMap {
return MemMap();
}
- MemMap(MemMap&& other) REQUIRES(!MemMap::mem_maps_lock_);
- MemMap& operator=(MemMap&& other) REQUIRES(!MemMap::mem_maps_lock_) {
+ MemMap(MemMap&& other) noexcept REQUIRES(!MemMap::mem_maps_lock_);
+ MemMap& operator=(MemMap&& other) noexcept REQUIRES(!MemMap::mem_maps_lock_) {
Reset();
swap(other);
return *this;
diff --git a/libartbase/base/scoped_arena_allocator.cc b/libartbase/base/scoped_arena_allocator.cc
index ab05c6041a..a54f350cab 100644
--- a/libartbase/base/scoped_arena_allocator.cc
+++ b/libartbase/base/scoped_arena_allocator.cc
@@ -106,7 +106,7 @@ void* ArenaStack::AllocWithMemoryTool(size_t bytes, ArenaAllocKind kind) {
return ptr;
}
-ScopedArenaAllocator::ScopedArenaAllocator(ScopedArenaAllocator&& other)
+ScopedArenaAllocator::ScopedArenaAllocator(ScopedArenaAllocator&& other) noexcept
: DebugStackReference(std::move(other)),
DebugStackRefCounter(),
ArenaAllocatorStats(other),
diff --git a/libartbase/base/scoped_arena_allocator.h b/libartbase/base/scoped_arena_allocator.h
index 7eaec5e3c3..52d036105a 100644
--- a/libartbase/base/scoped_arena_allocator.h
+++ b/libartbase/base/scoped_arena_allocator.h
@@ -138,7 +138,7 @@ class ArenaStack : private DebugStackRefCounter, private ArenaAllocatorMemoryToo
class ScopedArenaAllocator
: private DebugStackReference, private DebugStackRefCounter, private ArenaAllocatorStats {
public:
- ScopedArenaAllocator(ScopedArenaAllocator&& other);
+ ScopedArenaAllocator(ScopedArenaAllocator&& other) noexcept;
explicit ScopedArenaAllocator(ArenaStack* arena_stack);
~ScopedArenaAllocator();
diff --git a/libartbase/base/unix_file/fd_file.cc b/libartbase/base/unix_file/fd_file.cc
index d715670194..de60277432 100644
--- a/libartbase/base/unix_file/fd_file.cc
+++ b/libartbase/base/unix_file/fd_file.cc
@@ -91,7 +91,7 @@ void FdFile::Destroy() {
}
}
-FdFile::FdFile(FdFile&& other)
+FdFile::FdFile(FdFile&& other) noexcept
: guard_state_(other.guard_state_),
fd_(other.fd_),
file_path_(std::move(other.file_path_)),
@@ -105,7 +105,7 @@ FdFile::FdFile(FdFile&& other)
other.fd_ = -1;
}
-FdFile& FdFile::operator=(FdFile&& other) {
+FdFile& FdFile::operator=(FdFile&& other) noexcept {
if (this == &other) {
return *this;
}
diff --git a/libartbase/base/unix_file/fd_file.h b/libartbase/base/unix_file/fd_file.h
index e362ed13ce..54a16a28b6 100644
--- a/libartbase/base/unix_file/fd_file.h
+++ b/libartbase/base/unix_file/fd_file.h
@@ -46,10 +46,10 @@ class FdFile : public RandomAccessFile {
FdFile(const std::string& path, int flags, mode_t mode, bool checkUsage);
// Move constructor.
- FdFile(FdFile&& other);
+ FdFile(FdFile&& other) noexcept;
// Move assignment operator.
- FdFile& operator=(FdFile&& other);
+ FdFile& operator=(FdFile&& other) noexcept;
// Release the file descriptor. This will make further accesses to this FdFile invalid. Disables
// all further state checking.
diff --git a/openjdkjvmti/ti_class.cc b/openjdkjvmti/ti_class.cc
index 1ed615bf3e..f6113dfecc 100644
--- a/openjdkjvmti/ti_class.cc
+++ b/openjdkjvmti/ti_class.cc
@@ -145,7 +145,7 @@ class FakeJvmtiDeleter {
FakeJvmtiDeleter() {}
FakeJvmtiDeleter(FakeJvmtiDeleter&) = default;
- FakeJvmtiDeleter(FakeJvmtiDeleter&&) = default;
+ FakeJvmtiDeleter(FakeJvmtiDeleter&&) noexcept = default;
FakeJvmtiDeleter& operator=(const FakeJvmtiDeleter&) = default;
template <typename U> void operator()(const U* ptr) const {
diff --git a/openjdkjvmti/ti_stack.cc b/openjdkjvmti/ti_stack.cc
index e2b98b3021..220ad22be5 100644
--- a/openjdkjvmti/ti_stack.cc
+++ b/openjdkjvmti/ti_stack.cc
@@ -77,7 +77,7 @@ struct GetStackTraceVisitor : public art::StackVisitor {
start(start_),
stop(stop_) {}
GetStackTraceVisitor(const GetStackTraceVisitor&) = default;
- GetStackTraceVisitor(GetStackTraceVisitor&&) = default;
+ GetStackTraceVisitor(GetStackTraceVisitor&&) noexcept = default;
bool VisitFrame() override REQUIRES_SHARED(art::Locks::mutator_lock_) {
art::ArtMethod* m = GetMethod();
diff --git a/runtime/jni/check_jni.cc b/runtime/jni/check_jni.cc
index c5e8830d29..6f61f5e37c 100644
--- a/runtime/jni/check_jni.cc
+++ b/runtime/jni/check_jni.cc
@@ -181,7 +181,7 @@ class VarArgs {
}
}
- VarArgs(VarArgs&& other) {
+ VarArgs(VarArgs&& other) noexcept {
m_ = other.m_;
cnt_ = other.cnt_;
type_ = other.type_;
diff --git a/runtime/reference_table.cc b/runtime/reference_table.cc
index d62cbdb11a..45f5633f3d 100644
--- a/runtime/reference_table.cc
+++ b/runtime/reference_table.cc
@@ -277,7 +277,7 @@ void ReferenceTable::Dump(std::ostream& os, Table& entries) {
size_t identical;
SummaryElement() : equiv(0), identical(0) {}
- SummaryElement(SummaryElement&& ref) {
+ SummaryElement(SummaryElement&& ref) noexcept {
root = ref.root;
equiv = ref.equiv;
identical = ref.identical;
diff --git a/runtime/ti/agent.cc b/runtime/ti/agent.cc
index fc51567241..97c39bb3db 100644
--- a/runtime/ti/agent.cc
+++ b/runtime/ti/agent.cc
@@ -176,7 +176,7 @@ void Agent::Unload() {
}
}
-Agent::Agent(Agent&& other)
+Agent::Agent(Agent&& other) noexcept
: dlopen_handle_(nullptr),
onload_(nullptr),
onattach_(nullptr),
@@ -184,7 +184,7 @@ Agent::Agent(Agent&& other)
*this = std::move(other);
}
-Agent& Agent::operator=(Agent&& other) {
+Agent& Agent::operator=(Agent&& other) noexcept {
if (this != &other) {
if (dlopen_handle_ != nullptr) {
Unload();
diff --git a/runtime/ti/agent.h b/runtime/ti/agent.h
index 24a6f1ce6a..faf76a1334 100644
--- a/runtime/ti/agent.h
+++ b/runtime/ti/agent.h
@@ -105,8 +105,8 @@ class Agent {
// TODO We need to acquire some locks probably.
void Unload();
- Agent(Agent&& other);
- Agent& operator=(Agent&& other);
+ Agent(Agent&& other) noexcept;
+ Agent& operator=(Agent&& other) noexcept;
~Agent();
diff --git a/tools/titrace/titrace.cc b/tools/titrace/titrace.cc
index 981ad56e86..ca568d7b33 100644
--- a/tools/titrace/titrace.cc
+++ b/tools/titrace/titrace.cc
@@ -54,7 +54,7 @@ struct TiMemory {
}
TiMemory(const TiMemory& other) = delete;
- TiMemory(TiMemory&& other) {
+ TiMemory(TiMemory&& other) noexcept {
env_ = other.env_;
mem_ = other.mem_;
size_ = other.size_;
@@ -66,7 +66,7 @@ struct TiMemory {
}
}
- TiMemory& operator=(TiMemory&& other) {
+ TiMemory& operator=(TiMemory&& other) noexcept {
if (mem_ != other.mem_) {
TiMemory::~TiMemory();
}