[cfe-commits] r38935 - in /cfe/cfe/trunk: AST/ASTStreamer.cpp Driver/clang.cpp Makefile Sema/ASTStreamer.cpp clang.xcodeproj/project.pbxproj include/clang/AST/AST.h include/clang/AST/ASTStreamer.h include/clang/AST/Decl.h include/clang/Sema/ include/clang/Sema/ASTStreamer.h

sabre at cs.uiuc.edu sabre at cs.uiuc.edu
Wed Jul 11 09:25:58 PDT 2007


Author: sabre
Date: Wed Jul 11 11:25:57 2007
New Revision: 38935

URL: http://llvm.org/viewvc/llvm-project?rev=38935&view=rev
Log:
Stub out the ASTStreamer

Added:
    cfe/cfe/trunk/AST/ASTStreamer.cpp   (with props)
    cfe/cfe/trunk/Sema/ASTStreamer.cpp   (with props)
    cfe/cfe/trunk/include/clang/AST/ASTStreamer.h   (with props)
    cfe/cfe/trunk/include/clang/Sema/
    cfe/cfe/trunk/include/clang/Sema/ASTStreamer.h   (with props)
Modified:
    cfe/cfe/trunk/Driver/clang.cpp
    cfe/cfe/trunk/Makefile
    cfe/cfe/trunk/clang.xcodeproj/project.pbxproj
    cfe/cfe/trunk/include/clang/AST/AST.h
    cfe/cfe/trunk/include/clang/AST/Decl.h

Added: cfe/cfe/trunk/AST/ASTStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/ASTStreamer.cpp?rev=38935&view=auto

==============================================================================
--- cfe/cfe/trunk/AST/ASTStreamer.cpp (added)
+++ cfe/cfe/trunk/AST/ASTStreamer.cpp Wed Jul 11 11:25:57 2007
@@ -0,0 +1,67 @@
+//===--- ASTStreamer.cpp - Provide streaming interface to ASTs ------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file was developed by Chris Lattner and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements the ASTStreamer interface.
+//
+//===----------------------------------------------------------------------===//
+
+#include "clang/AST/ASTStreamer.h"
+#include "clang/Parse/Action.h"
+#include "clang/Parse/Parser.h"
+
+using namespace llvm;
+using namespace clang;
+
+
+
+
+namespace {
+  class ASTStreamer {
+    EmptyAction Builder;
+    Parser P;
+  public:
+    ASTStreamer(Preprocessor &PP, unsigned MainFileID)
+      : P(PP, Builder) {
+      PP.EnterSourceFile(MainFileID, 0, true);
+      
+      // Parsing the specified input file.
+      P.ParseTranslationUnit();
+    }
+    
+    /// ReadTopLevelDecl - Parse and return the next top-level declaration.
+    Decl *ReadTopLevelDecl() {
+      return 0;
+    }
+  };
+}
+
+
+
+//===----------------------------------------------------------------------===//
+// Public interface to the file
+//===----------------------------------------------------------------------===//
+
+/// ASTStreamer_Init - Create an ASTStreamer with the specified preprocessor
+/// and FileID.
+ASTStreamerTy *llvm::clang::ASTStreamer_Init(Preprocessor &PP, 
+                                             unsigned MainFileID) {
+  return new ASTStreamer(PP, MainFileID);
+}
+
+/// ASTStreamer_ReadTopLevelDecl - Parse and return one top-level declaration. This
+/// returns null at end of file.
+Decl *llvm::clang::ASTStreamer_ReadTopLevelDecl(ASTStreamerTy *Streamer) {
+  return static_cast<ASTStreamer*>(Streamer)->ReadTopLevelDecl();
+}
+
+/// ASTStreamer_Terminate - Gracefully shut down the streamer.
+///
+void llvm::clang::ASTStreamer_Terminate(ASTStreamerTy *Streamer) {
+  delete static_cast<ASTStreamer*>(Streamer);
+}

Propchange: cfe/cfe/trunk/AST/ASTStreamer.cpp

------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cfe/cfe/trunk/AST/ASTStreamer.cpp

------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: cfe/cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Driver/clang.cpp?rev=38935&r1=38934&r2=38935&view=diff

==============================================================================
--- cfe/cfe/trunk/Driver/clang.cpp (original)
+++ cfe/cfe/trunk/Driver/clang.cpp Wed Jul 11 11:25:57 2007
@@ -616,20 +616,30 @@
 }
 
 //===----------------------------------------------------------------------===//
-// Parser driver
+// Basic Parser driver
 //===----------------------------------------------------------------------===//
 
 static void ParseFile(Preprocessor &PP, Action *PA, unsigned MainFileID) {
   Parser P(PP, *PA);
-
   PP.EnterSourceFile(MainFileID, 0, true);
   
+  // Parsing the specified input file.
   P.ParseTranslationUnit();
+  delete PA;
+}
 
