12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576(****************************************************************************)(* *)(* This file is part of MOPSA, a Modular Open Platform for Static Analysis. *)(* *)(* Copyright (C) 2017-2019 The MOPSA Project. *)(* *)(* This program is free software: you can redistribute it and/or modify *)(* it under the terms of the GNU Lesser General Public License as published *)(* by the Free Software Foundation, either version 3 of the License, or *)(* (at your option) any later version. *)(* *)(* This program is distributed in the hope that it will be useful, *)(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)(* GNU Lesser General Public License for more details. *)(* *)(* You should have received a copy of the GNU Lesser General Public License *)(* along with this program. If not, see <http://www.gnu.org/licenses/>. *)(* *)(****************************************************************************)(** Stub alarms *)openMopsaopenAsttypecheck+=CHK_STUB_CONDITIONtypealarm_kind+=A_stub_invalid_requirementofexpr(** condition *)|A_stub_raiseofstring(** message *)let()=register_check(fundefaultfmt->function|CHK_STUB_CONDITION->Format.fprintffmt"Stub condition"|a->defaultfmta)let()=register_alarm{check=(funnext->function|A_stub_invalid_requirement_->CHK_STUB_CONDITION|A_stub_raise_->CHK_STUB_CONDITION|a->nexta);compare=(funnexta1a2->matcha1,a2with|A_stub_invalid_requiremente1,A_stub_invalid_requiremente2->compare_expre1e2|A_stub_raises1,A_stub_raises2->String.compares1s2|_->nexta1a2);print=(funnextfmt->function|A_stub_invalid_requiremente->Format.fprintffmt"invalid requirement '%a'"(Debug.boldpp_expr)e|A_stub_raises->Format.pp_print_stringfmts|a->nextfmta);join=(funnext->next);}letraise_stub_invalid_requirement?(bottom=true)condrangemanflow=letcs=Flow.get_callstackflowinletcond'=get_orig_exprcondinletalarm=mk_alarm(A_stub_invalid_requirementcond')csrangeinFlow.raise_alarmalarm~bottomman.latticeflowletraise_stub_alarm?(bottom=true)msgrangemanflow=letcs=Flow.get_callstackflowinletalarm=mk_alarm(A_stub_raisemsg)csrangeinFlow.raise_alarmalarm~bottomman.latticeflowletsafe_stub_conditionrangemanflow=Flow.add_safe_checkCHK_STUB_CONDITIONrangeflow