[cfe-dev] Checking if a ParmVarDecl is null in a Checker
Timothy J. Wood via cfe-dev
cfe-dev at lists.llvm.org
Tue Apr 24 13:52:09 PDT 2018
I’m attempting to add a Checker subclass that will warn on NSError-returning functions that return failure without having written to their outError parameter.
The bit I’m currently stuck on is this simple test input:
- (BOOL)failWithError:(NSError **)outError;
{
if (outError) {
*outError = [NSError errorWithDomain:@"domain" code:1 userInfo:nil];
}
(void)outError; // Added as a precaution in reference to <http://lists.llvm.org/pipermail/cfe-dev/2017-April/053510.html>
return NO;
}
In my `checkEndFunction` implementation, I can look up the ParmVarDecl for `outError`, but if I do something like:
class Loc LV = State->getLValue(OutError, LocCtxt);
ConditionTruthVal IsNull = State->isNull(LV);
The IsNull returned is marked under constrained when checking the path where outError was NULL.
Since this is my first attempt at writing a checker after reading <https://llvm.org/devmtg/2012-11/Zaks-Rose-Checker24Hours.pdf> and <https://clang-analyzer.llvm.org/checker_dev_manual.html>, I’m probably doing something horribly wrong (still stumbling around trying to figure out the difference between SVal/Loc/SymbolRef/MemRegion and their conversions…), so any pointers would be helpful.
Thanks!
-tim
More information about the cfe-dev
mailing list