I have created this regex and used the value to print out into a string.
std::string s (filename);
std::smatch m;
std::regex e ("\/(?:.(?!\/))+$");
while (std::regex_search (s,m,e)) {
for (auto p:m) std::cout << p << " ";
s = m.suffix().str();
}
std::string currFileName = s;
std::string Original = filename;
std::string newFile = Original + currFileName;
std::cout << newFile;
The problem is it does not show in the terminal.
Printed value
/simple-loops.cc /home/fypj/build/simple-loops.cc
Expected Value
/home/fypj/build/simple-loops.cc/simple-loops.cc
You may ask what filename is
llvm::StringRef filename;
SourceLocation ST = f->getSourceRange().getBegin();
filename = Rewrite.getSourceMgr().getFilename(ST);