[cfe-dev] Clang Source to Source Transformation [compile with tool]

Mustakimur Rahman Khandaker via cfe-dev cfe-dev at lists.llvm.org
Mon Jun 19 08:46:23 PDT 2017


Hi

I am working on some Clang source-to-source transformation. I am doing 
it from Clang source code: clang/tools/extra. What I do is that I am 
adding a printf("Hello World\n"); at the beginning of the main method. 
It works perfectly, I run my tool as bin/add-code ../../test/hello.c 
and it turns:

#include <stdio.h>

int main(){
  printf("This is from main ....\n");

  return 0;
}
to this:

#include <stdio.h>

int main(){
  printf("Hello World\n");
  printf("This is from main ....\n");

  return 0;
}
add-code is my clang libtool that I have written.
But this rewritter only write changes to the terminal; while I want to 
compile hello.c with the modification and want to do it with clang 
command, clang -c hello.c not like I have done here.
How could I do that?


Best Regards
Mustakimur Rahman Khandaker
Teaching Assistant and Graduate Student
Department of Computer Science
Florida State University
http://ww2.cs.fsu.edu/~khandake/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170619/6c657966/attachment.html>


More information about the cfe-dev mailing list