]> granicus.if.org Git - clang/commitdiff
Add ASTConsumer to CompilerInstance.
authorDaniel Dunbar <daniel@zuster.org>
Sat, 14 Nov 2009 02:47:17 +0000 (02:47 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Sat, 14 Nov 2009 02:47:17 +0000 (02:47 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88743 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Frontend/CompilerInstance.h
lib/Frontend/CompilerInstance.cpp

index ee0c3c02f20bf7d550f370e26a4a4c3ed7af5455..5e347061ccd7c7ffa5e4c76b4ab903585c4cec0f 100644 (file)
@@ -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;
 
@@ -311,6 +315,25 @@ public:
   /// takes ownership of \arg Value.
   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
   /// {
index 2755a5a56d966deb45cdfcd9ca68314a1d63aadb..0352c4546045320751e7335c5435e1e65f8ea00a 100644 (file)
@@ -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);
 }