[PATCH] D80016: [analyzer] StdLibraryFunctionsChecker: Add support to lookup types

Gabor Marton via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu May 28 07:02:45 PDT 2020


martong added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:747
+                          : *FilePtrTy)
+                : None;
+
----------------
balazske wrote:
> martong wrote:
> > balazske wrote:
> > > The `Optional<QualType>` can be left out from the right side expressions (in the `?` operator part). (A `QualType` should be assignable to `Optional<QualType>`.)
> > No that cannot be left out. Implicit conversion does not play when trying to determine the common type for the 2nd and 3rd argument of the ternary op. https://stackoverflow.com/questions/32251419/c-ternary-operator-conditional-operator-and-its-implicit-type-conversion-r
> > So, removing the explicit type I get a compile error.
> Still I do not like that code. Probably this is better then:
> ```
>   Optional<QualType> FilePtrTy, FilePtrRestrictTy;
>   if (FileTy) {
>     FilePtrTy = ACtx.getPointerType(*FileTy);
>     FilePtrRestrictTy = ACtx.getLangOpts().C99
>                             ? ACtx.getRestrictType(*FilePtrTy) // FILE *restrict
>                             : *FilePtrTy)
>   }
> ```
Ok, I added the `if`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80016





More information about the cfe-commits mailing list