1 //===- fpcmp.cpp - A fuzzy "cmp" that permits floating point noise --------===//
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-exception
7 //===----------------------------------------------------------------------===//
9 // fpcmp is a tool that basically works like the 'cmp' tool, except that it can
10 // tolerate errors due to floating point noise, with the -r and -a options.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/Support/CommandLine.h"
15 #include "llvm/Support/FileUtilities.h"
16 #include "llvm/Support/raw_ostream.h"
21 File1(cl::Positional
, cl::desc("<input file #1>"), cl::Required
);
23 File2(cl::Positional
, cl::desc("<input file #2>"), cl::Required
);
26 RelTolerance("r", cl::desc("Relative error tolerated"), cl::init(0));
28 AbsTolerance("a", cl::desc("Absolute error tolerated"), cl::init(0));
31 int main(int argc
, char **argv
) {
32 cl::ParseCommandLineOptions(argc
, argv
);
35 int DF
= DiffFilesWithTolerance(File1
, File2
, AbsTolerance
, RelTolerance
,
37 if (!ErrorMsg
.empty())
38 errs() << argv
[0] << ": " << ErrorMsg
<< "\n";