Inside lambdas.cpp a block of code wasn't executed,
because they required the standard to be at least
-std=c++14. This patch moves this block of code into
it's own source file.
Details
Diff Detail
Event Timeline
Moved clang_analyzer_eval() out of the lambda body, because no diagnostic was reported from the inside.
I quickly looked at the source code of the said checker and I found this:
void ExprInspectionChecker::analyzerEval(const CallExpr *CE, CheckerContext &C) const { const LocationContext *LC = C.getPredecessor()->getLocationContext(); // A specific instantiation of an inlined function may have more constrained // values than can generally be assumed. Skip the check. if (LC->getStackFrame()->getParent() != nullptr) return; reportBug(getArgumentValueString(CE, C), C); }
I guess the parent stack frame of the lambda is the function in which it's declared, so the bug reportion is skipped.
Oh, I see, this look deliberate. I wonder if we want to add an exception for lambdas though but that would be a different discussions unrelated to this PR.
We could also consider reporting a warning or an error in this case to let the caller know that the function doesn't work in this context. Right now it's up to the caller to figure it out on their own, and if they don't see the report they might think there's something wrong with some other part of their code.