[llvm-commits] [hlvm] r38033 - in /hlvm/trunk: autoconf/configure.ac build.sh configure docs/GettingStarted.html hlvm/Base/Memory.cpp hlvm/Base/Memory.h hlvm/Base/Source.cpp hlvm/Base/Source.h hlvm/Base/URI.cpp hlvm/Base/URI.h hlvm/Reader/Reader.h hlvm/Reader/XML/XMLReader.cpp hlvm/Reader/XML/XMLReader.h tools/hlvm-xml2xml/Makefile tools/hlvm-xml2xml/hlvm-xml2xml.cpp

Reid Spencer reid at x10sys.com
Sat Jul 7 16:59:09 PDT 2007


Author: reid
Date: Sat Jul  7 18:59:09 2007
New Revision: 38033

URL: http://llvm.org/viewvc/llvm-project?rev=38033&view=rev
Log:
Get hlvm-xml2xml to actually do something. It can now do a little bit of parsing
and geneate a skeletal XML file. This patch also solves several build and
configuration problems and documents those in the GettingStarted.html doc.

Added:
    hlvm/trunk/hlvm/Base/Memory.cpp
    hlvm/trunk/hlvm/Base/Memory.h
    hlvm/trunk/hlvm/Base/Source.cpp
    hlvm/trunk/hlvm/Base/Source.h
    hlvm/trunk/hlvm/Base/URI.cpp
    hlvm/trunk/hlvm/Base/URI.h
Modified:
    hlvm/trunk/autoconf/configure.ac
    hlvm/trunk/build.sh
    hlvm/trunk/configure
    hlvm/trunk/docs/GettingStarted.html
    hlvm/trunk/hlvm/Reader/Reader.h
    hlvm/trunk/hlvm/Reader/XML/XMLReader.cpp
    hlvm/trunk/hlvm/Reader/XML/XMLReader.h
    hlvm/trunk/tools/hlvm-xml2xml/Makefile
    hlvm/trunk/tools/hlvm-xml2xml/hlvm-xml2xml.cpp

Modified: hlvm/trunk/autoconf/configure.ac
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/autoconf/configure.ac?rev=38033&r1=38032&r2=38033&view=diff

==============================================================================
--- hlvm/trunk/autoconf/configure.ac (original)
+++ hlvm/trunk/autoconf/configure.ac Sat Jul  7 18:59:09 2007
@@ -211,18 +211,6 @@
 AC_MSG_RESULT($HLVM_WITH_WORKSPACE)
 AC_SUBST(HLVM_WITH_WORKSPACE)
 
-dnl -- with-expat: specifies the location of the expat library
-AC_MSG_CHECKING(location of expat library)
-AC_ARG_WITH(expat,
-  AS_HELP_STRING([--with-expat=<dir>],
-    [Specify where the expat lbrary is located (default=/usr/local)]),
-  [case "${withval}" in   
-     /*) HLVM_WITH_EXPAT=$withval ;;
-     *) AC_MSG_ERROR(bad value ${withval} for --with-expat) ;;
-  esac],[HLVM_WITH_EXPAT=/usr])
-AC_MSG_RESULT($HLVM_WITH_EXPAT)
-AC_SUBST(HLVM_WITH_EXPAT)
-
 dnl -- with-includes: specifies the location of additional header file dirs
 AC_MSG_CHECKING(location of additional header files)
 AC_ARG_WITH(includes,

Modified: hlvm/trunk/build.sh
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/build.sh?rev=38033&r1=38032&r2=38033&view=diff

==============================================================================
--- hlvm/trunk/build.sh (original)
+++ hlvm/trunk/build.sh Sat Jul  7 18:59:09 2007
@@ -86,9 +86,12 @@
   getDirectory "Enter path to LLVM object root" "/proj/llvm/build" 
   LLVM_OBJ="$DIR"
   
-  getDirectory "Enter path to expat libraries" "/proj/install/lib" 
+  getDirectory "Enter path to expat libraries" "/proj/install" 
   EXPAT_OBJ="$DIR"
 
+  getDirectory "Enter path to apr libraries" "/proj/install" 
+  APR_OBJ="$DIR"
+
   getDirectory "Enter path for additional header files" "/proj/install/include" 
   HEADERS="$DIR"
 
@@ -124,6 +127,7 @@
   echo "LLVM_SRC=$LLVM_SRC"
   echo "LLVM_OBJ=$LLVM_OBJ"
   echo "EXPAT_OBJ=$EXPAT_OBJ"
+  echo "APR_OBJ=$APR_OBJ"
   echo "HEADERS=$HEADERS"
   echo "LIBRARIES=$LIBRARIES"
   echo "PROGRAMS=$PROGRAMS"
@@ -149,6 +153,7 @@
   echo "LLVM_SRC=$LLVM_SRC" >> config.opts
   echo "LLVM_OBJ=$LLVM_OBJ" >> config.opts
   echo "EXPAT_OBJ=$EXPAT_OBJ" >> config.opts
+  echo "APR_OBJ=$APR_OBJ" >> config.opts
   echo "HEADERS=$HEADERS" >> config.opts
   echo "LIBRARIES=$LIBRARIES" >> config.opts
   echo "PROGRAMS=$PROGRAMS" >> config.opts
@@ -223,7 +228,9 @@
     --enable-small=${enable_SMALL} \
     --enable-efence=${enable_EFENCE} \
     --enable-profiling=${enable_PROFILING} \
-    --with-expat=${EXPAT_OBJ} \
+    --with-EXPAT=${EXPAT_OBJ} \
+    --with-APR=${APR_OBJ} \
+    --with-APRU=${APR_OBJ} \
     --with-llvm-src=${LLVM_SRC} \
     --with-llvm-obj=${LLVM_OBJ} \
     --with-workspace=${WORKSPACE} \

Modified: hlvm/trunk/configure
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/configure?rev=38033&r1=38032&r2=38033&view=diff

==============================================================================
--- hlvm/trunk/configure (original)
+++ hlvm/trunk/configure Sat Jul  7 18:59:09 2007
@@ -315,7 +315,7 @@
 # include <unistd.h>
 #endif"
 
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS HLVM_COPYRIGHT HLVM_PACKAGE HLVM_VERSION HLVM_SO_VERSION HLVM_SO_CURRENT HLVM_SO_REVISION HLVM_SO_AGE HLVM_SHAREDPREFIX HLVM_DEBUG HLVM_OPTIMIZE HLVM_INLINE HLVM_ASSERT HLVM_TRACE HLVM_SMALL HLVM_EFENCE HLVM_PROFILING HLVM_WITH_WORKSPACE HLVM_WITH_EXPAT HLVM_WITH_INCLUDES HLVM_WITH_LLVM_SRC HLVM_WITH_LLVM_OBJ HLVM_WITH_LLVMGCC CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP CXX CXXFLAGS ac_ct_CXX ifGNUmake apr_INC apr_LIB apru_INC apru_LIB expat_INC expat_LIB syck_INC syck_LIB EGREP HLVM_CFGNAME HLVM_CONFIGTIME HLVM_PREFIX LIBOBJS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS HLVM_COPYRIGHT HLVM_PACKAGE HLVM_VERSION HLVM_SO_VERSION HLVM_SO_CURRENT HLVM_SO_REVISION HLVM_SO_AGE HLVM_SHAREDPREFIX HLVM_DEBUG HLVM_OPTIMIZE HLVM_INLINE HLVM_ASSERT HLVM_TRACE HLVM_SMALL HLVM_EFENCE HLVM_PROFILING HLVM_WITH_WORKSPACE HLVM_WITH_INCLUDES HLVM_WITH_LLVM_SRC HLVM_WITH_LLVM_OBJ HLVM_WITH_LLVMGCC CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP CXX CXXFLAGS ac_ct_CXX ifGNUmake apr_INC apr_LIB apru_INC apru_LIB expat_INC expat_LIB syck_INC syck_LIB EGREP HLVM_CFGNAME HLVM_CONFIGTIME HLVM_PREFIX LIBOBJS LTLIBOBJS'
 ac_subst_files=''
 
 # Initialize some variables set by options.
@@ -875,8 +875,6 @@
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
   --with-workspace=<dir>  dir=location of the HLVM workspace storage
                           (default=/opt/hlvm)
-  --with-expat=<dir>      Specify where the expat lbrary is located
-                          (default=/usr/local)
   --with-includes=-I<dir>...
                           Specify additional header file directories
                           (efault=none)
@@ -1590,25 +1588,6 @@
 echo "${ECHO_T}$HLVM_WITH_WORKSPACE" >&6
 
 
-echo "$as_me:$LINENO: checking location of expat library" >&5
-echo $ECHO_N "checking location of expat library... $ECHO_C" >&6
-
-# Check whether --with-expat or --without-expat was given.
-if test "${with_expat+set}" = set; then
-  withval="$with_expat"
-  case "${withval}" in
-     /*) HLVM_WITH_EXPAT=$withval ;;
-     *) { { echo "$as_me:$LINENO: error: bad value ${withval} for --with-expat" >&5
-echo "$as_me: error: bad value ${withval} for --with-expat" >&2;}
-   { (exit 1); exit 1; }; } ;;
-  esac
-else
-  HLVM_WITH_EXPAT=/usr
-fi;
-echo "$as_me:$LINENO: result: $HLVM_WITH_EXPAT" >&5
-echo "${ECHO_T}$HLVM_WITH_EXPAT" >&6
-
-
 echo "$as_me:$LINENO: checking location of additional header files" >&5
 echo $ECHO_N "checking location of additional header files... $ECHO_C" >&6
 
@@ -7014,7 +6993,6 @@
 s, at HLVM_EFENCE@,$HLVM_EFENCE,;t t
 s, at HLVM_PROFILING@,$HLVM_PROFILING,;t t
 s, at HLVM_WITH_WORKSPACE@,$HLVM_WITH_WORKSPACE,;t t
-s, at HLVM_WITH_EXPAT@,$HLVM_WITH_EXPAT,;t t
 s, at HLVM_WITH_INCLUDES@,$HLVM_WITH_INCLUDES,;t t
 s, at HLVM_WITH_LLVM_SRC@,$HLVM_WITH_LLVM_SRC,;t t
 s, at HLVM_WITH_LLVM_OBJ@,$HLVM_WITH_LLVM_OBJ,;t t

Modified: hlvm/trunk/docs/GettingStarted.html
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/docs/GettingStarted.html?rev=38033&r1=38032&r2=38033&view=diff

==============================================================================
--- hlvm/trunk/docs/GettingStarted.html (original)
+++ hlvm/trunk/docs/GettingStarted.html Sat Jul  7 18:59:09 2007
@@ -18,6 +18,7 @@
       <li><a href="#software">Software</a>
     </ol>
   </li>
+  <li><a href="#other_packages">Building Other Packages</a></li>
 </ol>
 
 <div class="author">
@@ -284,5 +285,35 @@
     <li><b>zip*</b> - zip command for distribution generation</li>
   </ul>
 </div>
+
+<!-- *********************************************************************** -->
+<div class="section"><a name="other_packages">Building Other Packages</a></div>
+<!-- *********************************************************************** -->
+<div class="text">
+  <h2>Separate Install Area</h2>
+  <p>It is suggested that you keep a separate installation area for building the
+  things that HLVM depends upon. This is the location in your file system where
+  you will install the built packages. It is used with the <tt>--prefix</tt>
+  option to the configure programs of the packages. By using a separate install
+  area, you ensure that the HLVM version of required packages doesn't interfere
+  with any of your system installed packages.</p>
+  <h2>expat</h2>
+  <ul>
+    <li>Always build expat first. It doesn't depend on anything else</li>
+    <li>Use version 2.0 or later</li>
+  </ul>
+  <h2>apr</h2>
+  <ul>
+    <li>Optionally use the <tt>--enable-debug</tt> configure flag.</li>
+    <li>Required to use the <tt>--enable-threads</tt> configure flag.</li>
+    <li>Required to use the <tt>--enable-other-child</tt> configure flag.</li>
+  </ul>
+  <h2>apr-util</h2>
+  <ul>
+    <li>APR Utils depends on expat and so does HLVM. They must use the same
+    version or HLVM tools will not link properly. To ensure this, always provide
+    the apr-util configure script with <tt>--with-expat=/your/install</tt></li>
+  </ul>
+</div>
 </body>
 </html>

Added: hlvm/trunk/hlvm/Base/Memory.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Base/Memory.cpp?rev=38033&view=auto

==============================================================================
--- hlvm/trunk/hlvm/Base/Memory.cpp (added)
+++ hlvm/trunk/hlvm/Base/Memory.cpp Sat Jul  7 18:59:09 2007
@@ -0,0 +1,165 @@
+//===-- hlvm/Base/Memory.h - HLVM Memory Facilities -------------*- C++ -*-===//
+//
+//                      High Level Virtual Machine (HLVM)
+//
+// Copyright (C) 2006 Reid Spencer. All Rights Reserved.
+//
+// This software is free software; you can redistribute it and/or modify it 
+// under the terms of the GNU Lesser General Public License as published by 
+// the Free Software Foundation; either version 2.1 of the License, or (at 
+// your option) any later version.
+//
+// This software is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+// FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for 
+// more details.
+//
+// You should have received a copy of the GNU Lesser General Public License 
+// along with this library in the file named LICENSE.txt; if not, write to the 
+// Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+// MA 02110-1301 USA
+//
+//===----------------------------------------------------------------------===//
+/// @file hlvm/Base/Memory.h
+/// @author Reid Spencer <rspencer at reidspencer.com> (original author)
+/// @date 2006/05/04
+/// @since 0.1.0
+/// @brief Declares the HLVM Memory Facilities
+//===----------------------------------------------------------------------===//
+
+#include <hlvm/Base/Memory.h>
+#include <llvm/System/Signals.h>
+#include <memory>
+#include <new>
+#include <iostream>
+#include <cassert>
+
+namespace hlvm { namespace Base {
+
+// The following provides a 64KByte emergency memory reserve for the program 
+// heap.  Application writers are encouraged to use the memory facilities 
+// provided in this module but XPS itself can utilize the heap with  
+// malloc/free and new/delete.  This memory reserve helps to avoid situations 
+// where new/delete might fail.
+
+static char * _memory_reserve = 0;
+
+static void
+the_new_handler( void )
+{
+  if ( _memory_reserve )
+  {
+    delete [] _memory_reserve;
+    _memory_reserve = 0;
+  }
+  else
+  {
+    assert( _memory_reserve != 0 && "No memory!");
+  }
+}
+
+static void
+the_unexpected_handler( void )
+{
+  assert(!"Unexpected Handler.");
+}
+
+static void
+the_terminate_handler( void )
+{
+  assert(!"Terminate Handler.");
+}
+
+static void
+ensure_emergency_reserve( void )
+{
+  if ( _memory_reserve == 0 )
+  {
+    _memory_reserve = ::new char [ 64 * 1024 ];
+  }
+}
+
+bool
+memory_is_low( void )
+{
+  return _memory_reserve == 0;
+}
+
+apr_pool_t* POOL = 0;
+
+static bool initialized = false;
+void
+initialize(int& /*argc*/, char** /*argv*/)
+{
+  if ( ! initialized )
+  {
+    try
+    {
+      // Reserve memory for emergencies
+      ensure_emergency_reserve();
+
+      // Specify the new_handler for C++ memory allocation
+      std::set_new_handler( the_new_handler );
+
+      // Specify the unexpected handler for unexpected C++ exceptions
+      std::set_unexpected( the_unexpected_handler );
+
+      // Specify the terminate handler for abnormal terminations
+      std::set_terminate( the_terminate_handler );
+
+      // Initialize APR
+      if (APR_SUCCESS != apr_initialize())
+        assert(!"Can't initialize APR");
+
+      // Allocate the master pool
+      if (APR_SUCCESS != apr_pool_create(&POOL,0))
+        assert(!"Can't allocate the master pool");
+
+#ifdef XPS_DEBUG
+      // Make sure we print stack trace if we get bad signals
+      llvm::sys::PrintStackTraceOnErrorSignal();
+#endif
+
+    }
+    catch ( ... )
+    {
+      assert(!"Unexpected exception during initialization.");
+    }
+
+    if (0 != atexit(terminate))
+      assert(!"Can't register termination at exit");
+
+    // We've made it through initialization .. indicate that.
+    initialized = true;
+  }
+}
+
+void
+terminate( void )
+{
+  if (initialized)
+  {
+    // Terminate APR
+    apr_terminate();
+
+    // Release the memory reserve
+    ::delete [] _memory_reserve;
+
+    // Done.
+    initialized = false;
+  }
+}
+
+}}
+
+void* 
+operator new(size_t size, apr_pool_t* pool) 
+{
+  return apr_palloc(pool,size);
+}
+
+void*
+operator new[](size_t size, apr_pool_t* pool)
+{
+  return apr_palloc(pool,size);
+}

