optimizing: Fix a potential nullptr dereference
Operator precedence in C++ means the DCHECK was parsed as
DCHECK((allocation != nullptr && allocation->IsNewInstance()) ||
allocation->IsNewArray())
Caught by the static analyzer:
art/compiler/optimizing/instruction_builder.cc:1004:14: warning: Called
C++ object pointer is null [clang-analyzer-core.CallAndMessage]
Bug: None
Test: Reran the static analyzer. No more nullptr complaints. m builds
the file fine, as well.
Change-Id: Iad94719fc013f1883746128e066452994740f171
diff --git a/compiler/optimizing/instruction_builder.cc b/compiler/optimizing/instruction_builder.cc
index 40fafb0..df9e716 100644
--- a/compiler/optimizing/instruction_builder.cc
+++ b/compiler/optimizing/instruction_builder.cc
@@ -1000,8 +1000,8 @@
void HInstructionBuilder::BuildConstructorFenceForAllocation(HInstruction* allocation) {
DCHECK(allocation != nullptr &&
- allocation->IsNewInstance() ||
- allocation->IsNewArray()); // corresponding to "new" keyword in JLS.
+ (allocation->IsNewInstance() ||
+ allocation->IsNewArray())); // corresponding to "new" keyword in JLS.
if (allocation->IsNewInstance()) {
// STRING SPECIAL HANDLING: