[all-commits] [llvm/llvm-project] d1856b: [analyzer][NFC] Prefer CallEvent over CallExpr in ...

Balazs Benics via All-commits all-commits at lists.llvm.org
Thu Dec 28 07:08:13 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d1856b2f18c412f8ffbeee30e6e0316c197c143c
      https://github.com/llvm/llvm-project/commit/d1856b2f18c412f8ffbeee30e6e0316c197c143c
  Author: Balazs Benics <benicsbalazs at gmail.com>
  Date:   2023-12-28 (Thu, 28 Dec 2023)

  Changed paths:
    M clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp

  Log Message:
  -----------
  [analyzer][NFC] Prefer CallEvent over CallExpr in APIs

This change only uplifts existing APIs, without any semantic changes.
This is the continuation of 44820630dfa45bc47748a5abda7d4a9cb86da2c1.

Benefits of using CallEvents over CallExprs:
The callee decl is traced through function pointers if possible.
This will be important to fix #74269 in a follow-up patch.


  Commit: a49cf6c14ad498244fee6026da59cfdcdad6b80c
      https://github.com/llvm/llvm-project/commit/a49cf6c14ad498244fee6026da59cfdcdad6b80c
  Author: Balazs Benics <benicsbalazs at gmail.com>
  Date:   2023-12-28 (Thu, 28 Dec 2023)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
    M clang/test/Analysis/string.cpp

  Log Message:
  -----------
  [analyzer] Fix "sprintf" parameter modeling in CStringChecker

`CE->getCalleeDecl()` returns `VarDecl` if the callee is actually a
function pointer variable. Consequently, calling `getAsFunction()` will
return null.

To workaround the case, we should use the `CallEvent::parameters()`,
which will internally recover the function being called and do the right
thing.

Fixes #74269
Depends on "[analyzer][NFC] Prefer CallEvent over CallExpr in APIs"


Compare: https://github.com/llvm/llvm-project/compare/d488adb7c292...a49cf6c14ad4


More information about the All-commits mailing list