Fix static analyzer warning
nodes.cc: warning: Access to field 'next_' results in a dereference of a
null pointer (loaded from field 'last_instruction_')
This was split from
https://android-review.googlesource.com/#/c/416101/. Please see the
discussion nodes.cc (patch set 1) for why this warning is triggered.
Bug: 32619234
Test: test-art-host. Rebuilt ART with the analyzer to verify that these
issues are gone.
Change-Id: Id5da00ceee0667441233153a7971d238ea8c8650
diff --git a/compiler/optimizing/nodes.cc b/compiler/optimizing/nodes.cc
index d0047c5..4ca8337 100644
--- a/compiler/optimizing/nodes.cc
+++ b/compiler/optimizing/nodes.cc
@@ -967,6 +967,7 @@
DCHECK(last_instruction_ == nullptr);
first_instruction_ = last_instruction_ = instruction;
} else {
+ DCHECK(last_instruction_ != nullptr);
last_instruction_->next_ = instruction;
instruction->previous_ = last_instruction_;
last_instruction_ = instruction;