[cfe-commits] r88743 - in /cfe/trunk: include/clang/Frontend/CompilerInstance.h lib/Frontend/CompilerInstance.cpp

Daniel Dunbar daniel at zuster.org
Fri Nov 13 18:47:18 PST 2009


Author: ddunbar
Date: Fri Nov 13 20:47:17 2009
New Revision: 88743

URL: http://llvm.org/viewvc/llvm-project?rev=88743&view=rev
Log:
Add ASTConsumer to CompilerInstance.

Modified:
    cfe/trunk/include/clang/Frontend/CompilerInstance.h
    cfe/trunk/lib/Frontend/CompilerInstance.cpp

Modified: cfe/trunk/include/clang/Frontend/CompilerInstance.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CompilerInstance.h?rev=88743&r1=88742&r2=88743&view=diff

==============================================================================
--- cfe/trunk/include/clang/Frontend/CompilerInstance.h (original)
+++ cfe/trunk/include/clang/Frontend/CompilerInstance.h Fri Nov 13 20:47:17 2009
@@ -25,6 +25,7 @@
 
 namespace clang {
 class ASTContext;
+class ASTConsumer;
 class CodeCompleteConsumer;
 class Diagnostic;
 class DiagnosticClient;
@@ -82,6 +83,9 @@
   /// 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 @@
   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
   /// {
 

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=88743&r1=88742&r2=88743&view=diff

==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Fri Nov 13 20:47:17 2009
@@ -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 @@
   Context.reset(Value);
 }
 
+void CompilerInstance::setASTConsumer(ASTConsumer *Value) {
+  Consumer.reset(Value);
+}
+
 void CompilerInstance::setCodeCompletionConsumer(CodeCompleteConsumer *Value) {
   CompletionConsumer.reset(Value);
 }





More information about the cfe-commits mailing list