LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | List of all members
llvm::IncludeFile Struct Reference

Class to ensure linking of corresponding object file. More...

#include <IncludeFile.h>

Public Member Functions

 IncludeFile (const void *)
 

Detailed Description

Class to ensure linking of corresponding object file.

This class is used in the implementation of FORCE_DEFINING_FILE_TO_BE_LINKED macro to make sure that the implementation of a header file is included into a tool that uses the header. This is solely to overcome problems linking .a files and not getting the implementation of compilation units we need. This is commonly an issue with the various Passes but also occurs elsewhere in LLVM. We like to use .a files because they link faster and provide the smallest executables. However, sometimes those executables are too small, if the program doesn't reference something that might be needed, especially by a loaded share object. This little class helps to resolve that problem. The basic strategy is to use this class in a header file and pass the address of a variable to the constructor. If the variable is defined in the header file's corresponding .cpp file then all tools/libraries that #include the header file will require the .cpp as well. For example:
extern int LinkMyCodeStub;
static IncludeFile LinkMyModule(&LinkMyCodeStub);

Definition at line 73 of file IncludeFile.h.

Constructor & Destructor Documentation

IncludeFile::IncludeFile ( const void *  )
explicit

Definition at line 20 of file IncludeFile.cpp.


The documentation for this struct was generated from the following files: