When running the reference count checker twice (GC and non-GC mode), only emit
basic warnings (dead stores, null dereferences) on the first pass.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50584 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Driver/ASTConsumers.cpp b/Driver/ASTConsumers.cpp
index 59e477a..684b11e 100644
--- a/Driver/ASTConsumers.cpp
+++ b/Driver/ASTConsumers.cpp
@@ -813,16 +813,16 @@
virtual void getTransferFunctions(std::vector<GRTransferFuncs*>& TFs) {
switch (LangOpts.getGCMode()) {
case LangOptions::NonGC:
- TFs.push_back(MakeCFRefCountTF(*Ctx, false, LangOpts));
+ TFs.push_back(MakeCFRefCountTF(*Ctx, false, true, LangOpts));
break;
case LangOptions::GCOnly:
- TFs.push_back(MakeCFRefCountTF(*Ctx, true, LangOpts));
+ TFs.push_back(MakeCFRefCountTF(*Ctx, true, true, LangOpts));
break;
case LangOptions::HybridGC:
- TFs.push_back(MakeCFRefCountTF(*Ctx, false, LangOpts));
- TFs.push_back(MakeCFRefCountTF(*Ctx, true, LangOpts));
+ TFs.push_back(MakeCFRefCountTF(*Ctx, false, true, LangOpts));
+ TFs.push_back(MakeCFRefCountTF(*Ctx, true, false, LangOpts));
break;
}
}
diff --git a/include/clang/Analysis/LocalCheckers.h b/include/clang/Analysis/LocalCheckers.h
index 64dc4dd..530bf90 100644
--- a/include/clang/Analysis/LocalCheckers.h
+++ b/include/clang/Analysis/LocalCheckers.h
@@ -32,7 +32,8 @@
bool FullUninitTaint=false);
GRTransferFuncs* MakeGRSimpleValsTF();
-GRTransferFuncs* MakeCFRefCountTF(ASTContext& Ctx, bool GCEnabled,
+GRTransferFuncs* MakeCFRefCountTF(ASTContext& Ctx, bool GCEnabled,
+ bool StandardWarnings,
const LangOptions& lopts);
BugType* MakeDeadStoresChecker();
diff --git a/lib/Analysis/CFRefCount.cpp b/lib/Analysis/CFRefCount.cpp
index e62632c..c3da51b 100644
--- a/lib/Analysis/CFRefCount.cpp
+++ b/lib/Analysis/CFRefCount.cpp
@@ -626,7 +626,8 @@
// Instance variables.
CFRefSummaryManager Summaries;
- const bool GCEnabled;
+ const bool GCEnabled;
+ const bool EmitStandardWarnings;
const LangOptions& LOpts;
RefBFactoryTy RefBFactory;
@@ -674,9 +675,11 @@
public:
- CFRefCount(ASTContext& Ctx, bool gcenabled, const LangOptions& lopts)
+ CFRefCount(ASTContext& Ctx, bool gcenabled, bool StandardWarnings,
+ const LangOptions& lopts)
: Summaries(Ctx, gcenabled),
GCEnabled(gcenabled),
+ EmitStandardWarnings(StandardWarnings),
LOpts(lopts),
RetainSelector(GetNullarySelector("retain", Ctx)),
ReleaseSelector(GetNullarySelector("release", Ctx)),
@@ -1539,7 +1542,7 @@
} // end anonymous namespace
void CFRefCount::RegisterChecks(GRExprEngine& Eng) {
- GRSimpleVals::RegisterChecks(Eng);
+ if (EmitStandardWarnings) GRSimpleVals::RegisterChecks(Eng);
Eng.Register(new UseAfterRelease(*this));
Eng.Register(new BadRelease(*this));
Eng.Register(new Leak(*this));
@@ -1793,6 +1796,7 @@
//===----------------------------------------------------------------------===//
GRTransferFuncs* clang::MakeCFRefCountTF(ASTContext& Ctx, bool GCEnabled,
+ bool StandardWarnings,
const LangOptions& lopts) {
- return new CFRefCount(Ctx, GCEnabled, lopts);
+ return new CFRefCount(Ctx, GCEnabled, StandardWarnings, lopts);
}