[PATCH] D80016: [analyzer] StdLibraryFunctionsChecker: Add support to lookup types
Balázs Kéri via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 27 01:35:20 PDT 2020
balazske added inline comments.
================
Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:747
+ : *FilePtrTy)
+ : None;
+
----------------
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)
}
```
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