<commit_before>//===- Parser.cpp - Main dispatch module for the Parser library -------------===
//
// This library implements the functionality defined in llvm/assembly/parser.h
//
//===------------------------------------------------------------------------===

#include "llvm/Analysis/Verifier.h"
#include "llvm/Module.h"
#include "ParserInternals.h"
#include <stdio.h>  // for sprintf
using std::string;

// The useful interface defined by this file... Parse an ascii file, and return
// the internal representation in a nice slice'n'dice'able representation.
//
Module *ParseAssemblyFile(const string &Filename) { // throw (ParseException)
  FILE *F = stdin;

  if (Filename != "-") 
    F = fopen(Filename.c_str(), "r");

  if (F == 0) {
    throw ParseException(Filename, string("Could not open file '") + 
			 Filename + "'");
  }

  // TODO: If this throws an exception, F is not closed.
  Module *Result = RunVMAsmParser(Filename, F);
<commit_msg>Close input file if exception is thrown<commit_after>//===- Parser.cpp - Main dispatch module for the Parser library -------------===
//
// This library implements the functionality defined in llvm/assembly/parser.h
//
//===------------------------------------------------------------------------===

#include "llvm/Analysis/Verifier.h"
#include "llvm/Module.h"
#include "ParserInternals.h"
#include <stdio.h>  // for sprintf
using std::string;

// The useful interface defined by this file... Parse an ascii file, and return
// the internal representation in a nice slice'n'dice'able representation.
//
Module *ParseAssemblyFile(const string &Filename) { // throw (ParseException)
  FILE *F = stdin;

  if (Filename != "-") {
    F = fopen(Filename.c_str(), "r");

    if (F == 0)
      throw ParseException(Filename, "Could not open file '" + Filename + "'");
  }

  Module *Result;
  try {
    Result = RunVMAsmParser(Filename, F);
  } catch (...) {
    if (F != stdin) fclose(F);      // Make sure to close file descriptor if an
    throw;                          // exception is thrown
  }

{'fraction_non_alphanumeric': 0.2158869395711501, 'fraction_numerical': 0.0009746588693957114, 'mean_word_length': 2.3382113821138213, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5490680', 'n_tokens_mistral': 581, 'n_tokens_neox': 566, 'n_words': 191}