summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/Frontend/CompilerInstance.h23
-rw-r--r--clang/lib/Frontend/CompilerInstance.cpp5
2 files changed, 28 insertions, 0 deletions
diff --git a/clang/include/clang/Frontend/CompilerInstance.h b/clang/include/clang/Frontend/CompilerInstance.h
index ee0c3c02f20..5e347061ccd 100644
--- a/clang/include/clang/Frontend/CompilerInstance.h
+++ b/clang/include/clang/Frontend/CompilerInstance.h
@@ -25,6 +25,7 @@ class raw_fd_ostream;
namespace clang {
class ASTContext;
+class ASTConsumer;
class CodeCompleteConsumer;
class Diagnostic;
class DiagnosticClient;
@@ -82,6 +83,9 @@ class CompilerInstance {
/// The AST context.
llvm::OwningPtr<ASTContext> Context;
+ /// The AST consumer.
+ llvm::OwningPtr<ASTConsumer> Consumer;
+
/// The code completion consumer.
llvm::OwningPtr<CodeCompleteConsumer> CompletionConsumer;
@@ -312,6 +316,25 @@ public:
void setASTContext(ASTContext *Value);
/// }
+ /// @name ASTConsumer
+ /// {
+
+ bool hasASTConsumer() const { return Consumer != 0; }
+
+ ASTConsumer &getASTConsumer() const {
+ assert(Consumer && "Compiler instance has no AST consumer!");
+ return *Consumer;
+ }
+
+ /// takeASTConsumer - Remove the current AST consumer and give ownership to
+ /// the caller.
+ ASTConsumer *takeASTConsumer() { return Consumer.take(); }
+
+ /// setASTConsumer - Replace the current AST consumer; the compiler instance
+ /// takes ownership of \arg Value.
+ void setASTConsumer(ASTConsumer *Value);
+
+ /// }
/// @name Code Completion
/// {
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index 2755a5a56d9..0352c454604 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
#include "clang/Frontend/CompilerInstance.h"
+#include "clang/AST/ASTConsumer.h"
#include "clang/AST/ASTContext.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/FileManager.h"
@@ -67,6 +68,10 @@ void CompilerInstance::setASTContext(ASTContext *Value) {
Context.reset(Value);
}
+void CompilerInstance::setASTConsumer(ASTConsumer *Value) {
+ Consumer.reset(Value);
+}
+
void CompilerInstance::setCodeCompletionConsumer(CodeCompleteConsumer *Value) {
CompletionConsumer.reset(Value);
}
OpenPOWER on IntegriCloud