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

Amaury SECHET via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 3 22:12:27 PDT 2016


deadalnix added inline comments.

================
Comment at: lib/IR/Core.cpp:161-162
@@ +160,4 @@
+const char *LLVMGetModuleIdentifier(LLVMModuleRef M, unsigned *Len) {
+  auto &Str = unwrap(M)->getModuleIdentifier();
+  auto IdentLen = Str.length();
+  assert(IdentLen < UINT_MAX && "Module identifier is too long");
----------------
As said, just use size_t and get rid of the assert.

================
Comment at: tools/llvm-c-test/echo.cpp:881
@@ -871,1 +880,3 @@
+      report_fatal_error("LLVM{Set,Get}ModuleIdentifier failed");
+  LLVMSetModuleIdentifier(M, ModuleName, strlen(ModuleName));
 
----------------
This test take a module as input, read it, and write a copy in another module. That allow to test read and write operations.

Reading the identifier from the Src module writing it in the Dst module seems like the way to do that.


http://reviews.llvm.org/D18736





More information about the llvm-commits mailing list