diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-01-20 16:28:04 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-01-20 16:28:04 +0000 |
commit | 1f6b2b5c82b2d2d3935b0db76352a04e9877b73f (patch) | |
tree | 3e13bde8bfb2c3bab74a8c5062361b750429dee6 /include/clang | |
parent | b7ff74a6764ad837ce348bc7dd0f0804e4dbf492 (diff) |
Extract the (InputKind, std::string) pair used to describe inputs to
the front end into its own class, FrontendInputFile, to make it easier
to introduce new per-input data. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148546 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang')
-rw-r--r-- | include/clang/ARCMigrate/ARCMT.h | 6 | ||||
-rw-r--r-- | include/clang/Frontend/FrontendAction.h | 46 | ||||
-rw-r--r-- | include/clang/Frontend/FrontendOptions.h | 34 |
3 files changed, 49 insertions, 37 deletions
diff --git a/include/clang/ARCMigrate/ARCMT.h b/include/clang/ARCMigrate/ARCMT.h index 48c5130f88..b05dd4c95d 100644 --- a/include/clang/ARCMigrate/ARCMT.h +++ b/include/clang/ARCMigrate/ARCMT.h @@ -37,7 +37,7 @@ namespace arcmt { /// /// \returns false if no error is produced, true otherwise. bool checkForManualIssues(CompilerInvocation &CI, - StringRef Filename, InputKind Kind, + const FrontendInputFile &Input, DiagnosticConsumer *DiagClient, bool emitPremigrationARCErrors = false, StringRef plistOut = StringRef()); @@ -47,7 +47,7 @@ bool checkForManualIssues(CompilerInvocation &CI, /// /// \returns false if no error is produced, true otherwise. bool applyTransformations(CompilerInvocation &origCI, - StringRef Filename, InputKind Kind, + const FrontendInputFile &Input, DiagnosticConsumer *DiagClient); /// \brief Applies automatic modifications and produces temporary files @@ -62,7 +62,7 @@ bool applyTransformations(CompilerInvocation &origCI, /// /// \returns false if no error is produced, true otherwise. bool migrateWithTemporaryFiles(CompilerInvocation &origCI, - StringRef Filename, InputKind Kind, + const FrontendInputFile &Input, DiagnosticConsumer *DiagClient, StringRef outputDir, bool emitPremigrationARCErrors, diff --git a/include/clang/Frontend/FrontendAction.h b/include/clang/Frontend/FrontendAction.h index b6ef9a5ed3..041c1d3afc 100644 --- a/include/clang/Frontend/FrontendAction.h +++ b/include/clang/Frontend/FrontendAction.h @@ -12,6 +12,7 @@ #include "clang/Basic/LLVM.h" #include "clang/Basic/LangOptions.h" +#include "clang/Frontend/FrontendOptions.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/OwningPtr.h" #include <string> @@ -23,29 +24,10 @@ class ASTMergeAction; class ASTUnit; class CompilerInstance; -enum InputKind { - IK_None, - IK_Asm, - IK_C, - IK_CXX, - IK_ObjC, - IK_ObjCXX, - IK_PreprocessedC, - IK_PreprocessedCXX, - IK_PreprocessedObjC, - IK_PreprocessedObjCXX, - IK_OpenCL, - IK_CUDA, - IK_AST, - IK_LLVM_IR -}; - - /// FrontendAction - Abstract base class for actions which can be performed by /// the frontend. class FrontendAction { - std::string CurrentFile; - InputKind CurrentFileKind; + FrontendInputFile CurrentInput; llvm::OwningPtr<ASTUnit> CurrentASTUnit; CompilerInstance *Instance; friend class ASTMergeAction; @@ -127,18 +109,22 @@ public: /// @{ bool isCurrentFileAST() const { - assert(!CurrentFile.empty() && "No current file!"); + assert(!CurrentInput.File.empty() && "No current file!"); return CurrentASTUnit != 0; } + const FrontendInputFile &getCurrentInput() const { + return CurrentInput; + } + const std::string &getCurrentFile() const { - assert(!CurrentFile.empty() && "No current file!"); - return CurrentFile; + assert(!CurrentInput.File.empty() && "No current file!"); + return CurrentInput.File; } InputKind getCurrentFileKind() const { - assert(!CurrentFile.empty() && "No current file!"); - return CurrentFileKind; + assert(!CurrentInput.File.empty() && "No current file!"); + return CurrentInput.Kind; } ASTUnit &getCurrentASTUnit() const { @@ -150,7 +136,7 @@ public: return CurrentASTUnit.take(); } - void setCurrentFile(StringRef Value, InputKind Kind, ASTUnit *AST = 0); + void setCurrentInput(const FrontendInputFile &CurrentInput, ASTUnit *AST = 0); /// @} /// @name Supported Modes @@ -189,10 +175,7 @@ public: /// action may store and use this object up until the matching EndSourceFile /// action. /// - /// \param Filename - The input filename, which will be made available to - /// clients via \see getCurrentFile(). - /// - /// \param InputKind - The type of input. Some input kinds are handled + /// \param Input - The input filename and kind. Some input kinds are handled /// specially, for example AST inputs, since the AST file itself contains /// several objects which would normally be owned by the /// CompilerInstance. When processing AST input files, these objects should @@ -202,8 +185,7 @@ public: /// /// \return True on success; the compilation of this file should be aborted /// and neither Execute nor EndSourceFile should be called. - bool BeginSourceFile(CompilerInstance &CI, StringRef Filename, - InputKind Kind); + bool BeginSourceFile(CompilerInstance &CI, const FrontendInputFile &Input); /// Execute - Set the source managers main input file, and run the action. void Execute(); diff --git a/include/clang/Frontend/FrontendOptions.h b/include/clang/Frontend/FrontendOptions.h index fa6d044ce0..637ceff578 100644 --- a/include/clang/Frontend/FrontendOptions.h +++ b/include/clang/Frontend/FrontendOptions.h @@ -11,7 +11,6 @@ #define LLVM_CLANG_FRONTEND_FRONTENDOPTIONS_H #include "clang/Frontend/CommandLineSourceLoc.h" -#include "clang/Frontend/FrontendAction.h" #include "llvm/ADT/StringRef.h" #include <string> #include <vector> @@ -51,6 +50,37 @@ namespace frontend { }; } +enum InputKind { + IK_None, + IK_Asm, + IK_C, + IK_CXX, + IK_ObjC, + IK_ObjCXX, + IK_PreprocessedC, + IK_PreprocessedCXX, + IK_PreprocessedObjC, + IK_PreprocessedObjCXX, + IK_OpenCL, + IK_CUDA, + IK_AST, + IK_LLVM_IR +}; + + +/// \brief An input file for the front end. +struct FrontendInputFile { + /// \brief The file name, or "-" to read from standard input. + std::string File; + + /// \brief The kind of input, e.g., C source, AST file, LLVM IR. + InputKind Kind; + + FrontendInputFile() : Kind(IK_None) { } + FrontendInputFile(StringRef File, InputKind Kind) + : File(File.str()), Kind(Kind) { } +}; + /// FrontendOptions - Options for controlling the behavior of the frontend. class FrontendOptions { public: @@ -86,7 +116,7 @@ public: std::string ARCMTMigrateReportOut; /// The input files and their types. - std::vector<std::pair<InputKind, std::string> > Inputs; + std::vector<FrontendInputFile> Inputs; /// The output file, if any. std::string OutputFile; |