forked from OSchip/llvm-project
Add skeleton code to make wpa call the analysis engine.
llvm-svn: 107646
This commit is contained in:
parent
5b488b1e6c
commit
2231a920d0
|
@ -16,7 +16,8 @@ NO_INSTALL = 1
|
|||
TOOL_NO_EXPORTS = 1
|
||||
|
||||
LINK_COMPONENTS := asmparser bitreader mc core
|
||||
USEDLIBS = clangIndex.a clangFrontend.a clangDriver.a clangSema.a \
|
||||
clangAnalysis.a clangAST.a clangParse.a clangLex.a clangBasic.a
|
||||
USEDLIBS = clangChecker.a clangIndex.a clangFrontend.a clangDriver.a \
|
||||
clangSema.a clangAnalysis.a clangAST.a clangParse.a clangLex.a \
|
||||
clangBasic.a
|
||||
|
||||
include $(CLANG_LEVEL)/Makefile
|
||||
|
|
|
@ -14,6 +14,10 @@
|
|||
|
||||
#include "clang/Basic/FileManager.h"
|
||||
#include "clang/Basic/SourceManager.h"
|
||||
#include "clang/Checker/PathSensitive/AnalysisManager.h"
|
||||
#include "clang/Checker/PathSensitive/GRExprEngine.h"
|
||||
#include "clang/Checker/PathSensitive/GRTransferFuncs.h"
|
||||
#include "clang/Checker/Checkers/LocalCheckers.h"
|
||||
#include "clang/Frontend/ASTUnit.h"
|
||||
#include "clang/Frontend/CompilerInstance.h"
|
||||
#include "clang/Index/CallGraph.h"
|
||||
|
@ -21,6 +25,7 @@
|
|||
#include "clang/Index/TranslationUnit.h"
|
||||
#include "clang/Index/DeclReferenceMap.h"
|
||||
#include "clang/Index/SelectorMap.h"
|
||||
#include "clang/Lex/Preprocessor.h"
|
||||
#include "llvm/ADT/IntrusiveRefCntPtr.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
|
@ -52,6 +57,10 @@ public:
|
|||
virtual ASTContext &getASTContext() {
|
||||
return AST->getASTContext();
|
||||
}
|
||||
|
||||
virtual Preprocessor &getPreprocessor() {
|
||||
return AST->getPreprocessor();
|
||||
}
|
||||
|
||||
virtual DeclReferenceMap &getDeclReferenceMap() {
|
||||
return DeclRefMap;
|
||||
|
@ -101,8 +110,8 @@ int main(int argc, char **argv) {
|
|||
|
||||
// Feed all ASTUnits to the Indexer.
|
||||
for (unsigned i = 0, e = ASTUnits.size(); i != e; ++i) {
|
||||
ASTUnitTU TU(ASTUnits[i]);
|
||||
Idxer.IndexAST(&TU);
|
||||
ASTUnitTU *TU = new ASTUnitTU(ASTUnits[i]);
|
||||
Idxer.IndexAST(TU);
|
||||
}
|
||||
|
||||
Entity Ent = Entity::get(AnalyzeFunction, Prog);
|
||||
|
@ -112,5 +121,25 @@ int main(int argc, char **argv) {
|
|||
|
||||
if (!FD)
|
||||
return 0;
|
||||
|
||||
// Create an analysis engine.
|
||||
Preprocessor &PP = TU->getPreprocessor();
|
||||
|
||||
// Hard code options for now.
|
||||
AnalysisManager AMgr(TU->getASTContext(), PP.getDiagnostics(),
|
||||
PP.getLangOptions(), /* PathDiagnostic */ 0,
|
||||
CreateRegionStoreManager,
|
||||
CreateRangeConstraintManager,
|
||||
/* MaxNodes */ 300000, /* MaxLoop */ 3,
|
||||
/* VisualizeEG */ false, /* VisualizeEGUbi */ false,
|
||||
/* PurgeDead */ true, /* EagerlyAssume */ false,
|
||||
/* TrimGraph */ false, /* InlineCall */ true);
|
||||
|
||||
GRTransferFuncs* TF = MakeCFRefCountTF(AMgr.getASTContext(), /*GC*/false,
|
||||
AMgr.getLangOptions());
|
||||
GRExprEngine Eng(AMgr, TF);
|
||||
|
||||
Eng.ExecuteWorkList(AMgr.getStackFrame(FD), AMgr.getMaxNodes());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
namespace clang {
|
||||
class ASTContext;
|
||||
class Preprocessor;
|
||||
|
||||
namespace idx {
|
||||
class DeclReferenceMap;
|
||||
|
@ -26,6 +27,7 @@ class TranslationUnit {
|
|||
public:
|
||||
virtual ~TranslationUnit();
|
||||
virtual ASTContext &getASTContext() = 0;
|
||||
virtual Preprocessor &getPreprocessor() = 0;
|
||||
virtual DeclReferenceMap &getDeclReferenceMap() = 0;
|
||||
virtual SelectorMap &getSelectorMap() = 0;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue