ART: Mask garbage-memory warnings
Add invariants or NOLINT to let clang-analyzer understand that
there's no garbage involved.
(The analysis itself is too expensive to force it on for all
local builds.)
Test: mmma art
Change-Id: I6148d743321248195abb3a8f646e63941f11f9a9
diff --git a/runtime/class_loader_utils.h b/runtime/class_loader_utils.h
index af42878..78ad568 100644
--- a/runtime/class_loader_utils.h
+++ b/runtime/class_loader_utils.h
@@ -147,8 +147,14 @@
Handle<mirror::ClassLoader> class_loader,
Visitor fn)
REQUIRES_SHARED(Locks::mutator_lock_) {
- auto helper = [&fn](const art::DexFile* dex_file, void** ATTRIBUTE_UNUSED)
+ auto helper = [&fn](const art::DexFile* dex_file, void** ret)
REQUIRES_SHARED(Locks::mutator_lock_) {
+#ifdef __clang_analyzer__
+ *ret = nullptr;
+#else
+ UNUSED(ret);
+#endif
+
return fn(dex_file);
};
VisitClassLoaderDexFiles<decltype(helper), void*>(soa,
diff --git a/runtime/thread.cc b/runtime/thread.cc
index 7a7a80e..388c69e 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -598,7 +598,7 @@
1u;
#endif
volatile char space[kPageSize - (kAsanMultiplier * 256)];
- char sink ATTRIBUTE_UNUSED = space[zero];
+ char sink ATTRIBUTE_UNUSED = space[zero]; // NOLINT
if (reinterpret_cast<uintptr_t>(space) >= target + kPageSize) {
Touch(target);
}
diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc
index 61ddded..47877bd 100644
--- a/runtime/verifier/method_verifier.cc
+++ b/runtime/verifier/method_verifier.cc
@@ -3839,6 +3839,8 @@
template <class T>
ArtMethod* MethodVerifier::VerifyInvocationArgsFromIterator(
T* it, const Instruction* inst, MethodType method_type, bool is_range, ArtMethod* res_method) {
+ DCHECK_EQ(!is_range, inst->HasVarArgs());
+
// We use vAA as our expected arg count, rather than res_method->insSize, because we need to
// match the call to the signature. Also, we might be calling through an abstract method
// definition (which doesn't have register count values).
diff --git a/test/ti-agent/breakpoint_helper.cc b/test/ti-agent/breakpoint_helper.cc
index db4ea61..83ba0a6 100644
--- a/test/ti-agent/breakpoint_helper.cc
+++ b/test/ti-agent/breakpoint_helper.cc
@@ -114,7 +114,7 @@
return 0;
}
jlong start = 0;
- jlong end = end;
+ jlong end;
JvmtiErrorToException(env, jvmti_env, jvmti_env->GetMethodLocation(method, &start, &end));
return start;
}