-  // Start parsing the specified input file.
+//===----------------------------------------------------------------------===//
+// ASTStreamer drivers
+//===----------------------------------------------------------------------===//
 
+static void PrintASTs(Preprocessor &PP, unsigned MainFileID) {
+  ASTStreamerTy *Streamer = ASTStreamer_Init(PP, MainFileID);
   
-  delete PA;
+  while (Decl *D = ASTStreamer_ReadTopLevelDecl(Streamer)) {
+    std::cerr << "Read decl!\n";
+  }
+  
+  ASTStreamer_Terminate(Streamer);
 }
 
 //===----------------------------------------------------------------------===//
@@ -757,7 +767,7 @@
     ParseFile(PP, CreatePrintParserActionsAction(), MainFileID);
     break;
   case ParsePrintASTs:
-    // 
+    PrintASTs(PP, MainFileID);
     break;
   case ParseSyntaxOnly:              // -fsyntax-only
     ParseFile(PP, new EmptyAction(), MainFileID);

Modified: cfe/cfe/trunk/Makefile
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Makefile?rev=38935&r1=38934&r2=38935&view=diff

==============================================================================
--- cfe/cfe/trunk/Makefile (original)
+++ cfe/cfe/trunk/Makefile Wed Jul 11 11:25:57 2007
@@ -6,6 +6,6 @@
 
 TOOLNAME = clang
 
-USEDLIBS = clangParse.a clangLex.a clangBasic.a LLVMSupport.a LLVMSystem.a
+USEDLIBS = clangAST.a clangParse.a clangLex.a clangBasic.a LLVMSupport.a LLVMSystem.a
 
 include $(LEVEL)/Makefile.common

Added: cfe/cfe/trunk/Sema/ASTStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Sema/ASTStreamer.cpp?rev=38935&view=auto

==============================================================================
--- cfe/cfe/trunk/Sema/ASTStreamer.cpp (added)
+++ cfe/cfe/trunk/Sema/ASTStreamer.cpp Wed Jul 11 11:25:57 2007
@@ -0,0 +1,67 @@
+//===--- ASTStreamer.cpp - Provide streaming interface to ASTs ------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file was developed by Chris Lattner and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements the ASTStreamer interface.
+//
+//===----------------------------------------------------------------------===//
+
+#include "clang/AST/ASTStreamer.h"
+#include "clang/Parse/Action.h"
+#include "clang/Parse/Parser.h"
+
+using namespace llvm;
+using namespace clang;
+
+
+
+
+namespace {
+  class ASTStreamer {
+    EmptyAction Builder;
+    Parser P;
+  public:
+    ASTStreamer(Preprocessor &PP, unsigned MainFileID)
+      : P(PP, Builder) {
+      PP.EnterSourceFile(MainFileID, 0, true);
+      
+      // Parsing the specified input file.
+      P.ParseTranslationUnit();
+    }
+    
+    /// ReadTopLevelDecl - Parse and return the next top-level declaration.
+    Decl *ReadTopLevelDecl() {
+      return 0;
+    }
+  };
+}
+
+
+
+//===----------------------------------------------------------------------===//
+// Public interface to the file
+//===----------------------------------------------------------------------===//
+
+/// ASTStreamer_Init - Create an ASTStreamer with the specified preprocessor
+/// and FileID.
+ASTStreamerTy *llvm::clang::ASTStreamer_Init(Preprocessor &PP, 
+                                             unsigned MainFileID) {
+  return new ASTStreamer(PP, MainFileID);
+}
+
+/// ASTStreamer_ReadTopLevelDecl - Parse and return one top-level declaration. This
+/// returns null at end of file.
+Decl *llvm::clang::ASTStreamer_ReadTopLevelDecl(ASTStreamerTy *Streamer) {
+  return static_cast<ASTStreamer*>(Streamer)->ReadTopLevelDecl();
+}
+
+/// ASTStreamer_Terminate - Gracefully shut down the streamer.
+///
+void llvm::clang::ASTStreamer_Terminate(ASTStreamerTy *Streamer) {
+  delete static_cast<ASTStreamer*>(Streamer);
+}

Propchange: cfe/cfe/trunk/Sema/ASTStreamer.cpp

------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cfe/cfe/trunk/Sema/ASTStreamer.cpp

------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: cfe/cfe/trunk/clang.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/clang.xcodeproj/project.pbxproj?rev=38935&r1=38934&r2=38935&view=diff

