[PATCH] D77658: [analyzer] StdLibraryFunctionsChecker: Add sanity checks for constraints

Balázs Kéri via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 8 02:40:01 PDT 2020


balazske added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:116
+    /// Do sanity check on the constraint.
+    virtual bool validate(const FunctionDecl *) const { return true; }
     ArgNo getArgNo() const { return ArgN; }
----------------
Is it possible to have the validate on the signature (not function decl)? Because the function decl (where the rule is applied) should match the signature already. For example, if the signature contains an irrelevant type it is not good to have a rule that expects a `void*` at that place. After these rules are validated with the signature, they should be applicable on a (any) function that matches the signature.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:306
+    // Once we know the exact type of the function then do sanity check on all
+    // the given constraints.
+    bool validate(const FunctionDecl *FD) {
----------------
So this is a check to be used at debug build only to check for programming errors?
It could be better to separate this task from setting the `FD` itself. Or this function can be called `setFD` and contain a validation if in debug mode (or always). Probably it is better to do the validation always to filter out unexpected found functions (if some unusual API is encountered).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77658/new/

https://reviews.llvm.org/D77658





More information about the cfe-commits mailing list