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

Balázs Kéri via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 14 06:26:18 PDT 2020


balazske added a comment.

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.



================
Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:2013
+    if (Pthread_tTy) {
+      Pthread_tPtrTy = ACtx.getPointerType(*Pthread_tTy);
+      Pthread_tPtrRestrictTy = getRestrictTy(*Pthread_tPtrTy);
----------------
martong wrote:
> vsavchenko wrote:
> > It feels like the readability of the code here can be drastically improved by introducing functions `getPointerType`, `getRestrictType`, and similar accepting `Optional` arguments. 
> Yeah, we already have `getRestrictTy`, but never though to have `getPointerTy`, which indeed simplifies the code, thanks!
I think the improvement would be if these `get` functions accept `Optional` arguments and if the argument is empty return an empty value. This can make the `if`s unnecessary.


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