==============================================================================
--- cfe/cfe/trunk/clang.xcodeproj/project.pbxproj (original)
+++ cfe/cfe/trunk/clang.xcodeproj/project.pbxproj Wed Jul 11 11:25:57 2007
@@ -27,6 +27,8 @@
 		DEC8D9A40A94346E00353FCA /* AST.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DEC8D9A30A94346E00353FCA /* AST.h */; };
 		DEC8D9B60A9434FA00353FCA /* Builder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DEC8D9B50A9434FA00353FCA /* Builder.cpp */; };
 		DEC8DA1E0A94388B00353FCA /* PrintParserCallbacks.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DEC8DA1D0A94388B00353FCA /* PrintParserCallbacks.cpp */; };
+		DEC8DAAD0A94400300353FCA /* ASTStreamer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DEC8DAAC0A94400300353FCA /* ASTStreamer.cpp */; };
+		DEC8DAC00A94402500353FCA /* ASTStreamer.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DEC8DABF0A94402500353FCA /* ASTStreamer.h */; };
 		DED7D72D0A524281003AD0FB /* clang.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DED7D72C0A524281003AD0FB /* clang.cpp */; };
 		DED7D7410A524295003AD0FB /* Diagnostic.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DED7D7310A524295003AD0FB /* Diagnostic.h */; };
 		DED7D7420A524295003AD0FB /* DiagnosticKinds.def in CopyFiles */ = {isa = PBXBuildFile; fileRef = DED7D7320A524295003AD0FB /* DiagnosticKinds.def */; };
@@ -109,6 +111,7 @@
 				DE06E8140A8FF9330050E87E /* Action.h in CopyFiles */,
 				DEC8D9910A9433CD00353FCA /* Decl.h in CopyFiles */,
 				DEC8D9A40A94346E00353FCA /* AST.h in CopyFiles */,
+				DEC8DAC00A94402500353FCA /* ASTStreamer.h in CopyFiles */,
 			);
 			runOnlyForDeploymentPostprocessing = 1;
 		};
@@ -136,6 +139,8 @@
 		DEC8D9A30A94346E00353FCA /* AST.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = AST.h; path = clang/AST/AST.h; sourceTree = "<group>"; };
 		DEC8D9B50A9434FA00353FCA /* Builder.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = Builder.cpp; path = AST/Builder.cpp; sourceTree = "<group>"; };
 		DEC8DA1D0A94388B00353FCA /* PrintParserCallbacks.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = PrintParserCallbacks.cpp; sourceTree = "<group>"; };
+		DEC8DAAC0A94400300353FCA /* ASTStreamer.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = ASTStreamer.cpp; path = AST/ASTStreamer.cpp; sourceTree = "<group>"; };
+		DEC8DABF0A94402500353FCA /* ASTStreamer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = ASTStreamer.h; path = clang/AST/ASTStreamer.h; sourceTree = "<group>"; };
 		DED7D72C0A524281003AD0FB /* clang.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = clang.cpp; sourceTree = "<group>"; };
 		DED7D7310A524295003AD0FB /* Diagnostic.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Diagnostic.h; sourceTree = "<group>"; };
 		DED7D7320A524295003AD0FB /* DiagnosticKinds.def */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = DiagnosticKinds.def; sourceTree = "<group>"; };
@@ -260,6 +265,7 @@
 			isa = PBXGroup;
 			children = (
 				DEC8D9A30A94346E00353FCA /* AST.h */,
+				DEC8DABF0A94402500353FCA /* ASTStreamer.h */,
 				DEC8D9900A9433CD00353FCA /* Decl.h */,
 			);
 			name = AST;
