summaryrefslogtreecommitdiffstats
path: root/gnu/llvm/tools/clang/lib/StaticAnalyzer
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/llvm/tools/clang/lib/StaticAnalyzer')
-rw-r--r--gnu/llvm/tools/clang/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp9
-rw-r--r--gnu/llvm/tools/clang/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp3
-rw-r--r--gnu/llvm/tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp6
-rw-r--r--gnu/llvm/tools/clang/lib/StaticAnalyzer/Core/RegionStore.cpp2
4 files changed, 16 insertions, 4 deletions
diff --git a/gnu/llvm/tools/clang/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp b/gnu/llvm/tools/clang/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
index 0e0f52af316..437378e53da 100644
--- a/gnu/llvm/tools/clang/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
+++ b/gnu/llvm/tools/clang/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
@@ -94,11 +94,18 @@ void MacOSXAPIChecker::CheckDispatchOnce(CheckerContext &C, const CallExpr *CE,
bool SuggestStatic = false;
os << "Call to '" << FName << "' uses";
if (const VarRegion *VR = dyn_cast<VarRegion>(RB)) {
+ const VarDecl *VD = VR->getDecl();
+ // FIXME: These should have correct memory space and thus should be filtered
+ // out earlier. This branch only fires when we're looking from a block,
+ // which we analyze as a top-level declaration, onto a static local
+ // in a function that contains the block.
+ if (VD->isStaticLocal())
+ return;
// We filtered out globals earlier, so it must be a local variable
// or a block variable which is under UnknownSpaceRegion.
if (VR != R)
os << " memory within";
- if (VR->getDecl()->hasAttr<BlocksAttr>())
+ if (VD->hasAttr<BlocksAttr>())
os << " the block variable '";
else
os << " the local variable '";
diff --git a/gnu/llvm/tools/clang/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp b/gnu/llvm/tools/clang/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
index 15e8ea31c4c..b47762b915c 100644
--- a/gnu/llvm/tools/clang/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
+++ b/gnu/llvm/tools/clang/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
@@ -179,7 +179,8 @@ void WalkAST::VisitCXXMemberCallExpr(CallExpr *CE) {
}
// Get the callee.
- const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(CE->getDirectCallee());
+ const CXXMethodDecl *MD =
+ dyn_cast_or_null<CXXMethodDecl>(CE->getDirectCallee());
if (MD && MD->isVirtual() && !callIsNonVirtual && !MD->hasAttr<FinalAttr>() &&
!MD->getParent()->hasAttr<FinalAttr>())
ReportVirtualCall(CE, MD->isPure());
diff --git a/gnu/llvm/tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp b/gnu/llvm/tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
index c4ba2ae199f..d6e8fe5b51b 100644
--- a/gnu/llvm/tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
+++ b/gnu/llvm/tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -816,9 +816,11 @@ const VarRegion* MemRegionManager::getVarRegion(const VarDecl *D,
const StackFrameContext *STC = V.get<const StackFrameContext*>();
- if (!STC)
+ if (!STC) {
+ // FIXME: Assign a more sensible memory space to static locals
+ // we see from within blocks that we analyze as top-level declarations.
sReg = getUnknownRegion();
- else {
+ } else {
if (D->hasLocalStorage()) {
sReg = isa<ParmVarDecl>(D) || isa<ImplicitParamDecl>(D)
? static_cast<const MemRegion*>(getStackArgumentsRegion(STC))
diff --git a/gnu/llvm/tools/clang/lib/StaticAnalyzer/Core/RegionStore.cpp b/gnu/llvm/tools/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
index 15ca2c14f94..934cc5cd3ac 100644
--- a/gnu/llvm/tools/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ b/gnu/llvm/tools/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -1849,6 +1849,8 @@ SVal RegionStoreManager::getBindingForVar(RegionBindingsConstRef B,
// Function-scoped static variables are default-initialized to 0; if they
// have an initializer, it would have been processed by now.
+ // FIXME: This is only true when we're starting analysis from main().
+ // We're losing a lot of coverage here.
if (isa<StaticGlobalSpaceRegion>(MS))
return svalBuilder.makeZeroVal(T);