Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,21 +104,21 @@ class ExampleASTConsumer : public ASTConsumer {

class ExampleFrontendAction : public ASTFrontendAction {
public:
virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI, StringRef file) {
return new ExampleASTConsumer(&CI); // pass CI pointer to ASTConsumer
virtual std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, StringRef file) {
return std::unique_ptr<ASTConsumer>(new ExampleASTConsumer(&CI)); // pass CI pointer to ASTConsumer
}
};



int main(int argc, const char **argv) {
// parse the command-line args passed to your code
CommonOptionsParser op(argc, argv);
static cl::OptionCategory MyToolCategory("My tool options");
CommonOptionsParser op(argc, argv, MyToolCategory);
// create a new Clang Tool instance (a LibTooling environment)
ClangTool Tool(op.getCompilations(), op.getSourcePathList());

// run the Clang Tool, creating a new FrontendAction (explained below)
int result = Tool.run(newFrontendActionFactory<ExampleFrontendAction>());
int result = Tool.run(newFrontendActionFactory<ExampleFrontendAction>().get());

errs() << "\nFound " << numFunctions << " functions.\n\n";
// print out the rewritten source code ("rewriter" is a global var.)
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader support mc option

USEDLIBS = clangFrontend.a clangSerialization.a clangDriver.a \
clangTooling.a clangParse.a clangSema.a \
clangAnalysis.a clangRewriteFrontend.a clangRewriteCore.a \
clangAnalysis.a clangRewriteFrontend.a clangRewrite.a \
clangEdit.a clangAST.a clangLex.a clangBasic.a

include $(CLANG_LEVEL)/Makefile
4 changes: 2 additions & 2 deletions run_example.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
LLVM_DIR=~/static_analysis/llvm/ #the location of your llvm dir
$LLVM_DIR/Debug+Asserts/bin/example test.c --
LLVM_DIR=~/build_llvm #the location of your llvm dir
$LLVM_DIR/Release+Asserts/bin/example test.c --