aboutsummaryrefslogtreecommitdiff
path: root/lib/StaticAnalyzer
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2015-08-07 23:02:44 +0000
committerDimitry Andric <dim@FreeBSD.org>2015-08-07 23:02:44 +0000
commit51ece4aae5857052d224ce52277924c74685714e (patch)
treeca13cf9e2e8c2499f61f1246e455efd2804abd36 /lib/StaticAnalyzer
parentc192b3dcffd5e672a2b2e1730e2440febb4fb192 (diff)
downloadsrc-51ece4aae5857052d224ce52277924c74685714e.tar.gz
src-51ece4aae5857052d224ce52277924c74685714e.zip
Vendor import of clang trunk r242221:vendor/clang/clang-trunk-r242221
Notes
Notes: svn path=/vendor/clang/dist/; revision=286427 svn path=/vendor/clang/clang-trunk-r242221/; revision=286428; tag=vendor/clang/clang-trunk-r242221
Diffstat (limited to 'lib/StaticAnalyzer')
-rw-r--r--lib/StaticAnalyzer/Checkers/ObjCMissingSuperCallChecker.cpp2
-rw-r--r--lib/StaticAnalyzer/Core/CheckerRegistry.cpp25
-rw-r--r--lib/StaticAnalyzer/Core/MemRegion.cpp9
-rw-r--r--lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp1
4 files changed, 32 insertions, 5 deletions
diff --git a/lib/StaticAnalyzer/Checkers/ObjCMissingSuperCallChecker.cpp b/lib/StaticAnalyzer/Checkers/ObjCMissingSuperCallChecker.cpp
index a2cf8e10d09b..016cb146f84e 100644
--- a/lib/StaticAnalyzer/Checkers/ObjCMissingSuperCallChecker.cpp
+++ b/lib/StaticAnalyzer/Checkers/ObjCMissingSuperCallChecker.cpp
@@ -34,7 +34,6 @@ struct SelectorDescriptor {
const char *SelectorName;
unsigned ArgumentCount;
};
-}
//===----------------------------------------------------------------------===//
// FindSuperCallVisitor - Identify specific calls to the superclass.
@@ -63,7 +62,6 @@ private:
// ObjCSuperCallChecker
//===----------------------------------------------------------------------===//
-namespace {
class ObjCSuperCallChecker : public Checker<
check::ASTDecl<ObjCImplementationDecl> > {
public:
diff --git a/lib/StaticAnalyzer/Core/CheckerRegistry.cpp b/lib/StaticAnalyzer/Core/CheckerRegistry.cpp
index b64e30b31007..6ba64f52d183 100644
--- a/lib/StaticAnalyzer/Core/CheckerRegistry.cpp
+++ b/lib/StaticAnalyzer/Core/CheckerRegistry.cpp
@@ -8,7 +8,10 @@
//===----------------------------------------------------------------------===//
#include "clang/StaticAnalyzer/Core/CheckerRegistry.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Frontend/FrontendDiagnostic.h"
#include "clang/StaticAnalyzer/Core/CheckerOptInfo.h"
+#include "clang/StaticAnalyzer/Core/AnalyzerOptions.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/Support/raw_ostream.h"
@@ -111,6 +114,28 @@ void CheckerRegistry::initializeManager(CheckerManager &checkerMgr,
}
}
+void CheckerRegistry::validateCheckerOptions(const AnalyzerOptions &opts,
+ DiagnosticsEngine &diags) const {
+ for (auto &config : opts.Config) {
+ size_t pos = config.getKey().find(':');
+ if (pos == StringRef::npos)
+ continue;
+
+ bool hasChecker = false;
+ StringRef checkerName = config.getKey().substr(0, pos);
+ for (auto &checker : Checkers) {
+ if (checker.FullName.startswith(checkerName) &&
+ (checker.FullName.size() == pos || checker.FullName[pos] == '.')) {
+ hasChecker = true;
+ break;
+ }
+ }
+ if (!hasChecker) {
+ diags.Report(diag::err_unknown_analyzer_checker) << checkerName;
+ }
+ }
+}
+
void CheckerRegistry::printHelp(raw_ostream &out,
size_t maxNameChars) const {
// FIXME: Alphabetical sort puts 'experimental' in the middle.
diff --git a/lib/StaticAnalyzer/Core/MemRegion.cpp b/lib/StaticAnalyzer/Core/MemRegion.cpp
index 1fa675433b56..5ac845825c8d 100644
--- a/lib/StaticAnalyzer/Core/MemRegion.cpp
+++ b/lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -824,9 +824,12 @@ const VarRegion* MemRegionManager::getVarRegion(const VarDecl *D,
QualType T;
if (const TypeSourceInfo *TSI = BD->getSignatureAsWritten())
T = TSI->getType();
- else
- T = getContext().getFunctionNoProtoType(getContext().VoidTy);
-
+ if (T.isNull())
+ T = getContext().VoidTy;
+ if (!T->getAs<FunctionType>())
+ T = getContext().getFunctionNoProtoType(T);
+ T = getContext().getBlockPointerType(T);
+
const BlockTextRegion *BTR =
getBlockTextRegion(BD, C.getCanonicalType(T),
STC->getAnalysisDeclContext());
diff --git a/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp b/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
index b3ff79750b49..7fced1e5c71a 100644
--- a/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
+++ b/lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
@@ -114,6 +114,7 @@ ento::createCheckerManager(AnalyzerOptions &opts, const LangOptions &langOpts,
ClangCheckerRegistry allCheckers(plugins, &diags);
allCheckers.initializeManager(*checkerMgr, checkerOpts);
+ allCheckers.validateCheckerOptions(opts, diags);
checkerMgr->finishedCheckerRegistration();
for (unsigned i = 0, e = checkerOpts.size(); i != e; ++i) {