diff options
Diffstat (limited to 'include/clang/ARCMigrate')
-rw-r--r-- | include/clang/ARCMigrate/ARCMT.h | 131 | ||||
-rw-r--r-- | include/clang/ARCMigrate/ARCMTActions.h | 76 | ||||
-rw-r--r-- | include/clang/ARCMigrate/FileRemapper.h | 77 |
3 files changed, 0 insertions, 284 deletions
diff --git a/include/clang/ARCMigrate/ARCMT.h b/include/clang/ARCMigrate/ARCMT.h deleted file mode 100644 index 7408186..0000000 --- a/include/clang/ARCMigrate/ARCMT.h +++ /dev/null @@ -1,131 +0,0 @@ -//===-- ARCMT.h - ARC Migration Rewriter ------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_CLANG_ARCMIGRATE_ARCMT_H -#define LLVM_CLANG_ARCMIGRATE_ARCMT_H - -#include "clang/ARCMigrate/FileRemapper.h" -#include "clang/Basic/SourceLocation.h" -#include "clang/Frontend/CompilerInvocation.h" - -namespace clang { - class ASTContext; - class DiagnosticConsumer; - class PCHContainerOperations; - -namespace arcmt { - class MigrationPass; - -/// \brief Creates an AST with the provided CompilerInvocation but with these -/// changes: -/// -if a PCH/PTH is set, the original header is used instead -/// -Automatic Reference Counting mode is enabled -/// -/// It then checks the AST and produces errors/warning for ARC migration issues -/// that the user needs to handle manually. -/// -/// \param emitPremigrationARCErrors if true all ARC errors will get emitted -/// even if the migrator can fix them, but the function will still return false -/// if all ARC errors can be fixed. -/// -/// \param plistOut if non-empty, it is the file path to store the plist with -/// the pre-migration ARC diagnostics. -/// -/// \returns false if no error is produced, true otherwise. -bool -checkForManualIssues(CompilerInvocation &CI, const FrontendInputFile &Input, - std::shared_ptr<PCHContainerOperations> PCHContainerOps, - DiagnosticConsumer *DiagClient, - bool emitPremigrationARCErrors = false, - StringRef plistOut = StringRef()); - -/// \brief Works similar to checkForManualIssues but instead of checking, it -/// applies automatic modifications to source files to conform to ARC. -/// -/// \returns false if no error is produced, true otherwise. -bool -applyTransformations(CompilerInvocation &origCI, - const FrontendInputFile &Input, - std::shared_ptr<PCHContainerOperations> PCHContainerOps, - DiagnosticConsumer *DiagClient); - -/// \brief Applies automatic modifications and produces temporary files -/// and metadata into the \p outputDir path. -/// -/// \param emitPremigrationARCErrors if true all ARC errors will get emitted -/// even if the migrator can fix them, but the function will still return false -/// if all ARC errors can be fixed. -/// -/// \param plistOut if non-empty, it is the file path to store the plist with -/// the pre-migration ARC diagnostics. -/// -/// \returns false if no error is produced, true otherwise. -bool migrateWithTemporaryFiles( - CompilerInvocation &origCI, const FrontendInputFile &Input, - std::shared_ptr<PCHContainerOperations> PCHContainerOps, - DiagnosticConsumer *DiagClient, StringRef outputDir, - bool emitPremigrationARCErrors, StringRef plistOut); - -/// \brief Get the set of file remappings from the \p outputDir path that -/// migrateWithTemporaryFiles produced. -/// -/// \returns false if no error is produced, true otherwise. -bool getFileRemappings(std::vector<std::pair<std::string,std::string> > &remap, - StringRef outputDir, - DiagnosticConsumer *DiagClient); - -/// \brief Get the set of file remappings from a list of files with remapping -/// info. -/// -/// \returns false if no error is produced, true otherwise. -bool getFileRemappingsFromFileList( - std::vector<std::pair<std::string,std::string> > &remap, - ArrayRef<StringRef> remapFiles, - DiagnosticConsumer *DiagClient); - -typedef void (*TransformFn)(MigrationPass &pass); - -std::vector<TransformFn> getAllTransformations(LangOptions::GCMode OrigGCMode, - bool NoFinalizeRemoval); - -class MigrationProcess { - CompilerInvocation OrigCI; - std::shared_ptr<PCHContainerOperations> PCHContainerOps; - DiagnosticConsumer *DiagClient; - FileRemapper Remapper; - -public: - bool HadARCErrors; - - MigrationProcess(const CompilerInvocation &CI, - std::shared_ptr<PCHContainerOperations> PCHContainerOps, - DiagnosticConsumer *diagClient, - StringRef outputDir = StringRef()); - - class RewriteListener { - public: - virtual ~RewriteListener(); - - virtual void start(ASTContext &Ctx) { } - virtual void finish() { } - - virtual void insert(SourceLocation loc, StringRef text) { } - virtual void remove(CharSourceRange range) { } - }; - - bool applyTransform(TransformFn trans, RewriteListener *listener = nullptr); - - FileRemapper &getRemapper() { return Remapper; } -}; - -} // end namespace arcmt - -} // end namespace clang - -#endif diff --git a/include/clang/ARCMigrate/ARCMTActions.h b/include/clang/ARCMigrate/ARCMTActions.h deleted file mode 100644 index c830aa3..0000000 --- a/include/clang/ARCMigrate/ARCMTActions.h +++ /dev/null @@ -1,76 +0,0 @@ -//===--- ARCMTActions.h - ARC Migrate Tool Frontend Actions -----*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_CLANG_ARCMIGRATE_ARCMTACTIONS_H -#define LLVM_CLANG_ARCMIGRATE_ARCMTACTIONS_H - -#include "clang/ARCMigrate/FileRemapper.h" -#include "clang/Frontend/FrontendAction.h" -#include <memory> - -namespace clang { -namespace arcmt { - -class CheckAction : public WrapperFrontendAction { -protected: - bool BeginInvocation(CompilerInstance &CI) override; - -public: - CheckAction(FrontendAction *WrappedAction); -}; - -class ModifyAction : public WrapperFrontendAction { -protected: - bool BeginInvocation(CompilerInstance &CI) override; - -public: - ModifyAction(FrontendAction *WrappedAction); -}; - -class MigrateSourceAction : public ASTFrontendAction { - FileRemapper Remapper; -protected: - bool BeginInvocation(CompilerInstance &CI) override; - std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, - StringRef InFile) override; -}; - -class MigrateAction : public WrapperFrontendAction { - std::string MigrateDir; - std::string PlistOut; - bool EmitPremigrationARCErros; -protected: - bool BeginInvocation(CompilerInstance &CI) override; - -public: - MigrateAction(FrontendAction *WrappedAction, StringRef migrateDir, - StringRef plistOut, - bool emitPremigrationARCErrors); -}; - -/// \brief Migrates to modern ObjC syntax. -class ObjCMigrateAction : public WrapperFrontendAction { - std::string MigrateDir; - unsigned ObjCMigAction; - FileRemapper Remapper; - CompilerInstance *CompInst; -public: - ObjCMigrateAction(FrontendAction *WrappedAction, StringRef migrateDir, - unsigned migrateAction); - -protected: - std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, - StringRef InFile) override; - bool BeginInvocation(CompilerInstance &CI) override; -}; - -} -} - -#endif diff --git a/include/clang/ARCMigrate/FileRemapper.h b/include/clang/ARCMigrate/FileRemapper.h deleted file mode 100644 index 53b88e9..0000000 --- a/include/clang/ARCMigrate/FileRemapper.h +++ /dev/null @@ -1,77 +0,0 @@ -//===-- FileRemapper.h - File Remapping Helper ------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_CLANG_ARCMIGRATE_FILEREMAPPER_H -#define LLVM_CLANG_ARCMIGRATE_FILEREMAPPER_H - -#include "clang/Basic/LLVM.h" -#include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/PointerUnion.h" -#include "llvm/ADT/StringRef.h" -#include <memory> - -namespace llvm { - class MemoryBuffer; -} - -namespace clang { - class FileManager; - class FileEntry; - class DiagnosticsEngine; - class PreprocessorOptions; - -namespace arcmt { - -class FileRemapper { - // FIXME: Reuse the same FileManager for multiple ASTContexts. - std::unique_ptr<FileManager> FileMgr; - - typedef llvm::PointerUnion<const FileEntry *, llvm::MemoryBuffer *> Target; - typedef llvm::DenseMap<const FileEntry *, Target> MappingsTy; - MappingsTy FromToMappings; - - llvm::DenseMap<const FileEntry *, const FileEntry *> ToFromMappings; - -public: - FileRemapper(); - ~FileRemapper(); - - bool initFromDisk(StringRef outputDir, DiagnosticsEngine &Diag, - bool ignoreIfFilesChanged); - bool initFromFile(StringRef filePath, DiagnosticsEngine &Diag, - bool ignoreIfFilesChanged); - bool flushToDisk(StringRef outputDir, DiagnosticsEngine &Diag); - bool flushToFile(StringRef outputPath, DiagnosticsEngine &Diag); - - bool overwriteOriginal(DiagnosticsEngine &Diag, - StringRef outputDir = StringRef()); - - void remap(StringRef filePath, std::unique_ptr<llvm::MemoryBuffer> memBuf); - - void applyMappings(PreprocessorOptions &PPOpts) const; - - void clear(StringRef outputDir = StringRef()); - -private: - void remap(const FileEntry *file, std::unique_ptr<llvm::MemoryBuffer> memBuf); - void remap(const FileEntry *file, const FileEntry *newfile); - - const FileEntry *getOriginalFile(StringRef filePath); - void resetTarget(Target &targ); - - bool report(const Twine &err, DiagnosticsEngine &Diag); - - std::string getRemapInfoFile(StringRef outputDir); -}; - -} // end namespace arcmt - -} // end namespace clang - -#endif |