2004-04-13 20:55:49 +00:00
|
|
|
//===- fpcmp.cpp - A fuzzy "cmp" that permits floating point noise --------===//
|
2005-04-22 00:00:37 +00:00
|
|
|
//
|
2004-04-13 20:55:49 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:37:13 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-22 00:00:37 +00:00
|
|
|
//
|
2004-04-13 20:55:49 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// fpcmp is a tool that basically works like the 'cmp' tool, except that it can
|
2005-01-23 03:15:47 +00:00
|
|
|
// tolerate errors due to floating point noise, with the -r and -a options.
|
2004-04-13 20:55:49 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2004-09-01 22:55:40 +00:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
2005-01-23 03:15:47 +00:00
|
|
|
#include "llvm/Support/FileUtilities.h"
|
2010-04-15 03:47:24 +00:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2004-04-13 20:55:49 +00: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 03:15:47 +00:00
|
|
|
std::string ErrorMsg;
|
2007-04-07 19:49:35 +00:00
|
|
|
int DF = DiffFilesWithTolerance(sys::PathWithStatus(File1),
|
|
|
|
sys::PathWithStatus(File2),
|
2005-01-23 03:32:16 +00:00
|
|
|
AbsTolerance, RelTolerance, &ErrorMsg);
|
2005-01-23 03:15:47 +00:00
|
|
|
if (!ErrorMsg.empty())
|
2010-04-15 03:47:24 +00:00
|
|
|
errs() << argv[0] << ": " << ErrorMsg << "\n";
|
2005-01-23 03:15:47 +00:00
|
|
|
return DF;
|
2004-04-13 20:55:49 +00:00
|
|
|
}
|
|
|
|
|