[clang] [analyzer] Teach analzer about ms __analyzer_assume(bool) and friends (PR #80456)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 2 09:07:19 PST 2024
================
@@ -26,10 +27,41 @@ namespace {
class BuiltinFunctionChecker : public Checker<eval::Call> {
public:
bool evalCall(const CallEvent &Call, CheckerContext &C) const;
+
+private:
+ const CallDescriptionSet MicrosoftAnalysisAssume{
+ {{"__analysis_assume"}, 1},
+ {{"_Analysis_assume_"}, 1},
+ };
+
+ void evalCallAssume(const CallEvent &Call, CheckerContext &C) const;
};
}
+void BuiltinFunctionChecker::evalCallAssume(const CallEvent &Call,
+ CheckerContext &C) const {
+ assert(Call.getNumArgs() > 0);
+ assert(Call.getResultType()->isVoidType());
+ SVal Arg = Call.getArgSVal(0);
+
+ if (Arg.isUndef())
+ return; // Return true to model purity.
+
+ ProgramStateRef State = C.getState();
+ State = State->assume(Arg.castAs<DefinedOrUnknownSVal>(), true);
+
+ // FIXME: do we want to warn here? Not right now. The most reports might
+ // come from infeasible paths, thus being false positives.
+ if (!State) {
+ C.generateSink(C.getState(), C.getPredecessor());
+ return;
+ }
+
+ C.addTransition(State);
+ return;
----------------
NagyDonat wrote:
```suggestion
```
This is the last line of a `void` function.
https://github.com/llvm/llvm-project/pull/80456
More information about the cfe-commits
mailing list