summaryrefslogtreecommitdiff
path: root/include/llvm-c
diff options
context:
space:
mode:
authorEric Christopher <echristo@gmail.com>2013-04-22 22:47:22 +0000
committerEric Christopher <echristo@gmail.com>2013-04-22 22:47:22 +0000
commit3e39731e88f2d4f597cebc74388fd6650ca4f604 (patch)
treec2ad976c0ec348e36d363f5e02f02bc53326fa56 /include/llvm-c
parentd50dc20f06d9cf95562899020f773cd9f8309786 (diff)
downloadllvm-3e39731e88f2d4f597cebc74388fd6650ca4f604.tar.gz
llvm-3e39731e88f2d4f597cebc74388fd6650ca4f604.tar.bz2
llvm-3e39731e88f2d4f597cebc74388fd6650ca4f604.tar.xz
Move C++ code out of the C headers and into either C++ headers
or the C++ files themselves. This enables people to use just a C compiler to interoperate with LLVM. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180063 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm-c')
-rw-r--r--include/llvm-c/Core.h106
-rw-r--r--include/llvm-c/ExecutionEngine.h22
-rw-r--r--include/llvm-c/Object.h46
-rw-r--r--include/llvm-c/Target.h23
-rw-r--r--include/llvm-c/TargetMachine.h22
-rw-r--r--include/llvm-c/Transforms/PassManagerBuilder.h10
6 files changed, 1 insertions, 228 deletions
diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h
index 96359af51a..559c50ed3c 100644
--- a/include/llvm-c/Core.h
+++ b/include/llvm-c/Core.h
@@ -18,13 +18,6 @@
#include "llvm/Support/DataTypes.h"
#ifdef __cplusplus
-
-/* Need these includes to support the LLVM 'cast' template for the C++ 'wrap'
- and 'unwrap' conversion functions. */
-#include "llvm/IR/IRBuilder.h"
-#include "llvm/IR/Module.h"
-#include "llvm/PassRegistry.h"
-
extern "C" {
#endif
@@ -60,11 +53,6 @@ extern "C" {
* with C++ due to name mangling. So in addition to C, this interface enables
* tools written in such languages.
*
- * When included into a C++ source file, also declares 'wrap' and 'unwrap'
- * helpers to perform opaque reference<-->pointer conversions. These helpers
- * are shorter and more tightly typed than writing the casts by hand when
- * authoring bindings. In assert builds, they will do runtime type checking.
- *
* @{
*/
@@ -2690,100 +2678,6 @@ LLVMBool LLVMIsMultithreaded();
#ifdef __cplusplus
}
-
-namespace llvm {
- class MemoryBuffer;
- class PassManagerBase;
-
- #define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \
- inline ty *unwrap(ref P) { \
- return reinterpret_cast<ty*>(P); \
- } \
- \
- inline ref wrap(const ty *P) { \
- return reinterpret_cast<ref>(const_cast<ty*>(P)); \
- }
-
- #define DEFINE_ISA_CONVERSION_FUNCTIONS(ty, ref) \
- DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \
- \
- template<typename T> \
- inline T *unwrap(ref P) { \
- return cast<T>(unwrap(P)); \
- }
-
- #define DEFINE_STDCXX_CONVERSION_FUNCTIONS(ty, ref) \
- DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \
- \
- template<typename T> \
- inline T *unwrap(ref P) { \
- T *Q = (T*)unwrap(P); \
- assert(Q && "Invalid cast!"); \
- return Q; \
- }
-
- DEFINE_ISA_CONVERSION_FUNCTIONS (Type, LLVMTypeRef )
- DEFINE_ISA_CONVERSION_FUNCTIONS (Value, LLVMValueRef )
- DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Module, LLVMModuleRef )
- DEFINE_SIMPLE_CONVERSION_FUNCTIONS(BasicBlock, LLVMBasicBlockRef )
- DEFINE_SIMPLE_CONVERSION_FUNCTIONS(IRBuilder<>, LLVMBuilderRef )
- DEFINE_SIMPLE_CONVERSION_FUNCTIONS(MemoryBuffer, LLVMMemoryBufferRef )
- DEFINE_SIMPLE_CONVERSION_FUNCTIONS(LLVMContext, LLVMContextRef )
- DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Use, LLVMUseRef )
- DEFINE_STDCXX_CONVERSION_FUNCTIONS(PassManagerBase, LLVMPassManagerRef )
- DEFINE_STDCXX_CONVERSION_FUNCTIONS(PassRegistry, LLVMPassRegistryRef )
- /* LLVMModuleProviderRef exists for historical reasons, but now just holds a
- * Module.
- */
- inline Module *unwrap(LLVMModuleProviderRef MP) {
- return reinterpret_cast<Module*>(MP);
- }
-
- #undef DEFINE_STDCXX_CONVERSION_FUNCTIONS
- #undef DEFINE_ISA_CONVERSION_FUNCTIONS
- #undef DEFINE_SIMPLE_CONVERSION_FUNCTIONS
-
- /* Specialized opaque context conversions.
- */
- inline LLVMContext **unwrap(LLVMContextRef* Tys) {
- return reinterpret_cast<LLVMContext**>(Tys);
- }
-
- inline LLVMContextRef *wrap(const LLVMContext **Tys) {
- return reinterpret_cast<LLVMContextRef*>(const_cast<LLVMContext**>(Tys));
- }
-
- /* Specialized opaque type conversions.
- */
- inline Type **unwrap(LLVMTypeRef* Tys) {
- return reinterpret_cast<Type**>(Tys);
- }
-
- inline LLVMTypeRef *wrap(Type **Tys) {
- return reinterpret_cast<LLVMTypeRef*>(const_cast<Type**>(Tys));
- }
-
- /* Specialized opaque value conversions.
- */
- inline Value **unwrap(LLVMValueRef *Vals) {
- return reinterpret_cast<Value**>(Vals);
- }
-
- template<typename T>
- inline T **unwrap(LLVMValueRef *Vals, unsigned Length) {
- #ifdef DEBUG
- for (LLVMValueRef *I = Vals, *E = Vals + Length; I != E; ++I)
- cast<T>(*I);
- #endif
- (void)Length;
- return reinterpret_cast<T**>(Vals);
- }
-
- inline LLVMValueRef *wrap(const Value **Vals) {
- return reinterpret_cast<LLVMValueRef*>(const_cast<Value**>(Vals));
- }
-}
-
#endif /* !defined(__cplusplus) */
#endif /* !defined(LLVM_C_CORE_H) */
diff --git a/include/llvm-c/ExecutionEngine.h b/include/llvm-c/ExecutionEngine.h
index cb77bb2e2e..be763312d2 100644
--- a/include/llvm-c/ExecutionEngine.h
+++ b/include/llvm-c/ExecutionEngine.h
@@ -137,27 +137,7 @@ void *LLVMGetPointerToGlobal(LLVMExecutionEngineRef EE, LLVMValueRef Global);
*/
#ifdef __cplusplus
-}
-
-namespace llvm {
- struct GenericValue;
- class ExecutionEngine;
-
- #define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \
- inline ty *unwrap(ref P) { \
- return reinterpret_cast<ty*>(P); \
- } \
- \
- inline ref wrap(const ty *P) { \
- return reinterpret_cast<ref>(const_cast<ty*>(P)); \
- }
-
- DEFINE_SIMPLE_CONVERSION_FUNCTIONS(GenericValue, LLVMGenericValueRef )
- DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ExecutionEngine, LLVMExecutionEngineRef)
-
- #undef DEFINE_SIMPLE_CONVERSION_FUNCTIONS
-}
-
+}
#endif /* defined(__cplusplus) */
#endif
diff --git a/include/llvm-c/Object.h b/include/llvm-c/Object.h
index e2dad62b4e..ecccfeed7f 100644
--- a/include/llvm-c/Object.h
+++ b/include/llvm-c/Object.h
@@ -23,8 +23,6 @@
#include "llvm/Config/llvm-config.h"
#ifdef __cplusplus
-#include "llvm/Object/ObjectFile.h"
-
extern "C" {
#endif
@@ -99,50 +97,6 @@ const char *LLVMGetRelocationValueString(LLVMRelocationIteratorRef RI);
#ifdef __cplusplus
}
-
-namespace llvm {
- namespace object {
- inline ObjectFile *unwrap(LLVMObjectFileRef OF) {
- return reinterpret_cast<ObjectFile*>(OF);
- }
-
- inline LLVMObjectFileRef wrap(const ObjectFile *OF) {
- return reinterpret_cast<LLVMObjectFileRef>(const_cast<ObjectFile*>(OF));
- }
-
- inline section_iterator *unwrap(LLVMSectionIteratorRef SI) {
- return reinterpret_cast<section_iterator*>(SI);
- }
-
- inline LLVMSectionIteratorRef
- wrap(const section_iterator *SI) {
- return reinterpret_cast<LLVMSectionIteratorRef>
- (const_cast<section_iterator*>(SI));
- }
-
- inline symbol_iterator *unwrap(LLVMSymbolIteratorRef SI) {
- return reinterpret_cast<symbol_iterator*>(SI);
- }
-
- inline LLVMSymbolIteratorRef
- wrap(const symbol_iterator *SI) {
- return reinterpret_cast<LLVMSymbolIteratorRef>
- (const_cast<symbol_iterator*>(SI));
- }
-
- inline relocation_iterator *unwrap(LLVMRelocationIteratorRef SI) {
- return reinterpret_cast<relocation_iterator*>(SI);
- }
-
- inline LLVMRelocationIteratorRef
- wrap(const relocation_iterator *SI) {
- return reinterpret_cast<LLVMRelocationIteratorRef>
- (const_cast<relocation_iterator*>(SI));
- }
-
- }
-}
-
#endif /* defined(__cplusplus) */
#endif
diff --git a/include/llvm-c/Target.h b/include/llvm-c/Target.h
index 57abfa0207..80fc3e5ad7 100644
--- a/include/llvm-c/Target.h
+++ b/include/llvm-c/Target.h
@@ -235,29 +235,6 @@ void LLVMDisposeTargetData(LLVMTargetDataRef);
#ifdef __cplusplus
}
-
-namespace llvm {
- class DataLayout;
- class TargetLibraryInfo;
-
- inline DataLayout *unwrap(LLVMTargetDataRef P) {
- return reinterpret_cast<DataLayout*>(P);
- }
-
- inline LLVMTargetDataRef wrap(const DataLayout *P) {
- return reinterpret_cast<LLVMTargetDataRef>(const_cast<DataLayout*>(P));
- }
-
- inline TargetLibraryInfo *unwrap(LLVMTargetLibraryInfoRef P) {
- return reinterpret_cast<TargetLibraryInfo*>(P);
- }
-
- inline LLVMTargetLibraryInfoRef wrap(const TargetLibraryInfo *P) {
- TargetLibraryInfo *X = const_cast<TargetLibraryInfo*>(P);
- return reinterpret_cast<LLVMTargetLibraryInfoRef>(X);
- }
-}
-
#endif /* defined(__cplusplus) */
#endif
diff --git a/include/llvm-c/TargetMachine.h b/include/llvm-c/TargetMachine.h
index a02161aaa4..5878723508 100644
--- a/include/llvm-c/TargetMachine.h
+++ b/include/llvm-c/TargetMachine.h
@@ -117,30 +117,8 @@ LLVMBool LLVMTargetMachineEmitToFile(LLVMTargetMachineRef T, LLVMModuleRef M,
/** Compile the LLVM IR stored in \p M and store the result in \p OutMemBuf. */
LLVMBool LLVMTargetMachineEmitToMemoryBuffer(LLVMTargetMachineRef T, LLVMModuleRef M,
LLVMCodeGenFileType codegen, char** ErrorMessage, LLVMMemoryBufferRef *OutMemBuf);
-
-
-
#ifdef __cplusplus
}
-
-namespace llvm {
- class TargetMachine;
- class Target;
-
- inline TargetMachine *unwrap(LLVMTargetMachineRef P) {
- return reinterpret_cast<TargetMachine*>(P);
- }
- inline Target *unwrap(LLVMTargetRef P) {
- return reinterpret_cast<Target*>(P);
- }
- inline LLVMTargetMachineRef wrap(const TargetMachine *P) {
- return reinterpret_cast<LLVMTargetMachineRef>(
- const_cast<TargetMachine*>(P));
- }
- inline LLVMTargetRef wrap(const Target * P) {
- return reinterpret_cast<LLVMTargetRef>(const_cast<Target*>(P));
- }
-}
#endif
#endif
diff --git a/include/llvm-c/Transforms/PassManagerBuilder.h b/include/llvm-c/Transforms/PassManagerBuilder.h
index 82e513d490..545f8aae8c 100644
--- a/include/llvm-c/Transforms/PassManagerBuilder.h
+++ b/include/llvm-c/Transforms/PassManagerBuilder.h
@@ -86,16 +86,6 @@ void LLVMPassManagerBuilderPopulateLTOPassManager(LLVMPassManagerBuilderRef PMB,
#ifdef __cplusplus
}
-
-namespace llvm {
- inline PassManagerBuilder *unwrap(LLVMPassManagerBuilderRef P) {
- return reinterpret_cast<PassManagerBuilder*>(P);
- }
-
- inline LLVMPassManagerBuilderRef wrap(PassManagerBuilder *P) {
- return reinterpret_cast<LLVMPassManagerBuilderRef>(P);
- }
-}
#endif
#endif