Added: hlvm/trunk/hlvm/Base/Memory.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Base/Memory.h?rev=38033&view=auto

==============================================================================
--- hlvm/trunk/hlvm/Base/Memory.h (added)
+++ hlvm/trunk/hlvm/Base/Memory.h Sat Jul  7 18:59:09 2007
@@ -0,0 +1,58 @@
+//===-- hlvm/Base/Memory.h - HLVM Memory Facilities -------------*- C++ -*-===//
+//
+//                      High Level Virtual Machine (HLVM)
+//
+// Copyright (C) 2006 Reid Spencer. All Rights Reserved.
+//
+// This software is free software; you can redistribute it and/or modify it 
+// under the terms of the GNU Lesser General Public License as published by 
+// the Free Software Foundation; either version 2.1 of the License, or (at 
+// your option) any later version.
+//
+// This software is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+// FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for 
+// more details.
+//
+// You should have received a copy of the GNU Lesser General Public License 
+// along with this library in the file named LICENSE.txt; if not, write to the 
+// Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+// MA 02110-1301 USA
+//
+//===----------------------------------------------------------------------===//
+/// @file hlvm/Base/Memory.h
+/// @author Reid Spencer <rspencer at reidspencer.com> (original author)
+/// @date 2006/05/04
+/// @since 0.1.0
+/// @brief Declares memory facilities for HLVM
+//===----------------------------------------------------------------------===//
+
+#ifndef HLVM_BASE_MEMORY_H
+#define HLVM_BASE_MEMORY_H
+
+#include <apr-1/apr_pools.h>
+
+/// The BASE module implements fundamental utilities at the core of XPS.
+/// @brief The most elemental module in XPS.
+namespace hlvm { namespace Base {
+
+/// An APR pool to allocate memory into. This is the master pool of all XPS
+/// allocated pools and generally the one used to allocate APRish stuff into.
+/// Note that this doesn't exist until after the call to initialize()
+/// @see initialize
+/// @brief The main memory pool for XPS
+extern apr_pool_t* POOL;
+
+/// Determine if emergency memory reserve has been exhausted.
+/// @brief Detemine if heap memory is low.
+extern bool memory_is_low( void );
+
+void initialize(int& argc, char**argv );
+void terminate();
+
+}}
+
+void* operator new(size_t size, apr_pool_t* pool);
+void* operator new[](size_t size, apr_pool_t* pool);
+
+#endif

