#include "clang/ARCMigrate/ARCMT.h"
#include "clang/AST/ASTContext.h"
#include "clang/Frontend/PCHContainerOperations.h"
#include "clang/Frontend/TextDiagnosticPrinter.h"
#include "clang/Frontend/Utils.h"
#include "clang/Frontend/VerifyDiagnosticConsumer.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Lex/PreprocessorOptions.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Signals.h"
#include <system_error>
usingnamespaceclang;
usingnamespacearcmt;
static llvm::cl::opt<bool>
CheckOnly("check-only",
llvm::cl::desc("Just check for issues that need to be handled manually"));
static llvm::cl::opt<bool>
OutputTransformations("output-transformations",
llvm::cl::desc("Print the source transformations"));
static llvm::cl::opt<bool>
VerifyDiags("verify",llvm::cl::desc("Verify emitted diagnostics and warnings"));
static llvm::cl::opt<bool>
VerboseOpt("v", llvm::cl::desc("Enable verbose output"));
static llvm::cl::opt<bool>
VerifyTransformedFiles("verify-transformed-files",
llvm::cl::desc("Read pairs of file mappings (typically the output of "
"c-arcmt-test) and compare their contents with the filenames "
"provided in command-line"));
static llvm::cl::opt<std::string>
RemappingsFile("remappings-file",
llvm::cl::desc("Pairs of file mappings (typically the output of "
"c-arcmt-test)"));
static llvm::cl::list<std::string>
ResultFiles(llvm::cl::Positional, llvm::cl::desc("<filename>..."));
static llvm::cl::extrahelp extraHelp(
"\nusage with compiler args: arcmt-test [options] --args [compiler flags]\n");
std::string GetExecutablePath(const char *Argv0) { … }
static void printSourceLocation(SourceLocation loc, ASTContext &Ctx,
raw_ostream &OS);
static void printSourceRange(CharSourceRange range, ASTContext &Ctx,
raw_ostream &OS);
namespace {
class PrintTransforms : public MigrationProcess::RewriteListener { … };
}
static bool checkForMigration(StringRef resourcesPath,
ArrayRef<const char *> Args) { … }
static void printResult(FileRemapper &remapper, raw_ostream &OS) { … }
static bool performTransformations(StringRef resourcesPath,
ArrayRef<const char *> Args) { … }
static bool filesCompareEqual(StringRef fname1, StringRef fname2) { … }
static bool verifyTransformedFiles(ArrayRef<std::string> resultFiles) { … }
static void printSourceLocation(SourceLocation loc, ASTContext &Ctx,
raw_ostream &OS) { … }
static void printSourceRange(CharSourceRange range, ASTContext &Ctx,
raw_ostream &OS) { … }
int main(int argc, const char **argv) { … }