[cfe-commits] r49503 - in /cfe/trunk: Driver/ASTConsumers.cpp include/clang/Analysis/LocalCheckers.h lib/Analysis/CFRefCount.cpp
Ted Kremenek
kremenek at apple.com
Thu Apr 10 15:58:09 PDT 2008
Author: kremenek
Date: Thu Apr 10 17:58:08 2008
New Revision: 49503
URL: http://llvm.org/viewvc/llvm-project?rev=49503&view=rev
Log:
Fix some bonehead bugs in summary generation in CFRefCount.
Modified:
cfe/trunk/Driver/ASTConsumers.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=49503&r1=49502&r2=49503&view=diff
==============================================================================
--- cfe/trunk/Driver/ASTConsumers.cpp (original)
+++ cfe/trunk/Driver/ASTConsumers.cpp Thu Apr 10 17:58:08 2008
@@ -636,6 +636,7 @@
namespace {
class CheckerConsumer : public CFGVisitor {
+protected:
Diagnostic &Diags;
ASTContext* Ctx;
const std::string& HTMLDir;
@@ -755,7 +756,7 @@
virtual const char* getCheckerName() { return "CFRefCountChecker"; }
virtual GRTransferFuncs* getTransferFunctions() {
- return MakeCFRefCountTF();
+ return MakeCFRefCountTF(*Ctx);
}
};
} // end anonymous namespace
Modified: cfe/trunk/include/clang/Analysis/LocalCheckers.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/LocalCheckers.h?rev=49503&r1=49502&r2=49503&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/LocalCheckers.h (original)
+++ cfe/trunk/include/clang/Analysis/LocalCheckers.h Thu Apr 10 17:58:08 2008
@@ -30,7 +30,7 @@
bool FullUninitTaint=false);
GRTransferFuncs* MakeGRSimpleValsTF();
-GRTransferFuncs* MakeCFRefCountTF();
+GRTransferFuncs* MakeCFRefCountTF(ASTContext& Ctx);
} // end namespace clang
Modified: cfe/trunk/lib/Analysis/CFRefCount.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFRefCount.cpp?rev=49503&r1=49502&r2=49503&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CFRefCount.cpp (original)
+++ cfe/trunk/lib/Analysis/CFRefCount.cpp Thu Apr 10 17:58:08 2008
@@ -37,14 +37,10 @@
namespace llvm {
template <> struct FoldingSetTrait<ArgEffects> {
- static void Profile(const ArgEffects& X, FoldingSetNodeID ID) {
+ static void Profile(const ArgEffects& X, FoldingSetNodeID& ID) {
for (ArgEffects::const_iterator I = X.begin(), E = X.end(); I!= E; ++I)
ID.AddInteger((unsigned) *I);
- }
-
- static void Profile(ArgEffects& X, FoldingSetNodeID ID) {
- Profile(X, ID);
- }
+ }
};
} // end llvm namespace
@@ -56,7 +52,7 @@
private:
unsigned Data;
- RetEffect(Kind k, unsigned D) { Data = (Data << 2) | (unsigned) k; }
+ RetEffect(Kind k, unsigned D) { Data = (D << 2) | (unsigned) k; }
public:
@@ -64,7 +60,7 @@
unsigned getValue() const {
assert(getKind() == Alias);
- return Data & ~0x3;
+ return Data >> 2;
}
static RetEffect MakeAlias(unsigned Idx) { return RetEffect(Alias, Idx); }
@@ -118,12 +114,12 @@
typedef llvm::FoldingSet<CFRefSummary> SummarySetTy;
typedef llvm::DenseMap<FunctionDecl*, CFRefSummary*> SummaryMapTy;
- SummarySetTy SummarySet;
- SummaryMapTy SummaryMap;
- AESetTy AESet;
- llvm::BumpPtrAllocator BPAlloc;
-
- ArgEffects ScratchArgs;
+ ASTContext& Ctx;
+ SummarySetTy SummarySet;
+ SummaryMapTy SummaryMap;
+ AESetTy AESet;
+ llvm::BumpPtrAllocator BPAlloc;
+ ArgEffects ScratchArgs;
ArgEffects* getArgEffects();
@@ -138,7 +134,7 @@
CFRefSummary* getPersistentSummary(ArgEffects* AE, RetEffect RE);
public:
- CFRefSummaryManager() {}
+ CFRefSummaryManager(ASTContext& ctx) : Ctx(ctx) {}
~CFRefSummaryManager();
CFRefSummary* getSummary(FunctionDecl* FD, ASTContext& Ctx);
@@ -306,19 +302,26 @@
const char* TDName = ArgT->getDecl()->getIdentifier()->getName();
assert (TDName);
- if (strcmp("CFTypeRef", TDName) == 0)
+ if (strcmp("CFTypeRef", TDName) != 0)
return NULL;
if (!ArgT->isPointerType())
return NULL;
-
- // Check the return type. It should also be "CFTypeRef".
-
+
QualType RetTy = FT->getResultType();
- if (RetTy.getTypePtr() != ArgT)
- return NULL;
-
+ if (isRetain) {
+ // CFRetain: the return type should also be "CFTypeRef".
+ if (RetTy.getTypePtr() != ArgT)
+ return NULL;
+ }
+ else {
+ // CFRelease: the return type should be void.
+
+ if (RetTy != Ctx.VoidTy)
+ return NULL;
+ }
+
// The function's interface checks out. Generate a canned summary.
assert (ScratchArgs.empty());
@@ -446,11 +449,11 @@
unsigned Data;
RefVal(unsigned K, unsigned D) : Data((D << 3) | K) {
- assert ((K & ~0x5) == 0x0);
+ assert ((K & ~0x7) == 0x0);
}
RefVal(unsigned K) : Data(K) {
- assert ((K & ~0x5) == 0x0);
+ assert ((K & ~0x7) == 0x0);
}
public:
@@ -554,7 +557,7 @@
public:
- CFRefCount() {}
+ CFRefCount(ASTContext& Ctx) : Summaries(Ctx) {}
virtual ~CFRefCount() {}
virtual void RegisterChecks(GRExprEngine& Eng);
@@ -877,4 +880,6 @@
// Transfer function creation for external clients.
//===----------------------------------------------------------------------===//
-GRTransferFuncs* clang::MakeCFRefCountTF() { return new CFRefCount(); }
+GRTransferFuncs* clang::MakeCFRefCountTF(ASTContext& Ctx) {
+ return new CFRefCount(Ctx);
+}
More information about the cfe-commits
mailing list