From: Ted Kremenek Date: Fri, 2 May 2008 18:01:49 +0000 (+0000) Subject: When running the reference count checker twice (GC and non-GC mode), only emit X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9f7416138b8befe2d274f6f2cadc792d2c279711;p=clang 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 59e477ab65..684b11eaed 100644 --- a/Driver/ASTConsumers.cpp +++ b/Driver/ASTConsumers.cpp @@ -813,16 +813,16 @@ public: virtual void getTransferFunctions(std::vector& 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 64dc4dd90f..530bf90e7e 100644 --- a/include/clang/Analysis/LocalCheckers.h +++ b/include/clang/Analysis/LocalCheckers.h @@ -32,7 +32,8 @@ void CheckUninitializedValues(CFG& cfg, ASTContext& Ctx, Diagnostic& Diags, 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 e62632cad8..c3da51bd12 100644 --- a/lib/Analysis/CFRefCount.cpp +++ b/lib/Analysis/CFRefCount.cpp @@ -626,7 +626,8 @@ private: // Instance variables. CFRefSummaryManager Summaries; - const bool GCEnabled; + const bool GCEnabled; + const bool EmitStandardWarnings; const LangOptions& LOpts; RefBFactoryTy RefBFactory; @@ -674,9 +675,11 @@ private: 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 @@ namespace { } // 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 @@ void Leak::GetErrorNodes(std::vector*>& Nodes) { //===----------------------------------------------------------------------===// 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); }