llvm-analysis-0.3.0: A Haskell library for analyzing LLVM bitcode

Safe HaskellNone

LLVM.Analysis.ClassHierarchy

Contents

Description

This module defines a class hierarchy analysis for C++.

This analysis operates entirely at the bitcode level and does not rely on metadata.

The hierarchy analysis result only includes class instantiations in the bitcode provided (i.e., it is most useful for whole-program bitcodes). Results for single compilation units will be incomplete.

Also note that this analysis requires the input bitcode to be built with C++ run-time type information.

Synopsis

Types

data CHA Source

The result of the class hierarchy analysis

data VTable Source

An interface for inspecting virtual function tables

Instances

Functions

resolveVirtualCallee :: CHA -> Instruction -> Maybe [Function]Source

classSubtypes :: CHA -> Type -> [Type]Source

List of all types derived from the given Type.

classTransitiveSubtypes :: CHA -> Type -> [Type]Source

List of all types *transitively* drived from the given Type

classParents :: CHA -> Type -> [Type]Source

List of the immediate parent types of the given Type. The list is only empty for the root of a class hierarchy.

classAncestors :: CHA -> Type -> [Type]Source

List of all (transitive) parent types of the given Type.

classVTable :: CHA -> Type -> Maybe VTableSource

Retrieve the vtbl for a given type. Will return Nothing if the type is not a class or if the class has no virtual methods.

functionAtSlot :: Int -> VTable -> Maybe FunctionSource

Get the function at the named slot in a vtable. Returns Nothing for external vtables.

runCHA :: Module -> CHASource

The analysis reconstructs the class hierarchy by looking at typeinfo structures (which are probably only generated when compiling with run-time type information enabled). It also finds vtables by demangling the names of the vtables in the module.

Testing