Added: hlvm/trunk/hlvm/Base/Source.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Base/Source.cpp?rev=38033&view=auto

==============================================================================
--- hlvm/trunk/hlvm/Base/Source.cpp (added)
+++ hlvm/trunk/hlvm/Base/Source.cpp Sat Jul  7 18:59:09 2007
@@ -0,0 +1,233 @@
+//===-- hlvm/Base/Source.cpp - AST Abstract Data Sourc Class ----*- C++ -*-===//
+//
+//                      High Level Virtual Machine (HLVM)
+//
+// Copyright (C) 2006 Reid Spencer. All Rights Reserved.
+//
+// This software is free software; you can redistribute it and/or modify it 
+// under the terms of the GNU Lesser General Public License as published by 
+// the Free Software Foundation; either version 2.1 of the License, or (at 
+// your option) any later version.
+//
+// This software is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+// FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for 
+// more details.
+//
+// You should have received a copy of the GNU Lesser General Public License 
+// along with this library in the file named LICENSE.txt; if not, write to the 
+// Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+// MA 02110-1301 USA
+//
+//===----------------------------------------------------------------------===//
+/// @file hlvm/Base/Source.cpp
+/// @author Reid Spencer <reid at reidspencer.com> (original author)
+/// @date 2006/05/04
+/// @since 0.1.0
+/// @brief Defines the class hlvm::Source
+//===----------------------------------------------------------------------===//
+
+#include <hlvm/Base/Source.h>
+#include <llvm/System/MappedFile.h>
+#include <iostream>
+#include <ios>
+
+using namespace hlvm;
+
+namespace 
+{
+
+class MappedFileSource : public Base::Source 
+{
+public:
+  MappedFileSource(llvm::sys::MappedFile& mf)
+    : mf_(mf), at_(0), end_(0), was_mapped_(false), read_len_(0)
+  {
+  }
+
+  virtual void prepare(intptr_t block_len) 
+  {
+    was_mapped_ = mf_.isMapped();
+    if (!was_mapped_)
+      mf_.map();
+    at_ = mf_.charBase();
+    end_ = at_ + mf_.size();
+    read_len_ = block_len;
+  }
+
+  virtual bool more()
+  {
+    return at_ < end_;
+  }
+
+  virtual const char* read(intptr_t& actual_len)
+  {
+    if (at_ >= end_) {
+      actual_len = 0;
+      return 0;
+    }
+    const char* result = at_;
+    if (read_len_ < end_ - at_) {
+      actual_len = read_len_;
+      at_ += read_len_;
+    } else {
+      actual_len = end_ - at_;
+      at_ = end_;
+    }
+    return result;
+  }
+
+  virtual void finish()
+  {
+    if (!was_mapped_)
+      mf_.unmap();
+    at_ = 0;
+    end_ = 0;
+    was_mapped_ = false;
+    read_len_ = 0;
+  }
+
+  virtual std::string systemId() const
+  {
+    return mf_.path().toString();
+  }
+
+  virtual std::string publicId() const
+  {
+    return "file://" + systemId();
+  }
+
+private:
+  llvm::sys::MappedFile& mf_;
+  const char* at_;
+  const char* end_;
+  bool was_mapped_;
+  intptr_t read_len_;
+};
+
+class StreamSource : public Base::Source 
+{
+public:
+  StreamSource(std::istream& strm, std::string sysId, size_t bsize) : s_(strm) 
+  {
+    s_.seekg(0, std::ios::end);
+    len_ = s_.tellg();
+    s_.seekg(0, std::ios::beg);
+    if (bsize > 1024*1024)
+      buffSize = 1024*1024;
+    else 
+      buffSize = bsize;
+    buffer = new char[buffSize+1];
+  }
+
+  virtual ~StreamSource()
+  {
+    delete buffer;
+  }
+
+  virtual void prepare(intptr_t block_len)
+  {
+    s_.seekg(0,std::ios::beg);
+  }
+
+  virtual bool more()
+  {
+    return ! s_.bad() && !s_.eof();
+  }
+
+  virtual const char* read(intptr_t& actual_len)
+  {
+    if (more())
+    {
+      size_t pos = s_.tellg();
+      if (len_ - pos > buffSize)
+        actual_len = buffSize;
+      else
+        actual_len = len_ - pos;
+      s_.read(buffer, actual_len);
+      buffer[actual_len] = 0;
+      return buffer;
+    }
+    else
+    {
+      buffer[0] = 0;
+      actual_len = 0;
+      return buffer;
+    }
+  }
+
+  virtual void finish()
+  {
+  }
+
+  virtual std::string systemId() const
+  {
+    return sysId;
+  }
+
+  virtual std::string publicId() const
+  {
+    return "file:///" + systemId();
+  }
+
+private:
+  std::string sysId;
+  std::istream& s_;
+  size_t len_;
+  char* buffer;
+  size_t buffSize;
+};
+
+class URISource : public Base::Source 
+{
+private:
+  hlvm::Base::URI uri_;
+  llvm::sys::MappedFile* mf_;
+  MappedFileSource* mfs_;
+public:
+  URISource(const Base::URI& uri ) 
+    : uri_(uri) 
+    , mf_(0)
+    , mfs_(0)
+  {
+    mf_ = new llvm::sys::MappedFile(llvm::sys::Path(uri_.resolveToFile()));
+    mfs_ = new MappedFileSource(*mf_);
+  }
+  virtual ~URISource() {}
+  virtual void prepare(intptr_t block_len) { mfs_->prepare(block_len); }
+  virtual bool more() { return mfs_->more(); }
+  virtual const char* read(intptr_t& actual_len) 
+  { return mfs_->read(actual_len); }
+  virtual void finish() { mfs_->finish(); }
+  virtual std::string systemId() const { return mfs_->systemId(); }
+  virtual std::string publicId() const { return "file://" + mfs_->systemId(); }
+};
+
+}
+
+namespace hlvm { namespace Base {
+
+Source::~Source() 
+{
+}
+
+Source* 
+new_MappedFileSource(llvm::sys::MappedFile& mf)
+{
+  return new MappedFileSource(mf);
+}
+
+
+Source* 
+new_StreamSource(std::istream& strm, std::string sysId, size_t bSize)
+{
+  return new StreamSource(strm, sysId, bSize);
+}
+
+Source* 
+new_URISource(const Base::URI& uri)
+{
+  return new URISource(uri);
+}
+
+}}

