[PATCH] D42192: [analyzer] Assume that the allocated value is non-null before construction, not after.

George Karpenkov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 17 11:45:55 PST 2018

george.karpenkov added inline comments.

Comment at: lib/StaticAnalyzer/Core/ExprEngineCXX.cpp:514
+      QualType Ty = FD->getType();
+      if (const FunctionProtoType *ProtoType = Ty->getAs<FunctionProtoType>())
+        if (!ProtoType->isNothrow(getContext()))

Comment at: lib/StaticAnalyzer/Core/ExprEngineCXX.cpp:516
+        if (!ProtoType->isNothrow(getContext()))
+          State = State->assume(RetVal.castAs<DefinedOrUnknownSVal>(), true);
+    }
This is neither here nor there, but for this and many other cases I think we could be considerably more readable by defining helpers `State->assumeIsTrue` and `State->assumeIsFalse` (or `assumeNonNull`, or whatever is most descriptive)

  rC Clang


More information about the cfe-commits mailing list