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
|
|
|
|
//
|
|
|
|
// This file was developed by the LLVM research group and 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"
|
2004-04-13 22:55:49 +02:00
|
|
|
#include <iostream>
|
|
|
|
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;
|
2005-01-23 04:32:16 +01:00
|
|
|
int DF = DiffFilesWithTolerance(sys::Path(File1), sys::Path(File2),
|
|
|
|
AbsTolerance, RelTolerance, &ErrorMsg);
|
2005-01-23 04:15:47 +01:00
|
|
|
if (!ErrorMsg.empty())
|
|
|
|
std::cerr << argv[0] << ": " << ErrorMsg << "\n";
|
|
|
|
return DF;
|
2004-04-13 22:55:49 +02:00
|
|
|
}
|
|
|
|
|