summaryrefslogtreecommitdiffstats
path: root/clang/examples/wpa/clang-wpa.cpp
diff options
context:
space:
mode:
authorZhongxing Xu <xuzhongxing@gmail.com>2010-07-06 09:18:02 +0000
committerZhongxing Xu <xuzhongxing@gmail.com>2010-07-06 09:18:02 +0000
commit2231a920d09f1dd55672c89e514424d6897ed697 (patch)
tree01e3a9b76dad0c244263277a3f8de822f8c557ee /clang/examples/wpa/clang-wpa.cpp
parent5b488b1e6c422618b2a867e50573f24a49715eda (diff)
downloadbcm5719-llvm-2231a920d09f1dd55672c89e514424d6897ed697.tar.gz
bcm5719-llvm-2231a920d09f1dd55672c89e514424d6897ed697.zip
Add skeleton code to make wpa call the analysis engine.
llvm-svn: 107646
Diffstat (limited to 'clang/examples/wpa/clang-wpa.cpp')
-rw-r--r--clang/examples/wpa/clang-wpa.cpp33
1 files changed, 31 insertions, 2 deletions
diff --git a/clang/examples/wpa/clang-wpa.cpp b/clang/examples/wpa/clang-wpa.cpp
index bfac398532a..74ec368cfbe 100644
--- a/clang/examples/wpa/clang-wpa.cpp
+++ b/clang/examples/wpa/clang-wpa.cpp
@@ -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;
}
OpenPOWER on IntegriCloud