2004-04-13 22:55:49 +02:00
|
|
|
//===- fpcmp.cpp - A fuzzy "cmp" that permits floating point noise --------===//
|
2005-04-22 02:00:37 +02:00
|
|
|
//
|
2004-04-13 22:55:49 +02:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 21:37:13 +01:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-22 02:00:37 +02:00
|
|
|
//
|
2004-04-13 22:55:49 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// fpcmp is a tool that basically works like the 'cmp' tool, except that it can
|
2005-01-23 04:15:47 +01:00
|
|
|
// tolerate errors due to floating point noise, with the -r and -a options.
|
2004-04-13 22:55:49 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2004-09-02 00:55:40 +02:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
2005-01-23 04:15:47 +01:00
|
|
|
#include "llvm/Support/FileUtilities.h"
|
2010-04-15 05:47:24 +02:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2004-04-13 22:55:49 +02:00
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
cl::opt<std::string>
|
|
|
|
File1(cl::Positional, cl::desc("<input file #1>"), cl::Required);
|
|
|
|
cl::opt<std::string>
|
|
|
|
File2(cl::Positional, cl::desc("<input file #2>"), cl::Required);
|
|
|
|
|
|
|
|
cl::opt<double>
|
|
|
|
RelTolerance("r", cl::desc("Relative error tolerated"), cl::init(0));
|
|
|
|
cl::opt<double>
|
|
|
|
AbsTolerance("a", cl::desc("Absolute error tolerated"), cl::init(0));
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
cl::ParseCommandLineOptions(argc, argv);
|
|
|
|
|
2005-01-23 04:15:47 +01:00
|
|
|
std::string ErrorMsg;
|
2013-06-13 22:41:00 +02:00
|
|
|
int DF = DiffFilesWithTolerance(File1, File2, AbsTolerance, RelTolerance,
|
|
|
|
&ErrorMsg);
|
2005-01-23 04:15:47 +01:00
|
|
|
if (!ErrorMsg.empty())
|
2010-04-15 05:47:24 +02:00
|
|
|
errs() << argv[0] << ": " << ErrorMsg << "\n";
|
2005-01-23 04:15:47 +01:00
|
|
|
return DF;
|
2004-04-13 22:55:49 +02:00
|
|
|
}
|
|
|
|
|