From 7a5e7c28b508c767b5305c8bcbdfbf75b180285f Mon Sep 17 00:00:00 2001 From: Josh Berdine Date: Tue, 29 Nov 2016 16:35:51 -0800 Subject: [PATCH] ppx_compare Const Reviewed By: cristianoc Differential Revision: D4232385 fbshipit-source-id: c530aa8 --- infer/src/IR/Const.re | 29 ++--------------------------- infer/src/IR/Const.rei | 5 ++--- 2 files changed, 4 insertions(+), 30 deletions(-) diff --git a/infer/src/IR/Const.re b/infer/src/IR/Const.re index 2c5866463..0f9c83fd7 100644 --- a/infer/src/IR/Const.re +++ b/infer/src/IR/Const.re @@ -24,33 +24,8 @@ type t = | Cstr string /** string constants */ | Cfloat float /** float constants */ | Cclass Ident.name /** class constant */ - | Cptr_to_fld Ident.fieldname Typ.t /** pointer to field constant, and type of the surrounding Csu.t type */; - -let compare (c1: t) (c2: t) :int => - switch (c1, c2) { - | (Cint i1, Cint i2) => IntLit.compare i1 i2 - | (Cint _, _) => (-1) - | (_, Cint _) => 1 - | (Cfun fn1, Cfun fn2) => Procname.compare fn1 fn2 - | (Cfun _, _) => (-1) - | (_, Cfun _) => 1 - | (Cstr s1, Cstr s2) => string_compare s1 s2 - | (Cstr _, _) => (-1) - | (_, Cstr _) => 1 - | (Cfloat f1, Cfloat f2) => float_compare f1 f2 - | (Cfloat _, _) => (-1) - | (_, Cfloat _) => 1 - | (Cclass c1, Cclass c2) => Ident.compare_name c1 c2 - | (Cclass _, _) => (-1) - | (_, Cclass _) => 1 - | (Cptr_to_fld fn1 t1, Cptr_to_fld fn2 t2) => - let n = Ident.compare_fieldname fn1 fn2; - if (n != 0) { - n - } else { - Typ.compare t1 t2 - } - }; + | Cptr_to_fld Ident.fieldname Typ.t /** pointer to field constant, and type of the surrounding Csu.t type */ +[@@deriving compare]; let equal c1 c2 => compare c1 c2 == 0; diff --git a/infer/src/IR/Const.rei b/infer/src/IR/Const.rei index 321e06f89..499a757cc 100644 --- a/infer/src/IR/Const.rei +++ b/infer/src/IR/Const.rei @@ -26,9 +26,8 @@ type t = | Cstr string /** string constants */ | Cfloat float /** float constants */ | Cclass Ident.name /** class constant */ - | Cptr_to_fld Ident.fieldname Typ.t /** pointer to field constant, and type of the surrounding Csu.t type */; - -let compare: t => t => int; + | Cptr_to_fld Ident.fieldname Typ.t /** pointer to field constant, and type of the surrounding Csu.t type */ +[@@deriving compare]; let equal: t => t => bool;