<commit_before>//===--- Subsystems.h - Swift Compiler Subsystem Entrypoints ----*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
//  This file declares the main entrypoints to the various subsystems.
//
//===----------------------------------------------------------------------===//

#ifndef SWIFT_SUBSYSTEMS_H
#define SWIFT_SUBSYSTEMS_H

#include "swift/Basic/LLVM.h"
#include "llvm/ADT/ArrayRef.h"

namespace llvm {
  class SourceMgr;
  class MemoryBuffer;
  class Module;
  class FunctionPass;
}

namespace swift {
  class TranslationUnit;
  class ASTContext;
  class Component;
  class Expr;
  class SILModule;
  class LangOptions;
  struct TypeLoc;
  class SILParserTUState;
  class Token;

  namespace irgen {
    class Options;
  }
  
  /// SILParserState - This is a context object used to optionally maintain SIL
  /// parsing context for the parser.
  class SILParserState {
  public:
    SILModule *M;
    SILParserTUState *S;

    explicit SILParserState(SILModule *M);
    ~SILParserState();
  };
  

  /// verify - Check that the translation unit is well formed (i.e. following
  /// the invariants of the AST, not that the code written by the user makes
  /// sense), aborting and spewing errors if not.
  void verify(TranslationUnit *TUnit);

  /// parseIntoTranslationUnit - Parse a single buffer into the given
  /// taranslation unit.  If the translation unit is the main module, stop
  /// parsing after the next stmt-brace-item with side-effects.  If "SIL" is
  /// present, then we're parsing a .sil file instead of a .swift file.
  ///
  bool parseIntoTranslationUnit(TranslationUnit *TU, unsigned BufferID,
                                unsigned *BufferOffset = 0,
                                unsigned BufferEndOffset = 0,
                                SILParserState *SIL = 0);

  /// \brief Lex and return a vector of tokens for the given buffer.
  std::vector<Token> tokenize(llvm::SourceMgr &SM, unsigned BufferID,
                              unsigned Offset = 0, unsigned EndOffset = 0,
                              bool KeepComments = true);

  /// Attempt to parse a StringRef as a code completion context expression.
  /// Returns the parsed expression if successful, or null if an expression
  /// could not be parsed.
  Expr *parseCompletionContextExpr(TranslationUnit *TU, StringRef expr);<commit_msg>Use nullptr instead of '0'.<commit_after>//===--- Subsystems.h - Swift Compiler Subsystem Entrypoints ----*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
//  This file declares the main entrypoints to the various subsystems.
//
//===----------------------------------------------------------------------===//

#ifndef SWIFT_SUBSYSTEMS_H
#define SWIFT_SUBSYSTEMS_H

#include "swift/Basic/LLVM.h"
#include "llvm/ADT/ArrayRef.h"

namespace llvm {
  class SourceMgr;
  class MemoryBuffer;
  class Module;
  class FunctionPass;
}

namespace swift {
  class TranslationUnit;
  class ASTContext;
  class Component;
  class Expr;
  class SILModule;
  class LangOptions;
  struct TypeLoc;
  class SILParserTUState;
  class Token;

  namespace irgen {
    class Options;
  }
  
  /// SILParserState - This is a context object used to optionally maintain SIL
  /// parsing context for the parser.
  class SILParserState {
  public:
    SILModule *M;
    SILParserTUState *S;

    explicit SILParserState(SILModule *M);
    ~SILParserState();
  };
  

  /// verify - Check that the translation unit is well formed (i.e. following
  /// the invariants of the AST, not that the code written by the user makes
  /// sense), aborting and spewing errors if not.
  void verify(TranslationUnit *TUnit);

  /// parseIntoTranslationUnit - Parse a single buffer into the given
  /// taranslation unit.  If the translation unit is the main module, stop
  /// parsing after the next stmt-brace-item with side-effects.  If "SIL" is
  /// present, then we're parsing a .sil file instead of a .swift file.
  ///
  bool parseIntoTranslationUnit(TranslationUnit *TU, unsigned BufferID,
                                unsigned *BufferOffset = nullptr,
                                unsigned BufferEndOffset = 0,
                                SILParserState *SIL = nullptr);

  /// \brief Lex and return a vector of tokens for the given buffer.
  std::vector<Token> tokenize(llvm::SourceMgr &SM, unsigned BufferID,
                              unsigned Offset = 0, unsigned EndOffset = 0,
                              bool KeepComments = true);

  /// Attempt to parse a StringRef as a code completion context expression.
  /// Returns the parsed expression if successful, or null if an expression
  /// could not be parsed.
  Expr *parseCompletionContextExpr(TranslationUnit *TU, StringRef expr);
{'fraction_non_alphanumeric': 0.14221178171304663, 'fraction_numerical': 0.005240332490061439, 'mean_word_length': 2.199421965317919, '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': '7190039', 'n_tokens_mistral': 1543, 'n_tokens_neox': 1438, 'n_words': 559}