brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · 52bddee Raw
42 lines · cpp
1//===- fpcmp.cpp - A fuzzy "cmp" that permits floating point noise --------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8//9// fpcmp is a tool that basically works like the 'cmp' tool, except that it can10// tolerate errors due to floating point noise, with the -r and -a options.11//12//===----------------------------------------------------------------------===//13 14#include "llvm/Support/CommandLine.h"15#include "llvm/Support/FileUtilities.h"16#include "llvm/Support/raw_ostream.h"17using namespace llvm;18 19namespace {20  cl::opt<std::string>21  File1(cl::Positional, cl::desc("<input file #1>"), cl::Required);22  cl::opt<std::string>23  File2(cl::Positional, cl::desc("<input file #2>"), cl::Required);24 25  cl::opt<double>26  RelTolerance("r", cl::desc("Relative error tolerated"), cl::init(0));27  cl::opt<double>28  AbsTolerance("a", cl::desc("Absolute error tolerated"), cl::init(0));29}30 31int main(int argc, char **argv) {32  cl::ParseCommandLineOptions(argc, argv);33 34  std::string ErrorMsg;35  int DF = DiffFilesWithTolerance(File1, File2, AbsTolerance, RelTolerance,36                                  &ErrorMsg);37  if (!ErrorMsg.empty())38    errs() << argv[0] << ": " << ErrorMsg << "\n";39  return DF;40}41 42