Added: hlvm/trunk/hlvm/Base/Source.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Base/Source.h?rev=38033&view=auto

==============================================================================
--- hlvm/trunk/hlvm/Base/Source.h (added)
+++ hlvm/trunk/hlvm/Base/Source.h Sat Jul  7 18:59:09 2007
@@ -0,0 +1,79 @@
+//===-- hlvm/Base/Source.h - AST Abstract Input Source Class ----*- C++ -*-===//
+//
+//                      High Level Virtual Machine (HLVM)
+//
+// Copyright (C) 2006 Reid Spencer. All Rights Reserved.
+//
+// This software is free software; you can redistribute it and/or modify it 
+// under the terms of the GNU Lesser General Public License as published by 
+// the Free Software Foundation; either version 2.1 of the License, or (at 
+// your option) any later version.
+//
+// This software is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+// FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for 
+// more details.
+//
+// You should have received a copy of the GNU Lesser General Public License 
+// along with this library in the file named LICENSE.txt; if not, write to the 
+// Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+// MA 02110-1301 USA
+//
+//===----------------------------------------------------------------------===//
+/// @file hlvm/Base/Source.h
+/// @author Reid Spencer <reid at reidspencer.com> (original author)
+/// @date 2006/05/04
+/// @since 0.1.0
+/// @brief Declares the class hlvm::Base::Source
+//===----------------------------------------------------------------------===//
+
+#ifndef HLVM_BASE_SOURCE_H
+#define HLVM_BASE_SOURCE_H
+
+#include <hlvm/Base/URI.h>
+#include <llvm/System/MappedFile.h>
+#include <istream>
+
+namespace hlvm { namespace Base {
+  /// This class is the base class of a family of input source classes that can
+  /// be used to provide input to some parsing facility. This abstracts away
+  /// the details of how the input is acquired. Four functions must be 
+  /// implemented by subclasses: prepare, more, read, and finish.
+  /// @brief Abstract Input Source Class
+  class Source
+  {
+  /// @name Methods
+  /// @{
+  public:
+    /// @brief This destructor does nothing, but declared virtual for subclasses
+    virtual ~Source();
+
+    /// @brief Tells the source to prepare to be read
+    virtual void prepare(intptr_t block_len) = 0;
+
+    /// @brief Requests a block of data.
+    virtual const char* read(intptr_t& actual_len) = 0;
+
+    /// @brief Indicates if more data waits
+    virtual bool more() = 0;
+
+    /// @brief Tells the source to finish up.
+    virtual void finish() = 0;
+
+    /// @brief Get the system identifier of the source
+    virtual std::string systemId() const = 0;
+
+    /// @brief Get the public identifier of the source
+    virtual std::string publicId() const = 0;
+
+  /// @}
+  };
+
+  Source* new_MappedFileSource(llvm::sys::MappedFile& mf);
+  Source* new_StreamSource(std::istream&, std::string sysId = "<istream>", 
+      size_t bSize = 65536);
+  Source* new_URISource(const URI& uri);
+
+}}
+
+#endif

Added: hlvm/trunk/hlvm/Base/URI.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Base/URI.cpp?rev=38033&view=auto

==============================================================================
--- hlvm/trunk/hlvm/Base/URI.cpp (added)
+++ hlvm/trunk/hlvm/Base/URI.cpp Sat Jul  7 18:59:09 2007
@@ -0,0 +1,78 @@
+//===-- hlvm/Base/URI.cpp - Uniform Resource Identifier ---------*- C++ -*-===//
+//
+//                      High Level Virtual Machine (HLVM)
+//
+// Copyright (C) 2006 Reid Spencer. All Rights Reserved.
+//
+// This software is free software; you can redistribute it and/or modify it 
+// under the terms of the GNU Lesser General Public License as published by 
+// the Free Software Foundation; either version 2.1 of the License, or (at 
+// your option) any later version.
+//
+// This software is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+// FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for 
+// more details.
+//
+// You should have received a copy of the GNU Lesser General Public License 
+// along with this library in the file named LICENSE.txt; if not, write to the 
+// Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+// MA 02110-1301 USA
+//
+//===----------------------------------------------------------------------===//
+/// @file hlvm/Base/URI.cpp
+/// @author Reid Spencer <rspencer at reidspencer.com> (original author)
+/// @date 2006/05/04
+/// @since 0.1.0
+/// @brief Declares the class hlvm::Base::URI
+//===----------------------------------------------------------------------===//
+
+#include <hlvm/Base/URI.h>
+#include <hlvm/Base/Memory.h>
+#include <iostream>
+
+namespace hlvm { namespace Base {
+
+URI::URI( const char * text)
+{
+  apr_uri_parse(POOL, text, &uri_);
+}
+
+URI::URI( const std::string& str)
+{
+  apr_uri_parse(POOL, str.c_str(), &uri_);
+}
+
+URI::~URI ( void )
+{
+}
+
+std::string 
+URI::as_string( void ) const
+{
+  const char* result = apr_uri_unparse(POOL, &uri_, 0);
+  return std::string( result );
+}
+
+/// @brief Clears the URI, releases memory.
+void 
+URI::clear( void )
+{
+  /// FIXME: how do we do this with the APR pools?
+}
+
+std::string 
+URI::resolveToFile() const
+{
+  const char* scheme = this->scheme();
+  if (scheme)
+  {
+    if (strncmp("file",this->scheme(),4) == 0)
+    {
+      return this->path();
+    }
+  }
+  return "";
+}
+
+}}

Added: hlvm/trunk/hlvm/Base/URI.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Base/URI.h?rev=38033&view=auto

==============================================================================
--- hlvm/trunk/hlvm/Base/URI.h (added)
+++ hlvm/trunk/hlvm/Base/URI.h Sat Jul  7 18:59:09 2007
@@ -0,0 +1,257 @@
+//===-- hlvm/Base/URI.h - Uniform Resource Identifier -----------*- C++ -*-===//
+//
+//                      High Level Virtual Machine (HLVM)
+//
+// Copyright (C) 2006 Reid Spencer. All Rights Reserved.
+//
+// This software is free software; you can redistribute it and/or modify it 
+// under the terms of the GNU Lesser General Public License as published by 
+// the Free Software Foundation; either version 2.1 of the License, or (at 
+// your option) any later version.
+//
+// This software is distributed in the hope that it will be useful, but WITHOUT
+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+// FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for 
+// more details.
+//
+// You should have received a copy of the GNU Lesser General Public License 
+// along with this library in the file named LICENSE.txt; if not, write to the 
+// Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+// MA 02110-1301 USA
+//
+//===----------------------------------------------------------------------===//
+/// @file hlvm/Base/URI.h
+/// @author Reid Spencer <rspencer at reidspencer.com> (original author)
+/// @date 2006/05/04
+/// @since 0.1.0
+/// @brief Declares the class hlvm::Base::URI
+//===----------------------------------------------------------------------===//
+
+#ifndef HLVM_BASE_URI_H
+#define HLVM_BASE_URI_H
+
+#include <apr-1/apr_uri.h>
+#include <string>
+
+namespace hlvm { namespace Base {
+
+/// A class to represent Uniform Resource Identifiers (URIs). This class can
+/// also support URLs and URNs. The implementation is based on the APR-UTIL
+/// apr_uri set of functions and associated data types. 
+/// @see RFC 2396 states that hostnames take the form described in 
+/// @see RFC 1034 (Section 3) Hostname Syntax
+/// @see RFC 1123 (Section 2.1). Hostnames
+/// @see RFC 1609 Universal Resource Identifiers in WWW - Berners-Lee.
+/// @see RFC 1738 Uniform Resource Locators - Berners-Lee.
+/// @see RFC 1808 Relative Uniform Resource Locators - Fielding
+/// @see RFC 2059 Uniform Resource Locators for z39.50 - Denenberg
+/// @see RFC 2111 Content-ID and Message-ID Uniform Resource Locators-Levinson
+/// @see RFC 2396 Uniform Resource Identifiers (URI) - Berners-Lee
+/// @see RFC 3305 URI/URL/URN Clarifications and Recommendations - Mealling
+/// @see RFC 3406 URN Namespace Definition Mechanisms - Daigle
+/// @see RFC 3508 URL Schem Registration - Levin
+/// @brief HLVM Uniform Resource Identifier Class
+class URI
+{
+/// @name Constructors
+/// @{
+public:
+  /// @brief Default Constructor builds empty uri
+  URI ( void );
+
+  /// @brief Parsing constructor builds uri by parsing the string parameter
+  URI( const char * str );
+
+  /// @brief Parsing constructor builds uri by parsing the string parameter
+  URI( const std::string& xmlStr);
+
+  /// @brief Copy Constructor.
+  URI ( const URI & that );
+
+  /// @brief Destructor.
+  ~URI ( void );
+
+/// @}
+/// @name Operators
+/// @{
+public:
+  /// @brief Equality Operator.
+  bool operator == ( const URI & that ) const;
+
+  /// @brief Assignment Operator.
+  URI & operator = ( const URI & that );
+
+/// @}
+/// @name Accessors
+/// @{
+public:
+
+  /// @brief Return the URI as a string (escaped). Caller must
+  /// free the returned string.
+  std::string as_string( void ) const;
+
+  /// @brief Set a string to the value of the URI with escapes.
+  void get_string( std::string& str_to_fill ) const;
+
+  /// @brief Return the scheme of the URI
+  const char* const scheme() const;
+
+  /// @brief Return the password part of the URI
+  const char* const password() const;
+
+  /// @breif Return the user part of the URI
+  const char* const user() const;
+
+  /// @brief Return the host name from the URI
+  const char* const hostname() const;
+
+  /// @brief Return the combined [user[:password]\@host:port/ part of the URI
+  const char* const hostinfo() const;
+
+  /// @brief Return the port part of the URI
+  uint32_t port() const;
+
+  /// @brief Return the path part of the URI
+  const char* const path() const;
+
+  /// @brief Return the query part of the URI
+  const char* const query() const;
+
+  /// @brief Return the fragment identifier part of the URI
+  const char* const fragment() const;
+
+  /// @brief Determines if two URIs are equal
+  bool equals( const URI& that ) const;
+
+  std::string resolveToFile() const;
+/// @}
+/// @name Mutators
+/// @{
+public:
+  /// @brief Assignment of one URI to another
+  URI& assign( const URI& that );
+
+  /// @brief Assignment of an std::string to a URI. 
+  void assign( const std::string& that );
+
+  /// @brief Clears the URI, releases memory.
+  void clear( void );
+
+  /// @brief Sets the scheme
+  //void scheme( const char* const scheme );
+
+  /// @brief Set the opaque part of the URI
+  //void opaque( const char* const opaque );
+
+  /// @brief Sets the authority.
+  //void authority( const char* const authority );
+
+  /// @brief Sets the user.
+  //void user( const char* const user );
+
+  /// @brief Sets the server.
+  //void server( const char* const server );
+
+  /// @brief Sets the port.
+  //void port( uint32_t portnum );
+
+/// @}
+/// @name Functions
+/// @{
+public:
+  static uint32_t port_for_scheme( const char* scheme );
+
+/// @}
+/// @name Data
+/// @{
+private:
+  apr_uri_t uri_;
+/// @}
+/// @name Unimplemented
+/// @{
+private:
+/// @}
+
+};
+
+inline
+URI::URI()
+{
+}
+
+inline URI&
+URI::assign( const URI& that )
+{
+  this->uri_ = that.uri_;
+  return *this;
+}
+
+inline
+URI::URI ( const URI & that )
+{
+  this->assign(that);
+}
+
+inline URI & 
+URI::operator = ( const URI & that )
+{
+  return this->assign(that);
+}
+
+inline bool 
+URI::operator == ( const URI & that ) const
+{
+  return this->equals(that);
+}
+
+inline const char* const
+URI::scheme() const
+{
+  return uri_.scheme;
+}
+
+inline const char* const
+URI::password() const
+{
+  return uri_.password;
+}
+
+inline const char* const
+URI::user() const 
+{
+  return uri_.user;
+}
+
+inline const char* const
+URI::hostname() const 
+{
+  return uri_.hostname;
+}
+
+inline uint32_t 
+URI::port() const 
+{
+  return atoi(uri_.port_str);
+}
+
+inline const char* const
+URI::path() const 
+{
+  return uri_.path;
+}
+
+inline const char* const
+URI::query() const 
+{
+  return uri_.query;
+}
+
+inline const char* const
+URI::fragment() const 
+{
+  return uri_.fragment;
+}
+
+}}
+
+#endif

