summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Xcode/LLVM.xcodeproj/project.pbxproj4
-rw-r--r--include/llvm-c/Core.h103
-rw-r--r--include/llvm/Support/CHelpers.h104
-rw-r--r--lib/Bitcode/Writer/BitWriter.cpp1
-rw-r--r--lib/VMCore/Core.cpp14
5 files changed, 101 insertions, 125 deletions
diff --git a/Xcode/LLVM.xcodeproj/project.pbxproj b/Xcode/LLVM.xcodeproj/project.pbxproj
index 600a9cc655..a195dbda59 100644
--- a/Xcode/LLVM.xcodeproj/project.pbxproj
+++ b/Xcode/LLVM.xcodeproj/project.pbxproj
@@ -170,8 +170,6 @@
9FE25D940CAB16FB005383FC /* RegisterCoalescer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RegisterCoalescer.cpp; sourceTree = "<group>"; };
9FE25D950CAB1724005383FC /* APFloat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = APFloat.cpp; sourceTree = "<group>"; };
9FE25D960CAB1759005383FC /* TargetCallingConv.td */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = TargetCallingConv.td; sourceTree = "<group>"; };
- 9FE25D970CAB17F9005383FC /* DominatorCalculation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DominatorCalculation.h; path = ../lib/VMCore/DominatorCalculation.h; sourceTree = SOURCE_ROOT; };
- 9FE25D980CAB17F9005383FC /* DominatorInternals.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DominatorInternals.cpp; path = ../lib/VMCore/DominatorInternals.cpp; sourceTree = SOURCE_ROOT; };
9FE4508B0C77A77000C4FEA4 /* ARMCodeEmitter.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = ARMCodeEmitter.cpp; sourceTree = "<group>"; };
9FE4508C0C77A77000C4FEA4 /* ARMGenAsmWriter.inc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.pascal; path = ARMGenAsmWriter.inc; sourceTree = "<group>"; };
9FE4508D0C77A77000C4FEA4 /* ARMGenDAGISel.inc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.pascal; path = ARMGenDAGISel.inc; sourceTree = "<group>"; };
@@ -1345,8 +1343,6 @@
9F77937D0C73C4F400551F9C /* ConstantFold.h */,
DE66EC6008ABE86A00323D32 /* Constants.cpp */,
9FD3E5900CA0129D00E54D15 /* Core.cpp */,
- 9FE25D970CAB17F9005383FC /* DominatorCalculation.h */,
- 9FE25D980CAB17F9005383FC /* DominatorInternals.cpp */,
DE66EC6108ABE86A00323D32 /* Dominators.cpp */,
DE66EC6208ABE86A00323D32 /* Function.cpp */,
DE66EC6308ABE86A00323D32 /* Globals.cpp */,
diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h
index 47b89aa513..fb01b83735 100644
--- a/include/llvm-c/Core.h
+++ b/include/llvm-c/Core.h
@@ -23,12 +23,23 @@
|* 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. *|
+|* *|
\*===----------------------------------------------------------------------===*/
#ifndef LLVM_C_CORE_H
#define LLVM_C_CORE_H
#ifdef __cplusplus
+
+/* Need these includes to support the LLVM 'cast' template for the C++ 'wrap'
+ and 'unwrap' conversion functions. */
+#include "llvm/Module.h"
+#include "llvm/Support/LLVMBuilder.h"
+
extern "C" {
#endif
@@ -412,6 +423,94 @@ LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1,
#ifdef __cplusplus
}
-#endif
-#endif
+namespace llvm {
+ /* Opaque module conversions
+ */
+ inline Module *unwrap(LLVMModuleRef M) {
+ return reinterpret_cast<Module*>(M);
+ }
+
+ inline LLVMModuleRef wrap(Module *M) {
+ return reinterpret_cast<LLVMModuleRef>(M);
+ }
+
+ /* Opaque type conversions
+ */
+ inline Type *unwrap(LLVMTypeRef Ty) {
+ return reinterpret_cast<Type*>(Ty);
+ }
+
+ template<typename T>
+ inline T *unwrap(LLVMTypeRef Ty) {
+ return cast<T>(unwrap(Ty));
+ }
+
+ inline Type **unwrap(LLVMTypeRef* Tys) {
+ return reinterpret_cast<Type**>(Tys);
+ }
+
+ inline LLVMTypeRef wrap(const Type *Ty) {
+ return reinterpret_cast<LLVMTypeRef>(const_cast<Type*>(Ty));
+ }
+
+ inline LLVMTypeRef *wrap(const Type **Tys) {
+ return reinterpret_cast<LLVMTypeRef*>(const_cast<Type**>(Tys));
+ }
+
+ /* Opaque value conversions
+ */
+ inline Value *unwrap(LLVMValueRef Val) {
+ return reinterpret_cast<Value*>(Val);
+ }
+
+ template<typename T>
+ inline T *unwrap(LLVMValueRef Val) {
+ return cast<T>(unwrap(Val));
+ }
+
+ inline Value **unwrap(LLVMValueRef *Vals) {
+ return reinterpret_cast<Value**>(Vals);
+ }
+
+ template<typename T>
+ inline T **unwrap(LLVMValueRef *Vals, unsigned Length) {
+ #if DEBUG
+ for (LLVMValueRef *I = Vals, E = Vals + Length; I != E; ++I)
+ cast<T>(*I);
+ #endif
+ return reinterpret_cast<T**>(Vals);
+ }
+
+ inline LLVMValueRef wrap(const Value *Val) {
+ return reinterpret_cast<LLVMValueRef>(const_cast<Value*>(Val));
+ }
+
+ inline LLVMValueRef *wrap(const Value **Vals) {
+ return reinterpret_cast<LLVMValueRef*>(const_cast<Value**>(Vals));
+ }
+
+ /* Basic block conversions
+ */
+ inline BasicBlock *unwrap(LLVMBasicBlockRef BBRef) {
+ return reinterpret_cast<BasicBlock*>(BBRef);
+ }
+
+ inline LLVMBasicBlockRef wrap(const BasicBlock *BB) {
+ return reinterpret_cast<LLVMBasicBlockRef>(const_cast<BasicBlock*>(BB));
+ }
+
+ /* Opaque builder conversions.
+ */
+ inline LLVMBuilder *unwrap(LLVMBuilderRef B) {
+ return reinterpret_cast<LLVMBuilder*>(B);
+ }
+
+ inline LLVMBuilderRef wrap(LLVMBuilder *B) {
+ return reinterpret_cast<LLVMBuilderRef>(B);
+ }
+}
+
+#endif /* !defined(__cplusplus) */
+
+#endif /* !defined(LLVM_C_CORE_H) */
diff --git a/include/llvm/Support/CHelpers.h b/include/llvm/Support/CHelpers.h
deleted file mode 100644
index 0ae7503ab0..0000000000
--- a/include/llvm/Support/CHelpers.h
+++ /dev/null
@@ -1,104 +0,0 @@
-//===-- Support/CHelpers.h - Utilities for writing C bindings -------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file was developed by the LLVM research group and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// These opaque reference<-->pointer conversions are shorter and more tightly
-// typed than writing the casts by hand in C bindings. In assert builds, they
-// will do type checking.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_SUPPORT_CHELPERS_H
-#define LLVM_SUPPORT_CHELPERS_H
-
-#include "llvm/Module.h"
-#include "llvm/Type.h"
-#include "llvm/Value.h"
-
-typedef struct LLVMOpaqueModule *LLVMModuleRef;
-typedef struct LLVMOpaqueType *LLVMTypeRef;
-typedef struct LLVMOpaqueValue *LLVMValueRef;
-
-namespace llvm {
- /// Opaque module conversions
- ///
- inline Module *unwrap(LLVMModuleRef M) {
- return reinterpret_cast<Module*>(M);
- }
-
- inline LLVMModuleRef wrap(Module *M) {
- return reinterpret_cast<LLVMModuleRef>(M);
- }
-
- /// Opaque type conversions
- ///
- inline Type *unwrap(LLVMTypeRef Ty) {
- return reinterpret_cast<Type*>(Ty);
- }
-
- template<typename T>
- inline T *unwrap(LLVMTypeRef Ty) {
- return cast<T>(unwrap(Ty));
- }
-
- inline Type **unwrap(LLVMTypeRef* Tys) {
- return reinterpret_cast<Type**>(Tys);
- }
-
- inline LLVMTypeRef wrap(const Type *Ty) {
- return reinterpret_cast<LLVMTypeRef>(const_cast<Type*>(Ty));
- }
-
- inline LLVMTypeRef *wrap(const Type **Tys) {
- return reinterpret_cast<LLVMTypeRef*>(const_cast<Type**>(Tys));
- }
-
- /// Opaque value conversions
- ///
- inline Value *unwrap(LLVMValueRef Val) {
- return reinterpret_cast<Value*>(Val);
- }
-
- template<typename T>
- inline T *unwrap(LLVMValueRef Val) {
- return cast<T>(unwrap(Val));
- }
-
- inline Value **unwrap(LLVMValueRef *Vals) {
- return reinterpret_cast<Value**>(Vals);
- }
-
- template<typename T>
- inline T **unwrap(LLVMValueRef *Vals, unsigned Length) {
- #if DEBUG
- for (LLVMValueRef *I = Vals, E = Vals + Length; I != E; ++I)
- cast<T>(*I);
- #endif
- return reinterpret_cast<T**>(Vals);
- }
-
- inline LLVMValueRef wrap(const Value *Val) {
- return reinterpret_cast<LLVMValueRef>(const_cast<Value*>(Val));
- }
-
- inline LLVMValueRef *wrap(const Value **Vals) {
- return reinterpret_cast<LLVMValueRef*>(const_cast<Value**>(Vals));
- }
-
- /// Basic block conversions
- ///
- inline BasicBlock *unwrap(LLVMBasicBlockRef BBRef) {
- return reinterpret_cast<BasicBlock*>(BBRef);
- }
-
- inline LLVMBasicBlockRef wrap(const BasicBlock *BB) {
- return reinterpret_cast<LLVMBasicBlockRef>(const_cast<BasicBlock*>(BB));
- }
-}
-
-#endif
diff --git a/lib/Bitcode/Writer/BitWriter.cpp b/lib/Bitcode/Writer/BitWriter.cpp
index b2e7ac2ec0..8f562e98d9 100644
--- a/lib/Bitcode/Writer/BitWriter.cpp
+++ b/lib/Bitcode/Writer/BitWriter.cpp
@@ -9,7 +9,6 @@
#include "llvm-c/BitWriter.h"
#include "llvm/Bitcode/ReaderWriter.h"
-#include "llvm/Support/CHelpers.h"
#include <fstream>
using namespace llvm;
diff --git a/lib/VMCore/Core.cpp b/lib/VMCore/Core.cpp
index f35951d45b..b6a825462a 100644
--- a/lib/VMCore/Core.cpp
+++ b/lib/VMCore/Core.cpp
@@ -17,25 +17,11 @@
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/GlobalVariable.h"
-#include "llvm/Support/CHelpers.h"
-#include "llvm/Support/LLVMBuilder.h"
#include "llvm/TypeSymbolTable.h"
#include <cassert>
using namespace llvm;
-namespace {
- /// Opaque builder conversions.
- ///
- inline LLVMBuilder *unwrap(LLVMBuilderRef B) {
- return reinterpret_cast<LLVMBuilder*>(B);
- }
-
- inline LLVMBuilderRef wrap(LLVMBuilder *B) {
- return reinterpret_cast<LLVMBuilderRef>(B);
- }
-}
-
/*===-- Operations on modules ---------------------------------------------===*/