-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[hack][models] first model for hhbc_cmp_same
Summary: The Hack equality test === compare objects by reference. We propose a first model for the underlying hhbc_cmp_same builtin. We will need to refine this model later to take into account primitive types that are boxed in InferHack. Reviewed By: vsiles Differential Revision: D46061589 fbshipit-source-id: 161d67811c9ea45cb96a714d97751ff0060d65fb
- Loading branch information
1 parent
8314cbc
commit be05786
Showing
3 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright (c) Facebook, Inc. and its affiliates. | ||
// | ||
// This source code is licensed under the MIT license found in the | ||
// LICENSE file in the root directory of this source tree. | ||
|
||
namespace Equality; | ||
|
||
class A { | ||
|
||
public function eqNullSimpleBad() { | ||
$a = null; | ||
$taint = \Level1\taintSource(); | ||
if ($a === null) { | ||
\Level1\taintSink($taint); | ||
} | ||
} | ||
|
||
public function eqNullSimpleGood() { | ||
$a = new A(); | ||
$taint = \Level1\taintSource(); | ||
if ($a === null) { | ||
\Level1\taintSink($taint); | ||
} | ||
} | ||
|
||
public function neNullSimpleBad() { | ||
$a = new A(); | ||
$taint = \Level1\taintSource(); | ||
if ($a !== null) { | ||
\Level1\taintSink($taint); | ||
} | ||
} | ||
|
||
public function doubleEqNullBad(A $a) { | ||
$taint = \Level1\taintSource(); | ||
if ($a === null) { | ||
if (null === $a) { | ||
\Level1\taintSink($taint); | ||
} | ||
} | ||
} | ||
|
||
public function doubleEqNullGood(A $a1) { | ||
$taint = \Level1\taintSource(); | ||
$a = new A(); | ||
if ($a1 === null) { | ||
if ($a1 === $a) { | ||
\Level1\taintSink($taint); | ||
} | ||
} | ||
} | ||
|
||
public function doubleEqNeNullGood(A $a) { | ||
$taint = \Level1\taintSource(); | ||
if ($a === null) { | ||
if ($a !== null) { | ||
\Level1\taintSink($taint); | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters