void updateArgIfSet(llvm::cl::opt<T> &argValue, const llvm::Optional<T> &configValue) { if (configValue.hasValue() && argValue.getNumOccurrences() == 0) { argValue.setValue(configValue.getValue()); } }
int main(int argc, char* argv[]) { CodeHandler::Init(argc,argv); // First check if the report file exists and if not create the table header fstream report_file; const char * report_file_name = (ReportFilename.size()) ? ReportFilename[0].c_str() : "report.out"; report_file.open(report_file_name,ios::in); bool file_exists = report_file.is_open(); report_file.close(); report_file.open(report_file_name,ofstream::out | ofstream::app); if ( !file_exists ) report_file << "| " << setw(15) << "Filename" << " | " << setw(10) << "Domain" << " | " << setw(12) << "CanonPoint" << " | " << setw(15) << "CanonStrategy" << " | " << setw(6) << "#Added" << " | " << setw(8) << "#Deleted" << " | " << setw(12) << "#DiffPoints" << " | " << setw(6) << "#Diffs" << " | " << setw(15) << "Optimal #Diffs" << "|\n"; report_file << "| "<< setw(15) << InputFilename << " | " << setw(10) << string(ManagerType[0]) << " | " << setw(12) << string((PartitionPoint.size() > 0) ? PartitionPoint[0] : "none") << " | " << setw(15) << string((PartitionStrategy.size() > 0) ? PartitionStrategy[0] : "equiv") << " | "; string filename = InputFilename, patched_filname = PatchedFilename[0]; // Start by guarding both files GuardFilename.addValue(filename); cout << "GuardFilename = " << GuardFilename[0] << endl; InputFilename = GuardFilename[0]; UnionCompiler().GuardedInstructionsTransform(); // Ignore this option from now own (the condition is size() == 1) GuardFilename.addValue(""); GuardTaggedFilename.addValue(patched_filname); cout << "GuardTaggedFilename = " << GuardTaggedFilename[0] << endl; InputFilename = GuardTaggedFilename[0]; UnionCompiler().GuardedInstructionsTransform(); // Ignore this option from now own (the condition is size() == 1) GuardTaggedFilename.addValue(""); // Now tag the patched file TagFilename.addValue(Defines::kGuardedFilenamePrefix + patched_filname); cout << "TagFilename = " << TagFilename[0] << endl; InputFilename = TagFilename[0]; UnionCompiler().TagInstructionsTransform(); // Ignore this option from now own (the condition is size() == 1) TagFilename.addValue(""); // Now union the files InputFilename.setValue(Defines::kGuardedFilenamePrefix + filename); PatchedFilename[0] = Defines::kTaggedFilenamePrefix + Defines::kGuardedFilenamePrefix + patched_filname; cout << "InputFilename = " << InputFilename << ",PatchedFilename = " << PatchedFilename[0] << endl; UnionCompiler().UnionTransform(report_file); // Ignore this option from now own (the condition is size() == 1) PatchedFilename.addValue(""); // Now analyze it InputFilename.setValue(Defines::kUnionedFilenamePrefix + filename); cout << "InputFilename = " << InputFilename << endl; Analyzer().RunAnalysis(report_file); report_file << setw(15) <<" |\n"; report_file.close(); return 0; }