Index: include/llvm-c/DebugInfo.h =================================================================== --- include/llvm-c/DebugInfo.h +++ include/llvm-c/DebugInfo.h @@ -13,14 +13,6 @@ #include "llvm-c/Core.h" -/// Represents a piece of debug metadata attached to a Value. -/// @see llvm::Metadata -typedef struct LLVMOpaqueMetadata *LLVMMetadataRef; - -/// Represents a builder that can create debug metadata. -/// @see llvm::DIBuilder -typedef struct LLVMOpaqueDIBuilder *LLVMDIBuilderRef; - #ifdef __cplusplus extern "C" { #endif Index: include/llvm-c/Types.h =================================================================== --- include/llvm-c/Types.h +++ include/llvm-c/Types.h @@ -76,6 +76,13 @@ typedef struct LLVMOpaqueValue *LLVMValueRef; /** + * Represents metadata attached to values in LLVM IR. + * + * This models llvm::Metadata + */ +typedef struct LLVMOpaqueMetadata *LLVMMetadataRef; + +/** * Represents a basic block of instructions in LLVM IR. * * This models llvm::BasicBlock. @@ -90,6 +97,13 @@ typedef struct LLVMOpaqueBuilder *LLVMBuilderRef; /** + * Represents an LLVM debug info builder. + * + * This models llvm::DIBuilder. + */ +typedef struct LLVMOpaqueDIBuilder *LLVMDIBuilderRef; + +/** * Interface used to provide a module to JIT or interpreter. * This is now just a synonym for llvm::Module, but we have to keep using the * different type to keep binary compatibility. Index: include/llvm/IR/DIBuilder.h =================================================================== --- include/llvm/IR/DIBuilder.h +++ include/llvm/IR/DIBuilder.h @@ -782,6 +782,9 @@ } }; + // Create wrappers for C Binding types (see CBindingWrapping.h). + DEFINE_ISA_CONVERSION_FUNCTIONS(DIBuilder, LLVMDIBuilderRef) + } // end namespace llvm #endif // LLVM_IR_DIBUILDER_H Index: include/llvm/IR/Metadata.h =================================================================== --- include/llvm/IR/Metadata.h +++ include/llvm/IR/Metadata.h @@ -133,6 +133,14 @@ /// @} }; +// Create wrappers for C Binding types (see CBindingWrapping.h). +DEFINE_ISA_CONVERSION_FUNCTIONS(Metadata, LLVMMetadataRef) + +// Specialized opaque metadata conversions. +inline Metadata **unwrap(LLVMMetadataRef *MDs) { + return reinterpret_cast(MDs); +} + #define HANDLE_METADATA(CLASS) class CLASS; #include "llvm/IR/Metadata.def" Index: lib/IR/DebugInfo.cpp =================================================================== --- lib/IR/DebugInfo.cpp +++ lib/IR/DebugInfo.cpp @@ -665,15 +665,6 @@ // LLVM C API implementations. //===----------------------------------------------------------------------===// -namespace llvm { -DEFINE_ISA_CONVERSION_FUNCTIONS(DIBuilder, LLVMDIBuilderRef) -DEFINE_ISA_CONVERSION_FUNCTIONS(Metadata, LLVMMetadataRef) - -inline Metadata **unwrap(LLVMMetadataRef *Vals) { - return reinterpret_cast(Vals); -} -} - template DIT *unwrapDI(LLVMMetadataRef Ref) { return (DIT *)(Ref ? unwrap(Ref) : nullptr); } @@ -1123,7 +1114,7 @@ LLVMDIBuilderCreateGlobalVariableExpression( LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, const char *LinkageName, LLVMMetadataRef File, unsigned LineNumber, - LLVMMetadataRef Ty, uint8_t isLocalToUnit, LLVMDIExpressionRef Expr) { + LLVMMetadataRef Ty, uint8_t isLocalToUnit, LLVMMetadataRef Expr) { auto E = unwrap(Builder)->createGlobalVariableExpression( unwrapDI(Scope), Name, LinkageName, unwrapDI(File), LineNumber, unwrapDI(Ty), isLocalToUnit);