[PATCH] D52693: [LLVM-C] Add an accessor for the kind of a Metadata Node
Robert Widmann via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 29 14:24:45 PDT 2018
CodaFi updated this revision to Diff 167627.
Repository:
rL LLVM
https://reviews.llvm.org/D52693
Files:
include/llvm-c/DebugInfo.h
lib/IR/DebugInfo.cpp
Index: lib/IR/DebugInfo.cpp
===================================================================
--- lib/IR/DebugInfo.cpp
+++ lib/IR/DebugInfo.cpp
@@ -1354,3 +1354,14 @@
void LLVMSetSubprogram(LLVMValueRef Func, LLVMMetadataRef SP) {
unwrap<Function>(Func)->setSubprogram(unwrap<DISubprogram>(SP));
}
+
+LLVMMetadataKind LLVMGetMetadataKind(LLVMMetadataRef Metadata) {
+ switch(unwrap(Metadata)->getMetadataID()) {
+#define HANDLE_METADATA_LEAF(CLASS) \
+ case Metadata::CLASS##Kind: \
+ return (LLVMMetadataKind)LLVM##CLASS##MetadataKind;
+#include "llvm/IR/Metadata.def"
+ default:
+ return (LLVMMetadataKind)LLVMGenericDINodeMetadataKind;
+ }
+}
Index: include/llvm-c/DebugInfo.h
===================================================================
--- include/llvm-c/DebugInfo.h
+++ include/llvm-c/DebugInfo.h
@@ -126,6 +126,44 @@
LLVMDWARFEmissionLineTablesOnly
} LLVMDWARFEmissionKind;
+/**
+ * The kind of metadata nodes.
+ */
+enum {
+ LLVMMDStringMetadataKind,
+ LLVMConstantAsMetadataMetadataKind,
+ LLVMLocalAsMetadataMetadataKind,
+ LLVMDistinctMDOperandPlaceholderMetadataKind,
+ LLVMMDTupleMetadataKind,
+ LLVMDILocationMetadataKind,
+ LLVMDIExpressionMetadataKind,
+ LLVMDIGlobalVariableExpressionMetadataKind,
+ LLVMGenericDINodeMetadataKind,
+ LLVMDISubrangeMetadataKind,
+ LLVMDIEnumeratorMetadataKind,
+ LLVMDIBasicTypeMetadataKind,
+ LLVMDIDerivedTypeMetadataKind,
+ LLVMDICompositeTypeMetadataKind,
+ LLVMDISubroutineTypeMetadataKind,
+ LLVMDIFileMetadataKind,
+ LLVMDICompileUnitMetadataKind,
+ LLVMDISubprogramMetadataKind,
+ LLVMDILexicalBlockMetadataKind,
+ LLVMDILexicalBlockFileMetadataKind,
+ LLVMDINamespaceMetadataKind,
+ LLVMDIModuleMetadataKind,
+ LLVMDITemplateTypeParameterMetadataKind,
+ LLVMDITemplateValueParameterMetadataKind,
+ LLVMDIGlobalVariableMetadataKind,
+ LLVMDILocalVariableMetadataKind,
+ LLVMDILabelMetadataKind,
+ LLVMDIObjCPropertyMetadataKind,
+ LLVMDIImportedEntityMetadataKind,
+ LLVMDIMacroMetadataKind,
+ LLVMDIMacroFileMetadataKind
+};
+typedef unsigned LLVMMetadataKind;
+
/**
* An LLVM DWARF type encoding.
*/
@@ -1153,6 +1191,13 @@
*/
void LLVMSetSubprogram(LLVMValueRef Func, LLVMMetadataRef SP);
+/**
+ * Obtain the enumerated type of a Metadata instance.
+ *
+ * @see llvm::Metadata::getMetadataID()
+ */
+LLVMMetadataKind LLVMGetMetadataKind(LLVMMetadataRef Metadata);
+
#ifdef __cplusplus
} /* end extern "C" */
#endif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52693.167627.patch
Type: text/x-patch
Size: 2450 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180929/7e2dfeec/attachment.bin>
More information about the llvm-commits
mailing list