#include "llvm/Support/FileSystem.h"
#include "llvm/Support/YAMLTraits.h"
#include "llvm/Support/raw_ostream.h"
-#include <cstdlib>
#include <string>
#include <system_error>
// Check the arguments for correctness.
if (NewNames.empty()) {
errs() << "clang-rename: -new-name must be specified.\n\n";
- exit(1);
+ return 1;
}
if (SymbolOffsets.empty() == QualifiedNames.empty()) {
errs() << "clang-rename: -offset and -qualified-name can't be present at "
"the same time.\n";
- exit(1);
+ return 1;
}
// Check if NewNames is a valid identifier in C++17.
auto NewNameTokKind = Table.get(NewName).getTokenID();
if (!tok::isAnyIdentifier(NewNameTokKind)) {
errs() << "ERROR: new name is not a valid identifier in C++17.\n\n";
- exit(1);
+ return 1;
}
}
<< ") must be equal to number of new names(" << NewNames.size()
<< ").\n\n";
cl::PrintHelpMessage();
- exit(1);
+ return 1;
}
auto Files = OP.getSourcePathList();
if (FindingAction.errorOccurred()) {
// Diagnostics are already issued at this point.
- exit(1);
+ return 1;
}
if (Force && PrevNames.size() < NewNames.size()) {
// No matching PrevName for all NewNames. Without Force this is an error
// above already.
- exit(0);
+ return 0;
}
// Perform the renaming.
llvm::raw_fd_ostream OS(ExportFixes, EC, llvm::sys::fs::F_None);
if (EC) {
llvm::errs() << "Error opening output file: " << EC.message() << '\n';
- exit(1);
+ return 1;
}
// Export replacements.
yaml::Output YAML(OS);
YAML << TUR;
OS.close();
- exit(0);
+ return 0;
}
// Write every file to stdout. Right now we just barf the files without any
}
}
- exit(ExitCode);
+ return ExitCode;
}