]> granicus.if.org Git - clang/commitdiff
When running the reference count checker twice (GC and non-GC mode), only emit
authorTed Kremenek <kremenek@apple.com>
Fri, 2 May 2008 18:01:49 +0000 (18:01 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 2 May 2008 18:01:49 +0000 (18:01 +0000)
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

Driver/ASTConsumers.cpp
include/clang/Analysis/LocalCheckers.h
lib/Analysis/CFRefCount.cpp

index 59e477ab65e69d3f5873cb9d1559848c30ae4efc..684b11eaedb282eee15d1cae33459a27fd883ed3 100644 (file)
@@ -813,16 +813,16 @@ public:
   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;
     }
   }
index 64dc4dd90faa9634dd2adb40d55665ddfd8d6a26..530bf90e7e4ee91642132cf23464c9967540f2fc 100644 (file)
@@ -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();
   
index e62632cad8f3bf5b16b46e0d433b65e78d4e999f..c3da51bd125071efec54af84f9703ec03b58662e 100644 (file)
@@ -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<ExplodedNode<ValueState>*>& 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);
 }