aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-02-09 19:21:46 +0000
committerDouglas Gregor <dgregor@apple.com>2010-02-09 19:21:46 +0000
commit9bed8798964d9f07599c2c9199701f86fbc70e20 (patch)
treee8e5e9ff1371051db0b1fbda759f2de976d54a5c /include
parent8ec4aac6d3dee698e4cb7b9f540d962e4ccab468 (diff)
Introduce a testbed for merging multiple ASTs into a single AST
context with the AST importer. WIP, still useless but at least it has a test. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95683 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/clang/Driver/CC1Options.td3
-rw-r--r--include/clang/Frontend/FrontendAction.h6
-rw-r--r--include/clang/Frontend/FrontendActions.h39
-rw-r--r--include/clang/Frontend/FrontendOptions.h3
4 files changed, 51 insertions, 0 deletions
diff --git a/include/clang/Driver/CC1Options.td b/include/clang/Driver/CC1Options.td
index 23275b63ff..f0db6e7caf 100644
--- a/include/clang/Driver/CC1Options.td
+++ b/include/clang/Driver/CC1Options.td
@@ -200,6 +200,9 @@ def verify : Flag<"-verify">,
// CompilerInvocation out of a driver-derived argument vector.
def cc1 : Flag<"-cc1">;
+def ast_merge : Separate<"-ast-merge">,
+ MetaVarName<"<ast file>">,
+ HelpText<"Merge the given AST file into the translation unit being compiled.">;
def code_completion_at : Separate<"-code-completion-at">,
MetaVarName<"<file>:<line>:<column>">,
HelpText<"Dump code-completion information at a location">;
diff --git a/include/clang/Frontend/FrontendAction.h b/include/clang/Frontend/FrontendAction.h
index 29a9302c5c..7b7db3785c 100644
--- a/include/clang/Frontend/FrontendAction.h
+++ b/include/clang/Frontend/FrontendAction.h
@@ -18,6 +18,7 @@ namespace clang {
class ASTUnit;
class ASTConsumer;
class CompilerInstance;
+class ASTMergeAction;
/// FrontendAction - Abstract base class for actions which can be performed by
/// the frontend.
@@ -25,6 +26,7 @@ class FrontendAction {
std::string CurrentFile;
llvm::OwningPtr<ASTUnit> CurrentASTUnit;
CompilerInstance *Instance;
+ friend class ASTMergeAction;
protected:
/// @name Implementation Action Interface
@@ -104,6 +106,10 @@ public:
return *CurrentASTUnit;
}
+ ASTUnit *takeCurrentASTUnit() {
+ return CurrentASTUnit.take();
+ }
+
void setCurrentFile(llvm::StringRef Value, ASTUnit *AST = 0);
/// @}
diff --git a/include/clang/Frontend/FrontendActions.h b/include/clang/Frontend/FrontendActions.h
index 1eece64282..cbb3508c8a 100644
--- a/include/clang/Frontend/FrontendActions.h
+++ b/include/clang/Frontend/FrontendActions.h
@@ -11,6 +11,8 @@
#define LLVM_CLANG_FRONTEND_FRONTENDACTIONS_H
#include "clang/Frontend/FrontendAction.h"
+#include <string>
+#include <vector>
namespace clang {
class FixItRewriter;
@@ -119,6 +121,43 @@ public:
virtual bool hasCodeCompletionSupport() const { return true; }
};
+/**
+ * \brief Frontend action adaptor that merges ASTs together.
+ *
+ * This action takes an existing AST file and "merges" it into the AST
+ * context, producing a merged context. This action is an action
+ * adaptor, which forwards most of its calls to another action that
+ * will consume the merged context.
+ */
+class ASTMergeAction : public FrontendAction {
+ /// \brief The action that the merge action adapts.
+ FrontendAction *AdaptedAction;
+
+ /// \brief The set of AST files to merge.
+ std::vector<std::string> ASTFiles;
+
+protected:
+ virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
+ llvm::StringRef InFile);
+
+ virtual bool BeginSourceFileAction(CompilerInstance &CI,
+ llvm::StringRef Filename);
+
+ virtual void ExecuteAction();
+ virtual void EndSourceFileAction();
+
+public:
+ ASTMergeAction(FrontendAction *AdaptedAction,
+ std::string *ASTFiles, unsigned NumASTFiles);
+ virtual ~ASTMergeAction();
+
+ virtual bool usesPreprocessorOnly() const;
+ virtual bool usesCompleteTranslationUnit();
+ virtual bool hasPCHSupport() const;
+ virtual bool hasASTSupport() const;
+ virtual bool hasCodeCompletionSupport() const;
+};
+
//===----------------------------------------------------------------------===//
// Code Gen AST Actions
//===----------------------------------------------------------------------===//
diff --git a/include/clang/Frontend/FrontendOptions.h b/include/clang/Frontend/FrontendOptions.h
index 52f639aeb0..80ba77864a 100644
--- a/include/clang/Frontend/FrontendOptions.h
+++ b/include/clang/Frontend/FrontendOptions.h
@@ -110,6 +110,9 @@ public:
/// The list of plugins to load.
std::vector<std::string> Plugins;
+ /// \brief The list of AST files to merge.
+ std::vector<std::string> ASTMergeFiles;
+
public:
FrontendOptions() {
DebugCodeCompletionPrinter = 1;