This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] Display a diagnostics when an inlined function violates its os_consumed summary
ClosedPublic

Authored by george.karpenkov on Dec 10 2018, 3:08 PM.

Details

Summary

This is currently a diagnostics, but might be upgraded to an error in the future,
especially if we introduce os_return_on_success attributes.

rdar://46359592

Diff Detail

Repository
rL LLVM

Event Timeline

george.karpenkov retitled this revision from [analyzer] Display a diagnostics when an inlined function violates it's os_consumed summary to [analyzer] Display a diagnostics when an inlined function violates its os_consumed summary.Dec 10 2018, 3:10 PM
NoQ accepted this revision.Dec 10 2018, 3:19 PM

Looks great!

clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
118 ↗(On Diff #177605)

Why did they return void but make an out-parameter T_T

232 ↗(On Diff #177605)

Typo intended?

235–238 ↗(On Diff #177605)

Slightly shorter:

if (SC->inTopFrame())
  return;

const StackFrameContext *PC = SC->getParent()->getStackFrame();
267–273 ↗(On Diff #177605)

A tiny bit shorter:

const ParmVarDecl *PVD = Parameters[I];
if (!PVD->hasAttr<OSConsumedAttr>())
  return nullptr;

if (SymbolRef SR = Call->getArgSVal(I).getAsLocSymbol()) {
clang/test/Analysis/osobject-retain-release.cpp
118 ↗(On Diff #177605)

// no-warning?

This revision is now accepted and ready to land.Dec 10 2018, 3:19 PM
george.karpenkov marked 4 inline comments as done.
george.karpenkov added inline comments.
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
118 ↗(On Diff #177605)

this is a formatting change.

nevertheless, which one? os has a bigger lifetime than this function.

NoQ added inline comments.Dec 10 2018, 3:32 PM
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
118 ↗(On Diff #177605)

I meant Sym.

This revision was automatically updated to reflect the committed changes.