[cfe-commits] r125565 - in /cfe/trunk: examples/wpa/clang-wpa.cpp include/clang/StaticAnalyzer/Frontend/CheckerRegistration.h lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp lib/StaticAnalyzer/Frontend/AnalysisConsumer.h lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp

Argyrios Kyrtzidis akyrtzi at gmail.com
Tue Feb 15 08:54:13 PST 2011


Author: akirtzidis
Date: Tue Feb 15 10:54:12 2011
New Revision: 125565

URL: http://llvm.org/viewvc/llvm-project?rev=125565&view=rev
Log:
Fix the clang-wpa example.

Added:
    cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistration.h
Modified:
    cfe/trunk/examples/wpa/clang-wpa.cpp
    cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
    cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.h
    cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp

Modified: cfe/trunk/examples/wpa/clang-wpa.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/wpa/clang-wpa.cpp?rev=125565&r1=125564&r2=125565&view=diff
==============================================================================
--- cfe/trunk/examples/wpa/clang-wpa.cpp (original)
+++ cfe/trunk/examples/wpa/clang-wpa.cpp Tue Feb 15 10:54:12 2011
@@ -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 @@
   // 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());

Added: cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistration.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistration.h?rev=125565&view=auto
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistration.h (added)
+++ cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistration.h Tue Feb 15 10:54:12 2011
@@ -0,0 +1,26 @@
+//===-- CheckerRegistration.h - Checker Registration Function-------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_SA_FRONTEND_CHECKERREGISTRATION_H
+#define LLVM_CLANG_SA_FRONTEND_CHECKERREGISTRATION_H
+
+namespace clang {
+  class AnalyzerOptions;
+  class Diagnostic;
+
+namespace ento {
+  class CheckerManager;
+
+CheckerManager *registerCheckers(const AnalyzerOptions &opts,Diagnostic &diags);
+
+} // end ento namespace
+
+} // end namespace clang
+
+#endif

Modified: cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp?rev=125565&r1=125564&r2=125565&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp Tue Feb 15 10:54:12 2011
@@ -20,6 +20,7 @@
 #include "clang/Analysis/Analyses/LiveVariables.h"
 #include "clang/Analysis/Analyses/UninitializedValues.h"
 #include "clang/Analysis/CFG.h"
+#include "clang/StaticAnalyzer/Frontend/CheckerRegistration.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Checkers/LocalCheckers.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h"

Modified: cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.h?rev=125565&r1=125564&r2=125565&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.h (original)
+++ cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.h Tue Feb 15 10:54:12 2011
@@ -34,8 +34,6 @@
                                     const std::string &output,
                                     const AnalyzerOptions& Opts);
 
-CheckerManager *registerCheckers(const AnalyzerOptions &opts,Diagnostic &diags);
-
 } // end GR namespace
 
 } // end clang namespace

Modified: cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp?rev=125565&r1=125564&r2=125565&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp Tue Feb 15 10:54:12 2011
@@ -11,7 +11,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "AnalysisConsumer.h"
+#include "clang/StaticAnalyzer/Frontend/CheckerRegistration.h"
 #include "../Checkers/ClangSACheckerProvider.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/CheckerProvider.h"





More information about the cfe-commits mailing list