<commit_before>require 'llvm'
require 'llvm/core'
require 'llvm/target'

module LLVM
  # @private
  module C
    enum :verifier_failure_action, [
      :abort_process,
      :print_message,
      :return_status
    ]
    
    attach_function :LLVMVerifyModule, [:pointer, :verifier_failure_action, :pointer], :int
    attach_function :LLVMVerifyFunction, [:pointer, :verifier_failure_action], :int
  end
  
  class Module
    def verify
      do_verification(:return_status)
    end
    
    def verify!
      do_verification(:abort_process)
    end
    
    private
      def do_verification(action)
        str = FFI::MemoryPointer.new(FFI.type_size(:pointer))
        status = C.LLVMVerifyModule(self, action, str)
        case status
          when 1 then str.read_string
          else nil
        end
      end
  end
  
  class Function
    def verify
      do_verification(:return_status)
    end

    def verify!
      do_verification(:abort_process)
    end

    private

    def do_verification(action)
      C.LLVMVerifyFunction(self, action) != 0
    end
  end
end<commit_msg>Added documentation for analysis methods.<commit_after>require 'llvm'
require 'llvm/core'
require 'llvm/target'

module LLVM
  # @private
  module C
    enum :verifier_failure_action, [
      :abort_process,
      :print_message,
      :return_status
    ]
    
    attach_function :LLVMVerifyModule, [:pointer, :verifier_failure_action, :pointer], :int
    attach_function :LLVMVerifyFunction, [:pointer, :verifier_failure_action], :int
  end
  
  class Module
    # Verify that the module is valid.
    # @return [nil, String] human-readable description of any invalid
    #   constructs if invalid.
    def verify
      do_verification(:return_status)
    end
    
    # Verify that a module is valid, and abort the process if not.
    # @return [nil]
    def verify!
      do_verification(:abort_process)
    end
    
    private
      def do_verification(action)
        str = FFI::MemoryPointer.new(FFI.type_size(:pointer))
        status = C.LLVMVerifyModule(self, action, str)
        case status
        when 1 then str.read_string
        else nil
        end
      end
  end
  
  class Function
    # Verify that a function is valid.
    # @return [true, false]
    def verify
      do_verification(:return_status)
    end

    # Verify that a function is valid, and abort the process if not.
    # @return [true, false]
    def verify!
      do_verification(:abort_process)
    end

    private

    def do_verification(action)
      C.LLVMVerifyFunction(self, action) != 0
    end
  end
end
{'fraction_non_alphanumeric': 0.07680432265534543, 'fraction_numerical': 0.0015438054805094559, 'mean_word_length': 2.6100278551532035, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4185992', 'n_tokens_mistral': 798, 'n_tokens_neox': 804, 'n_words': 212}