@@ -268,6 +274,7 @@
 		DEC8D9920A9433F400353FCA /* AST */ = {
 			isa = PBXGroup;
 			children = (
+				DEC8DAAC0A94400300353FCA /* ASTStreamer.cpp */,
 				DEC8D9B50A9434FA00353FCA /* Builder.cpp */,
 			);
 			name = AST;
@@ -418,6 +425,7 @@
 				DE06E4D70A8FBF7A0050E87E /* Initializer.cpp in Sources */,
 				DEC8D9B60A9434FA00353FCA /* Builder.cpp in Sources */,
 				DEC8DA1E0A94388B00353FCA /* PrintParserCallbacks.cpp in Sources */,
+				DEC8DAAD0A94400300353FCA /* ASTStreamer.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Modified: cfe/cfe/trunk/include/clang/AST/AST.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/AST/AST.h?rev=38935&r1=38934&r2=38935&view=diff

==============================================================================
--- cfe/cfe/trunk/include/clang/AST/AST.h (original)
+++ cfe/cfe/trunk/include/clang/AST/AST.h Wed Jul 11 11:25:57 2007
@@ -14,14 +14,8 @@
 #ifndef LLVM_CLANG_AST_AST_H
 #define LLVM_CLANG_AST_AST_H
 
-namespace llvm {
-namespace clang {
-  
-  class Action;
-  
-  
-
-}  // end namespace clang
-}  // end namespace llvm
+// This header exports all AST interfaces.
+#include "clang/AST/ASTStreamer.h"
+#include "clang/AST/Decl.h"
 
 #endif

Added: cfe/cfe/trunk/include/clang/AST/ASTStreamer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/AST/ASTStreamer.h?rev=38935&view=auto

==============================================================================
--- cfe/cfe/trunk/include/clang/AST/ASTStreamer.h (added)
+++ cfe/cfe/trunk/include/clang/AST/ASTStreamer.h Wed Jul 11 11:25:57 2007
@@ -0,0 +1,41 @@
+//===--- AST.h - "Umbrella" header for AST library --------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file was developed by Chris Lattner and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+//  This file defines the ASTStreamer interface.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_AST_ASTSTREAMER_H
+#define LLVM_CLANG_AST_ASTSTREAMER_H
+
+namespace llvm {
+namespace clang {
+  class Preprocessor;
+  class Decl;
+  
+  /// ASTStreamerTy - This is an opaque type used to reference ASTStreamer
+  /// objects.
+  typedef void ASTStreamerTy;
+  
+  /// ASTStreamer_Init - Create an ASTStreamer with the specified preprocessor
+  /// and FileID.
+  ASTStreamerTy *ASTStreamer_Init(Preprocessor &PP, unsigned MainFileID);
+  
+  /// ASTStreamer_ReadTopLevelDecl - Parse and return one top-level declaration. This
+  /// returns null at end of file.
+  Decl *ASTStreamer_ReadTopLevelDecl(ASTStreamerTy *Streamer);
+  
+  /// ASTStreamer_Terminate - Gracefully shut down the streamer.
+  ///
+  void ASTStreamer_Terminate(ASTStreamerTy *Streamer);
+  
+}  // end namespace clang
+}  // end namespace llvm
+
+#endif
\ No newline at end of file

Propchange: cfe/cfe/trunk/include/clang/AST/ASTStreamer.h

------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cfe/cfe/trunk/include/clang/AST/ASTStreamer.h

------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: cfe/cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/AST/Decl.h?rev=38935&r1=38934&r2=38935&view=diff

==============================================================================
--- cfe/cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/cfe/trunk/include/clang/AST/Decl.h Wed Jul 11 11:25:57 2007
@@ -14,7 +14,7 @@
 #ifndef LLVM_CLANG_AST_DECL_H
 #define LLVM_CLANG_AST_DECL_H
 
-#include "clang/ADT/SourceLocation.h"
+#include "clang/Basic/SourceLocation.h"
 
 namespace llvm {
 namespace clang {

Added: cfe/cfe/trunk/include/clang/Sema/ASTStreamer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/Sema/ASTStreamer.h?rev=38935&view=auto

==============================================================================
--- cfe/cfe/trunk/include/clang/Sema/ASTStreamer.h (added)
+++ cfe/cfe/trunk/include/clang/Sema/ASTStreamer.h Wed Jul 11 11:25:57 2007
@@ -0,0 +1,41 @@
+//===--- AST.h - "Umbrella" header for AST library --------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file was developed by Chris Lattner and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+//  This file defines the ASTStreamer interface.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_AST_ASTSTREAMER_H
+#define LLVM_CLANG_AST_ASTSTREAMER_H
+
+namespace llvm {
+namespace clang {
+  class Preprocessor;
+  class Decl;
+  
+  /// ASTStreamerTy - This is an opaque type used to reference ASTStreamer
+  /// objects.
+  typedef void ASTStreamerTy;
+  
+  /// ASTStreamer_Init - Create an ASTStreamer with the specified preprocessor
+  /// and FileID.
+  ASTStreamerTy *ASTStreamer_Init(Preprocessor &PP, unsigned MainFileID);
+  
+  /// ASTStreamer_ReadTopLevelDecl - Parse and return one top-level declaration. This
+  /// returns null at end of file.
+  Decl *ASTStreamer_ReadTopLevelDecl(ASTStreamerTy *Streamer);
+  
+  /// ASTStreamer_Terminate - Gracefully shut down the streamer.
+  ///
+  void ASTStreamer_Terminate(ASTStreamerTy *Streamer);
+  
+}  // end namespace clang
+}  // end namespace llvm
+
+#endif
\ No newline at end of file

Propchange: cfe/cfe/trunk/include/clang/Sema/ASTStreamer.h

------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cfe/cfe/trunk/include/clang/Sema/ASTStreamer.h

------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision





More information about the cfe-commits mailing list