[PATCH] D18736: [llvm-c] Improve IR Introspection: Add LLVM{Get, Set}ModuleIdentifier

Jakob Bornecrantz via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 3 04:47:54 PDT 2016


Wallbraker added a subscriber: Wallbraker.
Wallbraker requested changes to this revision.
Wallbraker added a reviewer: Wallbraker.

================
Comment at: include/llvm-c/Core.h:483-496
@@ -482,2 +482,16 @@
 
 /**
+ * Obtain the identifier of a module. The result must be discarded with
+ * LLVMDisposeMessage.
+ *
+ * @see Module::getModuleIdentifier()
+ */
+char *LLVMGetModuleIdentifier(LLVMModuleRef M);
+
+/**
+ * Set the identifier of a module.
+ *
+ * @see Module::setModuleIdentifier()
+ */
+void LLVMSetModuleIdentifier(LLVMModuleRef M, const char *ID);
+
----------------
Please add a length parameter for both functions. Not all languages keep their string zero terminated and keep track of the length. For C StringRef will call strlen so the cost is the same.

```
char *LLVMGetModuleIdentifier(LLVMModuleRef M, size_t *Length);
void LLVMSetModuleIdentifier(LLVMModuleRef M, const char *ID, size_t Length);
```


http://reviews.llvm.org/D18736





More information about the llvm-commits mailing list