[cfe-dev] LLVM Project for Clang plugin

tmcclory at mail.eecis.udel.edu tmcclory at mail.eecis.udel.edu
Mon Jun 13 14:40:32 PDT 2011


I am writing a clang plugin using clang/examples/PrintFunctionNames as a
basis.  Currently, my code is in the clang/examples directory and the
resultant library is placed in llvm/Debug+Asserts/lib.  I would like to
have the plugin source and object code reside outside of the llvm
source/object trees.

It seems to me that I should adapt clang/examples/PrintFunctionNames into
the format of llvm/projects/sample.  Does this seem like the best
approach?  If so, could I have some feedback?

I've tried using llvm/projects/sample as a template.  In one attempt, I
copied the print PrintFunctionNames directory in lib/ directory of a new
project.  I replaced the PrintFunctionNames Makefile with
lib/sample/Makefile and tried to adapt it based on clang/Makefile, which
is included by the original Makefile.  I updated LIBRARY_NAME and such. I
added the following lines to the Makefile, after 'include
$(LEVEL)/Makefile.common':

CPP.Flags += -I$(CLANG_SRC)/include -I$(CLANG_OBJ)/include -L$(CLANG_SRC)/lib
LINK_COMPONENTS = all
LIBS += -lclangParse \
    -lclangSema \
    -lclangAnalysis \
    -lclangAST \
        -lclangFrontend \
        -lclangLex \
        -lclangBasic

These additions do not appear to be sufficient for including and linking
against clang components, as I'm getting pages of "X was not declared in
this scope" errors when I try to run make.  Any suggestions as to where
I'm going wrong?

Thanks,
Tim





More information about the cfe-dev mailing list