function that returns source line number
authorweiyu <weiyuluo1232@gmail.com>
Fri, 14 Jun 2019 22:36:53 +0000 (15:36 -0700)
committerweiyu <weiyuluo1232@gmail.com>
Fri, 14 Jun 2019 22:36:53 +0000 (15:36 -0700)
getPosition.hpp [new file with mode: 0644]

diff --git a/getPosition.hpp b/getPosition.hpp
new file mode 100644 (file)
index 0000000..f26d172
--- /dev/null
@@ -0,0 +1,19 @@
+#pragma once
+
+#include <llvm/IR/DebugLoc.h>
+//#include <llvm/IR/Constant.h>
+//#include <llvm/IR/Instruction.h>
+//#include <llvm/IR/IRBuilder.h>
+//#include <llvm/Support/raw_ostream.h>
+
+Value *getPosition( Instruction * I, IRBuilder <> IRB)
+{
+       const DebugLoc & debug_location = I->getDebugLoc ();
+       std::string position_string;
+       {
+               llvm::raw_string_ostream position_stream (position_string);
+               debug_location . print (position_stream);
+       }
+
+       return IRB . CreateGlobalStringPtr (position_string);
+}