[PATCH] D84415: [analyzer][StdLibraryFunctionsChecker] Add POSIX pthread handling functions

Gabor Marton via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 14 07:11:41 PDT 2020


martong marked an inline comment as done.
martong added a comment.

In D84415#2218084 <https://reviews.llvm.org/D84415#2218084>, @balazske wrote:

> Even some macro-like construct can improve readability. The current way of adding functions is source of copy-paste errors because more things are repeated, these should be written only once. And the `if`s for the existence of types can be eliminated (automated) somehow. So the final way of specifying the functions is to only list (get) the types first, then add the functions with name, arguments and constraints in a way that nothing needs to be repeated and computable parts are done automatically.

Yes, this totally makes sense, thank you guys for this suggestion!

Now I've started working on to reach this form, what do you think?

  // Taking an optional as arg.
  Optional<QualType> Pthread_cond_tPtrTy = getPointerTy(Pthread_cond_tTy);
  addToFunctionSummaryMap(
      {"pthread_cond_signal", "pthread_cond_broadcast"},
      // Create a signature with Optionals, addToFunctionSummaryMap will skip
      // the summary if the optional is not set.
      Signature(ArgTypes{Pthread_cond_tPtrTy}, RetType{IntTy}),
      Summary(NoEvalCall)
          .ArgConstraint(NotNull(ArgNo(0))));

Side note, one day hopefully we could have the same API to fill a `CallDescriptionMap`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84415



More information about the cfe-commits mailing list