[cfe-commits] r50394 - in /cfe/trunk: Driver/ASTConsumers.cpp Driver/ASTConsumers.h Driver/clang.cpp include/clang/Analysis/LocalCheckers.h lib/Analysis/CFRefCount.cpp
Ted Kremenek
kremenek at apple.com
Mon Apr 28 22:13:59 PDT 2008
Author: kremenek
Date: Tue Apr 29 00:13:59 2008
New Revision: 50394
URL: http://llvm.org/viewvc/llvm-project?rev=50394&view=rev
Log:
Provide the option to run the CF-retain checker in GC enabled mode.
The transfer functions for the checker don't do anything special yet in GC mode.
Modified:
cfe/trunk/Driver/ASTConsumers.cpp
cfe/trunk/Driver/ASTConsumers.h
cfe/trunk/Driver/clang.cpp
cfe/trunk/include/clang/Analysis/LocalCheckers.h
cfe/trunk/lib/Analysis/CFRefCount.cpp
Modified: cfe/trunk/Driver/ASTConsumers.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/ASTConsumers.cpp?rev=50394&r1=50393&r2=50394&view=diff
==============================================================================
--- cfe/trunk/Driver/ASTConsumers.cpp (original)
+++ cfe/trunk/Driver/ASTConsumers.cpp Tue Apr 29 00:13:59 2008
@@ -690,7 +690,7 @@
virtual bool printFuncDeclStart() { return false; }
virtual const char* getCheckerName() = 0;
- virtual GRTransferFuncs* getTransferFunctions() = 0;
+ virtual void getTransferFunctions(std::vector<GRTransferFuncs*>& TFs) = 0;
};
} // end anonymous namespace
@@ -732,22 +732,30 @@
else
llvm::cerr << '\n';
- // Construct the analysis engine.
- GRExprEngine Eng(C, CD, *Ctx);
+ std::vector<GRTransferFuncs*> TFs;
+ getTransferFunctions(TFs);
- // Set base transfer functions.
- llvm::OwningPtr<GRTransferFuncs> TF(getTransferFunctions());
- Eng.setTransferFunctions(TF.get());
-
- // Execute the worklist algorithm.
- Eng.ExecuteWorkList();
-
- // Display warnings.
- Eng.EmitWarnings(Diags, PD.get());
-
-#ifndef NDEBUG
- if (Visualize) Eng.ViewGraph(TrimGraph);
-#endif
+ while (!TFs.empty()) {
+
+ // Construct the analysis engine.
+ GRExprEngine Eng(C, CD, *Ctx);
+
+ // Set base transfer functions.
+ llvm::OwningPtr<GRTransferFuncs> TF(TFs.back());
+ TFs.pop_back();
+
+ Eng.setTransferFunctions(TF.get());
+
+ // Execute the worklist algorithm.
+ Eng.ExecuteWorkList();
+
+ // Display warnings.
+ Eng.EmitWarnings(Diags, PD.get());
+
+ #ifndef NDEBUG
+ if (Visualize) Eng.ViewGraph(TrimGraph);
+ #endif
+ }
}
//===----------------------------------------------------------------------===//
@@ -765,8 +773,8 @@
virtual const char* getCheckerName() { return "GRSimpleVals"; }
- virtual GRTransferFuncs* getTransferFunctions() {
- return MakeGRSimpleValsTF();
+ virtual void getTransferFunctions(std::vector<GRTransferFuncs*>& TFs) {
+ return TFs.push_back(MakeGRSimpleValsTF());
}
};
} // end anonymous namespace
@@ -789,19 +797,34 @@
namespace {
class CFRefCountCheckerVisitor : public CheckerConsumer {
+ const LangOptions& LangOpts;
public:
CFRefCountCheckerVisitor(Diagnostic &diags, Preprocessor* pp,
PreprocessorFactory* ppf,
+ const LangOptions& lopts,
const std::string& fname,
const std::string& htmldir,
bool visualize, bool trim, bool analyzeAll)
: CheckerConsumer(diags, pp, ppf, fname, htmldir, visualize,
- trim, analyzeAll) {}
+ trim, analyzeAll), LangOpts(lopts) {}
virtual const char* getCheckerName() { return "CFRefCountChecker"; }
- virtual GRTransferFuncs* getTransferFunctions() {
- return MakeCFRefCountTF(*Ctx);
+ virtual void getTransferFunctions(std::vector<GRTransferFuncs*>& TFs) {
+ switch (LangOpts.getGCMode()) {
+ case LangOptions::NonGC:
+ TFs.push_back(MakeCFRefCountTF(*Ctx, false));
+ break;
+
+ case LangOptions::GCOnly:
+ TFs.push_back(MakeCFRefCountTF(*Ctx, true));
+ break;
+
+ case LangOptions::HybridGC:
+ TFs.push_back(MakeCFRefCountTF(*Ctx, false));
+ TFs.push_back(MakeCFRefCountTF(*Ctx, true));
+ break;
+ }
}
};
} // end anonymous namespace
@@ -809,13 +832,15 @@
ASTConsumer* clang::CreateCFRefChecker(Diagnostic &Diags,
Preprocessor* PP,
PreprocessorFactory* PPF,
+ const LangOptions& LangOpts,
const std::string& FunctionName,
const std::string& HTMLDir,
bool Visualize, bool TrimGraph,
bool AnalyzeAll) {
- return new CFRefCountCheckerVisitor(Diags, PP, PPF, FunctionName, HTMLDir,
- Visualize, TrimGraph, AnalyzeAll);
+ return new CFRefCountCheckerVisitor(Diags, PP, PPF, LangOpts, FunctionName,
+ HTMLDir, Visualize, TrimGraph,
+ AnalyzeAll);
}
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/Driver/ASTConsumers.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/ASTConsumers.h?rev=50394&r1=50393&r2=50394&view=diff
==============================================================================
--- cfe/trunk/Driver/ASTConsumers.h (original)
+++ cfe/trunk/Driver/ASTConsumers.h Tue Apr 29 00:13:59 2008
@@ -53,6 +53,7 @@
ASTConsumer *CreateCFRefChecker(Diagnostic &Diags,
Preprocessor* PP, PreprocessorFactory* PPF,
+ const LangOptions& LangOpts,
const std::string& Function,
const std::string& HTMLDir, bool Visualize,
bool TrimGraph, bool AnalyzeAll);
Modified: cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=50394&r1=50393&r2=50394&view=diff
==============================================================================
--- cfe/trunk/Driver/clang.cpp (original)
+++ cfe/trunk/Driver/clang.cpp Tue Apr 29 00:13:59 2008
@@ -1132,7 +1132,8 @@
OutputFile, VisualizeEG, TrimGraph, AnalyzeAll);
case CheckerCFRef:
- return CreateCFRefChecker(Diag, PP, PPF, AnalyzeSpecificFunction,
+ return CreateCFRefChecker(Diag, PP, PPF, LangOpts,
+ AnalyzeSpecificFunction,
OutputFile, VisualizeEG, TrimGraph, AnalyzeAll);
case TestSerialization:
Modified: cfe/trunk/include/clang/Analysis/LocalCheckers.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/LocalCheckers.h?rev=50394&r1=50393&r2=50394&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/LocalCheckers.h (original)
+++ cfe/trunk/include/clang/Analysis/LocalCheckers.h Tue Apr 29 00:13:59 2008
@@ -31,7 +31,7 @@
bool FullUninitTaint=false);
GRTransferFuncs* MakeGRSimpleValsTF();
-GRTransferFuncs* MakeCFRefCountTF(ASTContext& Ctx);
+GRTransferFuncs* MakeCFRefCountTF(ASTContext& Ctx, bool GCEnabled);
BugType* MakeDeadStoresChecker();
} // end namespace clang
Modified: cfe/trunk/lib/Analysis/CFRefCount.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFRefCount.cpp?rev=50394&r1=50393&r2=50394&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CFRefCount.cpp (original)
+++ cfe/trunk/lib/Analysis/CFRefCount.cpp Tue Apr 29 00:13:59 2008
@@ -590,7 +590,8 @@
private:
// Instance variables.
- CFRefSummaryManager Summaries;
+ CFRefSummaryManager Summaries;
+ const bool GCEnabled;
RefBFactoryTy RefBFactory;
UseAfterReleasesTy UseAfterReleases;
@@ -636,8 +637,9 @@
public:
- CFRefCount(ASTContext& Ctx)
+ CFRefCount(ASTContext& Ctx, bool gcenabled)
: Summaries(Ctx),
+ GCEnabled(gcenabled),
RetainSelector(GetUnarySelector("retain", Ctx)),
ReleaseSelector(GetUnarySelector("release", Ctx)) {}
@@ -1575,6 +1577,6 @@
// Transfer function creation for external clients.
//===----------------------------------------------------------------------===//
-GRTransferFuncs* clang::MakeCFRefCountTF(ASTContext& Ctx) {
- return new CFRefCount(Ctx);
+GRTransferFuncs* clang::MakeCFRefCountTF(ASTContext& Ctx, bool GCEnabled) {
+ return new CFRefCount(Ctx, GCEnabled);
}
More information about the cfe-commits
mailing list