r179626 - Factor CheckerManager to be able to pass AnalyzerOptions to checkers
Ted Kremenek
kremenek at apple.com
Tue Apr 16 14:10:06 PDT 2013
Author: kremenek
Date: Tue Apr 16 16:10:05 2013
New Revision: 179626
URL: http://llvm.org/viewvc/llvm-project?rev=179626&view=rev
Log:
Factor CheckerManager to be able to pass AnalyzerOptions to checkers
during checker registration. There are no immediate clients of this,
but this provides a way for checkers to query the options table
at startup instead.
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h
cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistration.h
cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h?rev=179626&r1=179625&r2=179626&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h Tue Apr 16 16:10:05 2013
@@ -232,6 +232,7 @@ private:
/// \sa getMaxNodesPerTopLevelFunction
Optional<unsigned> MaxNodesPerTopLevelFunction;
+public:
/// Interprets an option's string value as a boolean.
///
/// Accepts the strings "true" and "false".
@@ -244,7 +245,6 @@ private:
/// Interprets an option's string value as an integer value.
int getOptionAsInteger(StringRef Name, int DefaultVal);
-public:
/// \brief Retrieves and sets the UserMode. This is a high-level option,
/// which is used to set other low-level options. It is not accessible
/// outside of AnalyzerOptions.
Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h?rev=179626&r1=179625&r2=179626&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h Tue Apr 16 16:10:05 2013
@@ -17,6 +17,7 @@
#include "clang/Analysis/ProgramPoint.h"
#include "clang/Basic/LangOptions.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/Store.h"
+#include "clang/StaticAnalyzer/Core/AnalyzerOptions.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/SmallVector.h"
@@ -134,9 +135,13 @@ enum PointerEscapeKind {
class CheckerManager {
const LangOptions LangOpts;
-
+ AnalyzerOptionsRef AOptions;
public:
- CheckerManager(const LangOptions &langOpts) : LangOpts(langOpts) { }
+ CheckerManager(const LangOptions &langOpts,
+ AnalyzerOptionsRef AOptions)
+ : LangOpts(langOpts),
+ AOptions(AOptions) {}
+
~CheckerManager();
bool hasPathSensitiveCheckers() const;
@@ -144,6 +149,7 @@ public:
void finishedCheckerRegistration();
const LangOptions &getLangOpts() const { return LangOpts; }
+ AnalyzerOptions &getAnalyzerOptions() { return *AOptions; }
typedef CheckerBase *CheckerRef;
typedef const void *CheckerTag;
@@ -167,6 +173,20 @@ public:
CheckerDtors.push_back(CheckerDtor(checker, destruct<CHECKER>));
CHECKER::_register(checker, *this);
ref = checker;
+ return checker;
+ }
+
+ template <typename CHECKER>
+ CHECKER *registerChecker(AnalyzerOptions &AOpts) {
+ CheckerTag tag = getTag<CHECKER>();
+ CheckerRef &ref = CheckerTags[tag];
+ if (ref)
+ return static_cast<CHECKER *>(ref); // already registered.
+
+ CHECKER *checker = new CHECKER(AOpts);
+ CheckerDtors.push_back(CheckerDtor(checker, destruct<CHECKER>));
+ CHECKER::_register(checker, *this);
+ ref = checker;
return checker;
}
Modified: cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistration.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistration.h?rev=179626&r1=179625&r2=179626&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistration.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistration.h Tue Apr 16 16:10:05 2013
@@ -21,7 +21,7 @@ namespace clang {
namespace ento {
class CheckerManager;
-CheckerManager *createCheckerManager(const AnalyzerOptions &opts,
+CheckerManager *createCheckerManager(AnalyzerOptions &opts,
const LangOptions &langOpts,
ArrayRef<std::string> plugins,
DiagnosticsEngine &diags);
Modified: cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp?rev=179626&r1=179625&r2=179626&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp Tue Apr 16 16:10:05 2013
@@ -100,11 +100,12 @@ void ClangCheckerRegistry::warnIncompati
}
-CheckerManager *ento::createCheckerManager(const AnalyzerOptions &opts,
+CheckerManager *ento::createCheckerManager(AnalyzerOptions &opts,
const LangOptions &langOpts,
ArrayRef<std::string> plugins,
DiagnosticsEngine &diags) {
- OwningPtr<CheckerManager> checkerMgr(new CheckerManager(langOpts));
+ OwningPtr<CheckerManager> checkerMgr(new CheckerManager(langOpts,
+ &opts));
SmallVector<CheckerOptInfo, 8> checkerOpts;
for (unsigned i = 0, e = opts.CheckersControlList.size(); i != e; ++i) {
More information about the cfe-commits
mailing list