[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.
----------------
NagyDonat wrote:

`Return true` is inaccurate/confusing after a valueless `return;`

https://github.com/llvm/llvm-project/pull/80456


More information about the cfe-commits mailing list