Modified: hlvm/trunk/hlvm/Reader/Reader.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Reader/Reader.h?rev=38033&r1=38032&r2=38033&view=diff

==============================================================================
--- hlvm/trunk/hlvm/Reader/Reader.h (original)
+++ hlvm/trunk/hlvm/Reader/Reader.h Sat Jul  7 18:59:09 2007
@@ -30,8 +30,6 @@
 #ifndef XPS_READER_READER_H
 #define XPS_READER_READER_H
 
-#include <llvm/System/Path.h>
-
 namespace hlvm {
 namespace AST { class Node; }
 

Modified: hlvm/trunk/hlvm/Reader/XML/XMLReader.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Reader/XML/XMLReader.cpp?rev=38033&r1=38032&r2=38033&view=diff

==============================================================================
--- hlvm/trunk/hlvm/Reader/XML/XMLReader.cpp (original)
+++ hlvm/trunk/hlvm/Reader/XML/XMLReader.cpp Sat Jul  7 18:59:09 2007
@@ -30,6 +30,7 @@
 #include <hlvm/Reader/XML/XMLReader.h>
 #include <hlvm/Reader/XML/HLVMTokenizer.h>
 #include <hlvm/Base/Locator.h>
+#include <hlvm/Base/Source.h>
 #include <hlvm/AST/Bundle.h>
 #include <expat.h>
 #include <vector>
@@ -108,14 +109,14 @@
 };
 
 class XMLReaderImpl : public XMLReader {
-  llvm::sys::Path path_;
+  hlvm::Base::Source* in_;
   AST::Node* node_;
   XML_Parser xp_;
   std::vector<ElementInfo> elems_; ///< The element stack
   ElementInfo* etop_; ///< A pointer to the top of the element stack
 public:
-  XMLReaderImpl(const llvm::sys::Path& path) :
-    path_(path), node_(0), xp_(0), elems_(), etop_(0)
+  XMLReaderImpl(Base::Source* input)
+    : in_(input), node_(0), xp_(0), elems_(), etop_(0)
   {
     xp_ = XML_ParserCreate( "UTF-8");
     // Reserve some space on the elements and attributes list so we aren't
@@ -206,9 +207,7 @@
     // Fill in the element info
     ei.local = name;
     ei.token = HLVMTokenizer::recognize(name);
-    ei.set(
-      "",
-      p->path_.c_str(),
+    ei.set("", "{in}",
       uint32_t(XML_GetCurrentLineNumber(p->xp_)), 
       uint32_t(XML_GetCurrentColumnNumber(p->xp_))
     );
@@ -381,6 +380,41 @@
   XML_SetCdataSectionHandler( xp_, StartCdataSectionHandler, 
     EndCdataSectionHandler );
   XML_SetUnknownEncodingHandler( xp_, UnknownEncodingHandler, this);
+
+  try
+  {
+    int actual_len = 0;
+    in_->prepare(65536);
+
+    // While there is more input to read
+    while ( in_->more() )
+    {
+      // Read a chunk of data
+      const char* ptr = in_->read(actual_len);
+
+      // Parse it.
+      int parse_result = XML_Parse( xp_, ptr, actual_len, in_->more() ) ;
+
+      if ( XML_STATUS_ERROR == parse_result )
+      {
+        std::cerr << "Parsing Error\n";
+
+        // Signal end of the parsing if we didn't already
+        if (in_->more())
+          XML_Parse( xp_, 0, 0, 1 );
+        in_->finish();
+        return;
+      }
+    }
+
+    // Signal the end of parsing
+    XML_StopParser( xp_, 0);
+    in_->finish();
+  } catch (...) {
+    XML_StopParser(xp_,0);
+    in_->finish();
+    throw;
+  }
 }
 
 void 
@@ -506,7 +540,7 @@
 }
 
 XMLReader* 
-hlvm::XMLReader::create(const llvm::sys::Path& path)
+hlvm::XMLReader::create(hlvm::Base::Source* src)
 {
-  return new XMLReaderImpl(path);
+  return new XMLReaderImpl(src);
 }

Modified: hlvm/trunk/hlvm/Reader/XML/XMLReader.h
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Reader/XML/XMLReader.h?rev=38033&r1=38032&r2=38033&view=diff

==============================================================================
--- hlvm/trunk/hlvm/Reader/XML/XMLReader.h (original)
+++ hlvm/trunk/hlvm/Reader/XML/XMLReader.h Sat Jul  7 18:59:09 2007
@@ -31,7 +31,7 @@
 #define XPS_READER_XML_XMLREADER_H
 
 #include <hlvm/Reader/Reader.h>
-#include <llvm/System/Path.h>
+#include <hlvm/Base/Source.h>
 
 namespace hlvm {
 
@@ -43,7 +43,7 @@
     /// This method instantiates an XMLReader that is prepared to read from
     /// the path provided.
     /// @brief Create a new XmlReader
-    static XMLReader* create(const llvm::sys::Path& path);
+    static XMLReader* create(Base::Source* in);
 
     virtual ~XMLReader() {}
   };

Modified: hlvm/trunk/tools/hlvm-xml2xml/Makefile
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/tools/hlvm-xml2xml/Makefile?rev=38033&r1=38032&r2=38033&view=diff

==============================================================================
--- hlvm/trunk/tools/hlvm-xml2xml/Makefile (original)
+++ hlvm/trunk/tools/hlvm-xml2xml/Makefile Sat Jul  7 18:59:09 2007
@@ -2,7 +2,7 @@
 
 LEVEL = ../..
 TOOLNAME = hlvm-xml2xml
-USEDLIBS = HLVMXMLWriter.a HLVMXMLReader.a HLVMAST.a
+USEDLIBS = HLVMXMLWriter.a HLVMXMLReader.a HLVMAST.a HLVMBase.a
 LLVMLIBS = LLVMSupport.a LLVMSystem.a
 
 include $(LEVEL)/Makefile.hlvm

Modified: hlvm/trunk/tools/hlvm-xml2xml/hlvm-xml2xml.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/tools/hlvm-xml2xml/hlvm-xml2xml.cpp?rev=38033&r1=38032&r2=38033&view=diff

==============================================================================
--- hlvm/trunk/tools/hlvm-xml2xml/hlvm-xml2xml.cpp (original)
+++ hlvm/trunk/tools/hlvm-xml2xml/hlvm-xml2xml.cpp Sat Jul  7 18:59:09 2007
@@ -27,6 +27,7 @@
 /// @brief Implements the main program for the hlvm-xml2xml executable
 //===----------------------------------------------------------------------===//
 
+#include <hlvm/Base/Memory.h>
 #include <hlvm/Reader/XML/XMLReader.h>
 #include <hlvm/Writer/XML/XMLWriter.h>
 #include <llvm/Support/CommandLine.h>
@@ -46,9 +47,9 @@
 int main(int argc, char**argv) 
 {
   try {
+    Base::initialize(argc,argv);
     cl::ParseCommandLineOptions(argc, argv, 
       "hlvm-xml2xml XML->AST->XML translator\n");
-    sys::PrintStackTraceOnErrorSignal();
 
     std::ostream *Out = &std::cout;  // Default to printing to stdout.
 
@@ -75,7 +76,23 @@
       Out = &std::cout;
     }
 
-    XMLReader* rdr = XMLReader::create(llvm::sys::Path(InputFilename));
+    Base::Source* src = 0;
+    llvm::sys::MappedFile* mf = 0;
+    if (InputFilename == "-" ) {
+      src = Base::new_StreamSource(std::cin);
+    } else {
+      llvm::sys::Path path(InputFilename);
+      if (path.canRead()) {
+        mf = new llvm::sys::MappedFile(path);
+        src = Base::new_MappedFileSource(*mf);
+      } else {
+        std::cerr << argv[0] << ": can't read input file: " << InputFilename
+                  << "\n";
+        exit(2);
+      }
+    }
+
+    XMLReader* rdr = XMLReader::create(src);
     XMLWriter* wrtr = XMLWriter::create(*Out);
     rdr->read();
     AST::Node* node = rdr->get();
@@ -84,6 +101,10 @@
     }
     delete rdr;
     delete wrtr;
+    if (mf) {
+      mf->close();
+      delete mf;
+    }
 
     if (Out != &std::cout) {
       static_cast<std::ofstream*>(Out)->close();





More information about the llvm-commits mailing list