[PATCH] D12889: [Static Analyzer] Generics Checker: When an ObjC method returns a specialized object, track it properly.

Gábor Horváth via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 15 17:39:44 PDT 2015


xazax.hun added inline comments.

================
Comment at: lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp:675
@@ +674,3 @@
+
+  QualType ResultType = Method->getReturnType().substObjCTypeArgs(
+      C, TypeArgs, ObjCSubstitutionContext::Result);
----------------
zaks.anna wrote:
> Could you use StaticResultType here?
In StaticResultType every occurrence of a Type Argument is replaced with id, which is not suitable for type checking.

================
Comment at: lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp:795
@@ -817,1 +794,3 @@
+  // Checking that the return type is used correctly is done in pre-call to get
+  // cleaner diagnostic paths.
   checkReturnType(MessageExpr, *TrackedType, Sym, Method, *TypeArgs,
----------------
zaks.anna wrote:
> The path is longer if the call is inlined, correct? (Not much difference otherwise..)
In fact there is a heuristic that omits the stepping in into the function when the diagnostic is generated. I moved this check to the post call callback.

================
Comment at: lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp:803
@@ +802,3 @@
+/// initialized with by invoking the 'class' method on a class.
+/// This method is also used to infer the type information for the return
+/// types.
----------------
zaks.anna wrote:
> It looks like it's only inferring the type information of the specializations and not for non-generic types..
Added a todo for the missing case.


http://reviews.llvm.org/D12889





More information about the cfe-commits mailing list