<commit_before>//===-- FrontendActions.h - Useful Frontend Actions -------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_CLANG_FRONTEND_FRONTENDACTIONS_H
#define LLVM_CLANG_FRONTEND_FRONTENDACTIONS_H

#include "clang/Frontend/FrontendAction.h"
#include <string>
#include <vector>

namespace clang {

class Module;
class FileEntry;
  
//===----------------------------------------------------------------------===//
// Custom Consumer Actions
//===----------------------------------------------------------------------===//

class InitOnlyAction : public FrontendAction {
  void ExecuteAction() override;

  ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
                                 StringRef InFile) override;

public:
  // Don't claim to only use the preprocessor, we want to follow the AST path,
  // but do nothing.
  bool usesPreprocessorOnly() const override { return false; }
};

//===----------------------------------------------------------------------===//
// AST Consumer Actions
//===----------------------------------------------------------------------===//

class ASTPrintAction : public ASTFrontendAction {
protected:
  ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
                                 StringRef InFile) override;
};

class ASTDumpAction : public ASTFrontendAction {
protected:
  ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
                                 StringRef InFile) override;
};

class ASTDeclListAction : public ASTFrontendAction {
protected:
  ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
                                 StringRef InFile) override;
};

class ASTViewAction : public ASTFrontendAction {
protected:
  ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
                                 StringRef InFile) override;
};

class DeclContextPrintAction : public ASTFrontendAction {
protected:
  ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
                                 StringRef InFile) override;
};

class GeneratePCHAction : public ASTFrontendAction {
protected:
  ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
                                 StringRef InFile) override;

  TranslationUnitKind getTranslationUnitKind() override {
    return TU_Prefix;
  }

  bool hasASTFileSupport() const override { return false; }

public:
  /// \brief Compute the AST consumer arguments that will be used to
  /// create the PCHGenerator instance returned by CreateASTConsumer.
  ///
  /// \returns true if an error occurred, false otherwise.
  static bool ComputeASTConsumerArguments(CompilerInstance &CI,
                                          StringRef InFile,
                                          std::string &Sysroot,
                                          std::string &OutputFile,
                                          raw_ostream *&OS);
};

class GenerateModuleAction : public ASTFrontendAction {
  Module *Module;
  const FileEntry *ModuleMapForUniquing;
  bool IsSystem;
  
protected:
  ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
                                 StringRef InFile) override;

  TranslationUnitKind getTranslationUnitKind() override {
    return TU_Module;
  }

  bool hasASTFileSupport() const override { return false; }

public:
  GenerateModuleAction(const FileEntry *ModuleMap = nullptr,
                       bool IsSystem = false)
    : ASTFrontendAction(), ModuleMapForUniquing(ModuleMap), IsSystem(IsSystem)
  { }

  bool BeginSourceFileAction(CompilerInstance &CI, StringRef Filename) override;

  /// \brief Compute the AST consumer arguments that will be used to
  /// create the PCHGenerator instance returned by CreateASTConsumer.
  ///
  /// \returns true if an error occurred, false otherwise.
  bool ComputeASTConsumerArguments(CompilerInstance &CI,
                                   StringRef InFile,
                                   std::string &Sysroot,<commit_msg>Add clang:: qualifier back to Module<commit_after>//===-- FrontendActions.h - Useful Frontend Actions -------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_CLANG_FRONTEND_FRONTENDACTIONS_H
#define LLVM_CLANG_FRONTEND_FRONTENDACTIONS_H

#include "clang/Frontend/FrontendAction.h"
#include <string>
#include <vector>

namespace clang {

class Module;
class FileEntry;
  
//===----------------------------------------------------------------------===//
// Custom Consumer Actions
//===----------------------------------------------------------------------===//

class InitOnlyAction : public FrontendAction {
  void ExecuteAction() override;

  ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
                                 StringRef InFile) override;

public:
  // Don't claim to only use the preprocessor, we want to follow the AST path,
  // but do nothing.
  bool usesPreprocessorOnly() const override { return false; }
};

//===----------------------------------------------------------------------===//
// AST Consumer Actions
//===----------------------------------------------------------------------===//

class ASTPrintAction : public ASTFrontendAction {
protected:
  ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
                                 StringRef InFile) override;
};

class ASTDumpAction : public ASTFrontendAction {
protected:
  ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
                                 StringRef InFile) override;
};

class ASTDeclListAction : public ASTFrontendAction {
protected:
  ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
                                 StringRef InFile) override;
};

class ASTViewAction : public ASTFrontendAction {
protected:
  ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
                                 StringRef InFile) override;
};

class DeclContextPrintAction : public ASTFrontendAction {
protected:
  ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
                                 StringRef InFile) override;
};

class GeneratePCHAction : public ASTFrontendAction {
protected:
  ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
                                 StringRef InFile) override;

  TranslationUnitKind getTranslationUnitKind() override {
    return TU_Prefix;
  }

  bool hasASTFileSupport() const override { return false; }

public:
  /// \brief Compute the AST consumer arguments that will be used to
  /// create the PCHGenerator instance returned by CreateASTConsumer.
  ///
  /// \returns true if an error occurred, false otherwise.
  static bool ComputeASTConsumerArguments(CompilerInstance &CI,
                                          StringRef InFile,
                                          std::string &Sysroot,
                                          std::string &OutputFile,
                                          raw_ostream *&OS);
};

class GenerateModuleAction : public ASTFrontendAction {
  clang::Module *Module;
  const FileEntry *ModuleMapForUniquing;
  bool IsSystem;
  
protected:
  ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
                                 StringRef InFile) override;

  TranslationUnitKind getTranslationUnitKind() override {
    return TU_Module;
  }

  bool hasASTFileSupport() const override { return false; }

public:
  GenerateModuleAction(const FileEntry *ModuleMap = nullptr,
                       bool IsSystem = false)
    : ASTFrontendAction(), ModuleMapForUniquing(ModuleMap), IsSystem(IsSystem)
  { }

  bool BeginSourceFileAction(CompilerInstance &CI, StringRef Filename) override;

  /// \brief Compute the AST consumer arguments that will be used to
  /// create the PCHGenerator instance returned by CreateASTConsumer.
  ///
  /// \returns true if an error occurred, false otherwise.
  bool ComputeASTConsumerArguments(CompilerInstance &CI,
                                   StringRef InFile,
                                   std::string &Sysroot,
{'fraction_non_alphanumeric': 0.1630512514898689, 'fraction_numerical': 0.0, 'mean_word_length': 1.8854883081155434, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 36, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '963029', 'n_tokens_mistral': 1984, 'n_tokens_neox': 1887, 'n_words': 564}