tahonermann added inline comments.

================
Comment at: clang/lib/StaticAnalyzer/Core/MemRegion.cpp:1034-1042
+          if (T.isNull() || !T->getAs<FunctionType>())
+            // If the type is invalid or is not a function type, we cannot get
+            // a block pointer type for it. This isn't ideal, but it's better
+            // than asserting in getBlockPointerType() or creating a function
+            // without a prototype in a language that has no such concept (like
+            // C++ or C2x).
+            sReg = getUnknownRegion();
----------------
rsmith wrote:
> I find it really surprising that the "signature is present but is not a 
> function type" case is reachable -- the static analyzer should only run on 
> valid code, and in valid code I'd expect the signature of a block would 
> always be a function type. Is that  case actually reached in our test suite?
> 
> I worry that the "block has no explicit signature" case here is common, and 
> that we're losing substantial coverage in that case. Per 
> https://clang.llvm.org/docs/BlockLanguageSpec.html#block-literal-expressions, 
> `^ {  ...  }` is equivalent  to `^ (void) { ... }`, so it seems the original 
> code here was just wrong and we should always have been creating a 
> `FunctionProtoType`  in this case.
I haven't studied the surrounding code much, so perhaps this comment isn't 
applicable, but I would expect `FunctionProtoType` to be applicable when an 
empty parameter list is explicitly specified as in `^ () { ... }` prior to C2x.


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

https://reviews.llvm.org/D123955

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

Reply via email to