balazske added inline comments.

================
Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:882
+  const QualType SizePtrTy = getPointerTy(SizeTy);
+  const QualType SizePtrRestrictTy = getRestrictTy(SizePtrTy);
 
----------------
martong wrote:
> balazske wrote:
> > Another idea: Have a class that handles all the variants (simple, pointer, 
> > const pointer, const restrict pointer, restrict). It can have get functions 
> > that compute the type if not done yet, or get every variant at first time 
> > even if it is later not used (or has no sense).
> > For example create it like `TypeVariants SizeTy{ACtx.getSizeType()};` and 
> > then call `SizeTy.getType()`, `SizeTy.asPtr()`, `SizeTy.asPtrRestrict()`, 
> > ... .
> > ```
> I'd rather keep the current form, because I think it makes it easier to 
> compose types from different base types (and it is similar to the ASTMatchers 
> in this sense).
If I got it correctly, the problem with my approach above is that it has 
separate functions for every special type variant. The current is acceptable 
but looks not fully uniform to me (the type has a `withConst` and for getting a 
pointer or restrict there is a function call). We could have something like a 
"`TypeBuilder`" that has methods `withConst()`, `withRestrict()`, 
`withPointerTo()` (these can return a TypeBuilder too) and finally a 
(omittable) `getType()` that returns `Optional<QualType>`.
```
const QualType ConstVoidPtrRestrictTy = TypeBuilder{ACtx, 
VoidTy}.withConst().withPointerTo().withRestrict().getType();
```



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84415

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to