|
Language.C.Analysis.SemRep | Portability | ghc | Stability | alpha | Maintainer | benedikt.huber@gmail.com |
|
|
|
|
|
Description |
This module contains definitions for representing C translation units.
In contrast to Language.C.Syntax.AST, the representation tries to express the semantics of
of a translation unit.
|
|
Synopsis |
|
|
|
|
Sums of tags and identifiers
|
|
|
Composite type definitions (tags)
| Constructors | |
|
|
|
return the type corresponding to a tag definition
|
|
class Declaration n where | Source |
|
All datatypes aggregating a declaration are instances of Declaration
| | Methods | | get the name, type and declaration attributes of a declaration or definition
|
|
|
|
|
get the variable identifier of a declaration (only safe if the
the declaration is known to have a name)
|
|
|
get the variable name of a Declaration
|
|
|
get the type of a Declaration
|
|
|
get the declaration attributes of a Declaration
|
|
|
identifiers, typedefs and enumeration constants (namespace sum)
| Constructors | Declaration Decl | object or function declaration
| ObjectDef ObjDef | object definition
| FunctionDef FunDef | function definition
| EnumeratorDef Enumerator | definition of an enumerator
|
|
|
|
|
textual description of the kind of an object
|
|
|
splitIdentDecls includeAllDecls splits a map of object, function and enumerator declarations and definitions into one map
holding declarations, and three maps for object definitions, enumerator definitions and function definitions.
If includeAllDecls is True all declarations are present in the first map, otherwise only those where no corresponding definition
is available.
|
|
Global definitions
|
|
|
global declaration/definition table returned by the analysis
| Constructors | |
|
|
|
empty global declaration table
|
|
|
filter global declarations
|
|
|
merge global declarations
|
|
Events for visitors
|
|
|
Declaration events
Those events are reported to callbacks, which are executed during the traversal.
| Constructors | TagEvent TagDef | file-scope struct/union/enum event
| DeclEvent IdentDecl | file-scope declaration or definition
| TypeDefEvent TypeDef | a type definition
| AsmEvent AsmBlock | assembler block
|
|
|
|
Declarations and definitions
|
|
|
Declarations, which aren't definitions
| Constructors | |
|
|
|
Object Definitions
An object definition is a declaration together with an initializer.
If the initializer is missing, it is a tentative definition, i.e. a
definition which might be overriden later on.
| Constructors | |
|
|
|
Returns True if the given object definition is tentative.
|
|
|
Function definitions
A function definition is a declaration together with a statement (the function body).
| Constructors | |
|
|
|
Parameter declaration
| Constructors | |
|
|
|
Struct/Union member declaration
| Constructors | |
|
|
|
typedef definitions.
The identifier is a new name for the given type.
| Constructors | |
|
|
|
return the idenitifier of a typedef
|
|
|
Generic variable declarations
| Constructors | |
|
|
Declaration attributes
|
|
|
Declaration attributes of the form DeclAttrs isInlineFunction storage linkage attrs
They specify the storage and linkage of a declared object.
| Constructors | |
|
|
|
|
|
Storage duration and linkage of a variable
| Constructors | NoStorage | no storage
| Auto Register | automatic storage (optional: register)
| Static Linkage ThreadLocal | static storage, with linkage and thread local specifier (gnu c)
| FunLinkage Linkage | function, either internal or external linkage
|
|
|
|
|
get the Storage of a declaration
|
|
|
|
|
|
|
Linkage: Either internal to the translation unit or external
| Constructors | InternalLinkage | | ExternalLinkage | |
|
|
|
Types
|
|
|
types of C objects
| Constructors | |
|
|
|
Function types are of the form FunType return-type params isVariadic attrs.
If the parameter types aren't yet known, the function has type FunTypeIncomplete type attrs.
| Constructors | |
|
|
|
return True if the given type is a function type
Result is undefined in the presence of TypeOfExpr or undefined typeDefs
|
|
|
resolve typedefs, if possible
|
|
|
|
|
|
|
An array type may either have unknown size or a specified array size, the latter either variable or constant.
Furthermore, when used as a function parameters, the size may be qualified as static.
In a function prototype, the size may be `Unspecified variable size' ([*]).
| Constructors | UnknownArraySize Bool | UnknownArraySize is-starred | ArraySize Bool Expr | FixedSizeArray is-static size-expr |
|
|
|
|
typdef references
If the actual type is known, it is attached for convenience
| Constructors | |
|
|
|
normalized type representation
| Constructors | |
|
|
|
Builtin type (va_list)
| Constructors | |
|
|
|
integral types (C99 6.7.2.2)
| Constructors | TyBool | | TyChar | | TySChar | | TyUChar | | TyShort | | TyUShort | | TyInt | | TyUInt | | TyLong | | TyULong | | TyLLong | | TyULLong | |
|
|
|
|
floating point type (C99 6.7.2.2)
| Constructors | |
|
|
|
accessor class : struct/union/enum names
| | Methods | |
|
|
class HasCompTyKind a where | Source |
|
accessor class : composite type tags (struct or union)
| | Methods | |
|
|
|
composite type declarations
| Constructors | |
|
|
|
Composite type (struct or union).
| Constructors | |
|
|
|
return the type of a composite type definition
|
|
|
a tag to determine wheter we refer to a struct or union, see CompType.
| Constructors | |
|
|
|
|
|
|
Representation of C enumeration types
| Constructors | |
|
|
|
return the type of an enum definition
|
|
|
An Enumerator consists of an identifier, a constant expressions and the link to its type
| Constructors | |
|
|
|
Type qualifiers: constant, volatile and restrict
| Constructors | |
|
|
|
no type qualifiers
|
|
|
merge (&&) two type qualifier sets
|
|
Variable names
|
|
|
VarName name assembler-name is a name of an declared object
| Constructors | |
|
|
|
|
|
Assembler name (alias for CStrLit)
|
|
Attributes (STUB, not yet analyzed)
|
|
|
__attribute__ annotations
Those are of the form Attr attribute-name attribute-parameters,
and serve as generic properties of some syntax tree elements.
Some examples:
- labels can be attributed with unused to indicate that their not used
- struct definitions can be attributed with packed to tell the compiler to use the most compact representation
- declarations can be attributed with deprecated
- function declarations can be attributes with noreturn to tell the compiler that the function will never return,
- or with const to indicate that it is a pure function
TODO: ultimatively, we want to parse attributes and represent them in a typed way
| Constructors | |
|
|
|
|
Statements and Expressions (STUB, aliases to Syntax)
|
|
|
Stmt is an alias for CStat (Syntax)
|
|
|
Expr is currently an alias for CExpr (Syntax)
|
|
|
Initializer is currently an alias for CInit.
We're planning a normalized representation, but this depends on the implementation of
constant expression evaluation
|
|
|
Top level assembler block (alias for CStrLit)
|
|
Produced by Haddock version 2.6.0 |