Skip to content

Commit

Permalink
[analyzer] [NFC] Minor refactoring of ISL-specific code in RetainCoun…
Browse files Browse the repository at this point in the history
…tChecker

Differential Revision: https://reviews.llvm.org/D50879

llvm-svn: 340098
  • Loading branch information
George Karpenkov committed Aug 17, 2018
1 parent bc0cddf commit b1b791b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
Expand Up @@ -765,9 +765,7 @@ bool RetainCountChecker::evalCall(const CallExpr *CE, CheckerContext &C) const {
bool hasTrustedImplementationAnnotation = false;

// See if it's one of the specific functions we know how to eval.
bool canEval = SmrMgr.canEval(CE, FD, hasTrustedImplementationAnnotation);

if (!canEval)
if (!SmrMgr.canEval(CE, FD, hasTrustedImplementationAnnotation))
return false;

// Bind the return value.
Expand Down Expand Up @@ -1235,11 +1233,8 @@ RetainCountChecker::processLeaks(ProgramStateRef state,
return N;
}

static bool isGeneralizedObjectRef(QualType Ty) {
if (Ty.getAsString().substr(0, 4) == "isl_")
return true;
else
return false;
static bool isISLObjectRef(QualType Ty) {
return StringRef(Ty.getAsString()).startswith("isl_");
}

void RetainCountChecker::checkBeginFunction(CheckerContext &Ctx) const {
Expand All @@ -1263,9 +1258,9 @@ void RetainCountChecker::checkBeginFunction(CheckerContext &Ctx) const {

QualType Ty = Param->getType();
const ArgEffect *AE = CalleeSideArgEffects.lookup(idx);
if (AE && *AE == DecRef && isGeneralizedObjectRef(Ty)) {
if (AE && *AE == DecRef && isISLObjectRef(Ty)) {
state = setRefBinding(state, Sym, RefVal::makeOwned(RetEffect::ObjKind::Generalized, Ty));
} else if (isGeneralizedObjectRef(Ty)) {
} else if (isISLObjectRef(Ty)) {
state = setRefBinding(
state, Sym,
RefVal::makeNotOwned(RetEffect::ObjKind::Generalized, Ty));
Expand Down
Expand Up @@ -482,10 +482,10 @@ bool RetainSummaryManager::canEval(const CallExpr *CE,
return isRetain(FD, FName) || isAutorelease(FD, FName) ||
isMakeCollectable(FName);

if (FD->getDefinition()) {
bool out = isTrustedReferenceCountImplementation(FD->getDefinition());
hasTrustedImplementationAnnotation = out;
return out;
const FunctionDecl* FDD = FD->getDefinition();
if (FDD && isTrustedReferenceCountImplementation(FDD)) {
hasTrustedImplementationAnnotation = true;
return true;
}
}

Expand Down

0 comments on commit b1b791b

Please sign in to comment.