diff options
| author | 2014-09-30 15:43:59 -0700 | |
|---|---|---|
| committer | 2014-09-30 15:43:59 -0700 | |
| commit | 07140838a3ee44a6056cacdc78f2930e019107da (patch) | |
| tree | 4f344df6ec2612d8ddbf0a00e2b49a39a7501249 | |
| parent | f9098ea6d7326b4d8de2860d18adf74046b80855 (diff) | |
Enable -Wunreachable-code
Caught bugs in DeoptimizeStackVisitor and assemble_x86 SIB encoding.
Add UNREACHABLE macro to document code expected to be unreachable.
Bug: 17731047
Change-Id: I2e363fe5b38a1246354d98be18c902a6031c0b9e
| -rw-r--r-- | build/Android.common_build.mk | 1 | ||||
| -rw-r--r-- | compiler/dex/quick/x86/assemble_x86.cc | 2 | ||||
| -rw-r--r-- | runtime/base/macros.h | 1 | ||||
| -rw-r--r-- | runtime/class_linker.cc | 6 | ||||
| -rw-r--r-- | runtime/mirror/object.cc | 3 | ||||
| -rw-r--r-- | runtime/parsed_options.cc | 2 | ||||
| -rw-r--r-- | runtime/quick_exception_handler.cc | 8 |
7 files changed, 11 insertions, 12 deletions
diff --git a/build/Android.common_build.mk b/build/Android.common_build.mk index 0dcefead38..386128e00d 100644 --- a/build/Android.common_build.mk +++ b/build/Android.common_build.mk @@ -158,6 +158,7 @@ art_cflags := \ -Wno-unused-parameter \ -Wstrict-aliasing \ -fstrict-aliasing \ + -Wunreachable-code \ -fvisibility=protected ART_TARGET_CLANG_CFLAGS := diff --git a/compiler/dex/quick/x86/assemble_x86.cc b/compiler/dex/quick/x86/assemble_x86.cc index ab1608be91..dce2b73fff 100644 --- a/compiler/dex/quick/x86/assemble_x86.cc +++ b/compiler/dex/quick/x86/assemble_x86.cc @@ -580,7 +580,7 @@ static bool HasSib(const X86EncodingMap* entry) { case kX86CallA: return true; default: return false; } - case kPcRel: return true; + case kPcRel: switch (entry->opcode) { case kX86PcRelLoadRA: return true; default: return false; diff --git a/runtime/base/macros.h b/runtime/base/macros.h index fae9271d9e..b66d528d1b 100644 --- a/runtime/base/macros.h +++ b/runtime/base/macros.h @@ -179,6 +179,7 @@ char (&ArraySizeHelper(T (&array)[N]))[N]; #define WARN_UNUSED __attribute__((warn_unused_result)) template<typename T> void UNUSED(const T&) {} +#define UNREACHABLE __builtin_unreachable // Annotalysis thread-safety analysis support. #if defined(__SUPPORT_TS_ANNOTATION__) || defined(__clang__) diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index cc77c508a5..2cf3820ace 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -2269,9 +2269,7 @@ mirror::Class* ClassLinker::FindClass(Thread* self, const char* descriptor, return soa.Decode<mirror::Class*>(result.get()); } } - - ThrowNoClassDefFoundError("Class %s not found", PrintableString(descriptor).c_str()); - return nullptr; + UNREACHABLE(); } mirror::Class* ClassLinker::DefineClass(Thread* self, const char* descriptor, @@ -4340,7 +4338,7 @@ bool ClassLinker::WaitForInitializeClass(Handle<mirror::Class> klass, Thread* se LOG(FATAL) << "Unexpected class status. " << PrettyClass(klass.Get()) << " is " << klass->GetStatus(); } - LOG(FATAL) << "Not Reached" << PrettyClass(klass.Get()); + UNREACHABLE(); } bool ClassLinker::ValidateSuperClassDescriptors(Handle<mirror::Class> klass) { diff --git a/runtime/mirror/object.cc b/runtime/mirror/object.cc index a1177d645d..57069ab26c 100644 --- a/runtime/mirror/object.cc +++ b/runtime/mirror/object.cc @@ -187,8 +187,7 @@ int32_t Object::IdentityHashCode() const { } } } - LOG(FATAL) << "Unreachable"; - return 0; + UNREACHABLE(); } void Object::CheckFieldAssignmentImpl(MemberOffset field_offset, Object* new_value) { diff --git a/runtime/parsed_options.cc b/runtime/parsed_options.cc index 2bd994dc57..d82002683a 100644 --- a/runtime/parsed_options.cc +++ b/runtime/parsed_options.cc @@ -932,7 +932,7 @@ bool ParsedOptions::ParseDouble(const std::string& option, char after_char, } bool sane_val = true; double value; - if (false) { + if ((false)) { // TODO: this doesn't seem to work on the emulator. b/15114595 std::stringstream iss(substring); iss >> value; diff --git a/runtime/quick_exception_handler.cc b/runtime/quick_exception_handler.cc index 43d21de765..2c158ba963 100644 --- a/runtime/quick_exception_handler.cc +++ b/runtime/quick_exception_handler.cc @@ -230,7 +230,7 @@ class DeoptimizeStackVisitor FINAL : public StackVisitor { reinterpret_cast<mirror::Object*>(GetVReg(m, reg, kind))); break; case kLongLoVReg: - if (GetVRegKind(reg + 1, kinds), kLongHiVReg) { + if (GetVRegKind(reg + 1, kinds) == kLongHiVReg) { // Treat it as a "long" register pair. new_frame->SetVRegLong(reg, GetVRegPair(m, reg, kLongLoVReg, kLongHiVReg)); } else { @@ -238,14 +238,14 @@ class DeoptimizeStackVisitor FINAL : public StackVisitor { } break; case kLongHiVReg: - if (GetVRegKind(reg - 1, kinds), kLongLoVReg) { + if (GetVRegKind(reg - 1, kinds) == kLongLoVReg) { // Nothing to do: we treated it as a "long" register pair. } else { new_frame->SetVReg(reg, GetVReg(m, reg, kind)); } break; case kDoubleLoVReg: - if (GetVRegKind(reg + 1, kinds), kDoubleHiVReg) { + if (GetVRegKind(reg + 1, kinds) == kDoubleHiVReg) { // Treat it as a "double" register pair. new_frame->SetVRegLong(reg, GetVRegPair(m, reg, kDoubleLoVReg, kDoubleHiVReg)); } else { @@ -253,7 +253,7 @@ class DeoptimizeStackVisitor FINAL : public StackVisitor { } break; case kDoubleHiVReg: - if (GetVRegKind(reg - 1, kinds), kDoubleLoVReg) { + if (GetVRegKind(reg - 1, kinds) == kDoubleLoVReg) { // Nothing to do: we treated it as a "double" register pair. } else { new_frame->SetVReg(reg, GetVReg(m, reg, kind)); |