summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-02-15 16:54:12 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-02-15 16:54:12 +0000
commit27af04bcca46f8a3374586be1301477f9123f5e1 (patch)
tree71fb104ee82ea388396e9840e29f615209abef6a /examples
parent809dfe8ad390bdaf7db12af944a84e16111efbbe (diff)
Fix the clang-wpa example.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125565 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'examples')
-rw-r--r--examples/wpa/clang-wpa.cpp44
1 files changed, 34 insertions, 10 deletions
diff --git a/examples/wpa/clang-wpa.cpp b/examples/wpa/clang-wpa.cpp
index a234931c8e..bbb9e147eb 100644
--- a/examples/wpa/clang-wpa.cpp
+++ b/examples/wpa/clang-wpa.cpp
@@ -14,9 +14,11 @@
#include "clang/Basic/FileManager.h"
#include "clang/Basic/SourceManager.h"
+#include "clang/StaticAnalyzer/Frontend/CheckerRegistration.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/TransferFuncs.h"
+#include "clang/StaticAnalyzer/Core/CheckerManager.h"
#include "clang/StaticAnalyzer/Checkers/LocalCheckers.h"
#include "clang/Frontend/ASTUnit.h"
#include "clang/Frontend/CompilerInstance.h"
@@ -26,6 +28,7 @@
#include "clang/Index/DeclReferenceMap.h"
#include "clang/Index/SelectorMap.h"
#include "clang/Lex/Preprocessor.h"
+#include "clang/Basic/TargetInfo.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/raw_ostream.h"
@@ -131,20 +134,41 @@ int main(int argc, char **argv) {
// Create an analysis engine.
Preprocessor &PP = TU->getPreprocessor();
- // Hard code options for now.
+ AnalyzerOptions Opts;
+
+ // Hard code options and checkers for now.
+
+ Opts.MaxNodes = 300000;
+ Opts.MaxLoop = 3;
+ Opts.InlineCall = true;
+ Opts.CFGAddImplicitDtors = true;
+ Opts.EagerlyTrimEGraph = true;
+
+ Opts.CheckersControlList.push_back(std::make_pair("core", true));
+ if (PP.getTargetInfo().getTriple().getOS() != llvm::Triple::Win32)
+ Opts.CheckersControlList.push_back(std::make_pair("unix", true));
+ if (PP.getTargetInfo().getTriple().getVendor() == llvm::Triple::Apple)
+ Opts.CheckersControlList.push_back(std::make_pair("macosx", true));
+
+ // Checks to perform for Objective-C/Objective-C++.
+ if (PP.getLangOptions().ObjC1)
+ Opts.CheckersControlList.push_back(std::make_pair("cocoa", true));
+
+ llvm::OwningPtr<ento::CheckerManager> checkerMgr;
+ checkerMgr.reset(ento::registerCheckers(Opts, PP.getDiagnostics()));
+
using namespace clang::ento;
AnalysisManager AMgr(TU->getASTContext(), PP.getDiagnostics(),
PP.getLangOptions(), /* PathDiagnostic */ 0,
CreateRegionStoreManager,
- CreateRangeConstraintManager, &Idxer,
- /* MaxNodes */ 300000, /* MaxVisit */ 3,
- /* VisualizeEG */ false, /* VisualizeEGUbi */ false,
- /* PurgeDead */ true, /* EagerlyAssume */ false,
- /* TrimGraph */ false, /* InlineCall */ true,
- /* UseUnoptimizedCFG */ false,
- /* addImplicitDtors */ true,
- /* addInitializers */ false,
- /* reclaimeNodes */ true);
+ CreateRangeConstraintManager, checkerMgr.get(), &Idxer,
+ Opts.MaxNodes, Opts.MaxLoop,
+ Opts.VisualizeEGDot, Opts.VisualizeEGUbi,
+ Opts.PurgeDead, Opts.EagerlyAssume,
+ Opts.TrimGraph, Opts.InlineCall,
+ Opts.UnoptimizedCFG, Opts.CFGAddImplicitDtors,
+ Opts.CFGAddInitializers,
+ Opts.EagerlyTrimEGraph);
TransferFuncs* TF = MakeCFRefCountTF(AMgr.getASTContext(), /*GC*/false,
AMgr.getLangOptions());