<div dir="ltr">It looks like it was fixed, indeed. After an update I don't see an awful number of crashes any more. Thanks!</div><br><br><div class="gmail_quote"><div dir="ltr">On Mon, Mar 26, 2018 at 8:05 PM George Karpenkov <<a href="mailto:ekarpenkov@apple.com">ekarpenkov@apple.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space">Yeah, I’m pretty sure this was fixed on Friday with <a href="https://reviews.llvm.org/rC328406" target="_blank">https://reviews.llvm.org/rC328406</a><br><div><br><blockquote type="cite"><div>On Mar 26, 2018, at 10:54 AM, Alexander Kornienko <<a href="mailto:alexfh@google.com" target="_blank">alexfh@google.com</a>> wrote:</div><br class="m_-4836335935645267090Apple-interchange-newline"><div><div dir="ltr">This checker crashes on almost each file in our codebase. No test case yet, but here's a stack trace:<div><div>clang::Type::getTypeClass</div><div>clang::ReferenceType::classof</div><div>llvm::isa_impl::doit</div><div>llvm::isa_impl_cl::doit</div><div>llvm::isa_impl_wrap::doit</div><div>llvm::isa_impl_wrap::doit</div><div>llvm::isa</div><div>clang::Type::getAs</div><div>clang::ASTContext::getLValueReferenceType</div><div>::TrustNonnullChecker::checkPostCall</div><div>clang::ento::check::PostCall::_checkCall</div><div>clang::ento::CheckerFn::operator()</div><div>::CheckCallContext::runChecker</div><div>expandGraphWithCheckers</div><div>clang::ento::CheckerManager::runCheckersForCallEvent</div><div>clang::ento::CheckerManager::runCheckersForPostCall</div><div>clang::ento::ExprEngine::VisitCXXDestructor</div><div>clang::ento::ExprEngine::ProcessTemporaryDtor</div><div>clang::ento::ExprEngine::ProcessImplicitDtor</div><div>clang::ento::ExprEngine::processCFGElement</div><div>clang::ento::CoreEngine::dispatchWorkItem</div><div>clang::ento::CoreEngine::ExecuteWorkList</div><div>::AnalysisConsumer::ActionExprEngine</div><div>::AnalysisConsumer::HandleCode</div><div>::AnalysisConsumer::HandleTranslationUnit</div><div>clang::MultiplexConsumer::HandleTranslationUnit</div><div>clang::ParseAST</div><div>clang::FrontendAction::Execute</div><div>clang::CompilerInstance::ExecuteAction</div><div>clang::tooling::FrontendActionFactory::runInvocation</div><div>clang::tooling::ToolInvocation::runInvocation</div><div>clang::tooling::ToolInvocation::run</div></div><div><br></div><div>Could you fix or revert the patch?</div></div><br><br><div class="gmail_quote"><div dir="ltr">On Fri, Mar 23, 2018 at 1:18 AM George Karpenkov via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: george.karpenkov<br>
Date: Thu Mar 22 17:16:03 2018<br>
New Revision: 328282<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=328282&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=328282&view=rev</a><br>
Log:<br>
[analyzer] Trust _Nonnull annotations for system framework<br>
<br>
Changes the analyzer to believe that methods annotated with _Nonnull<br>
from system frameworks indeed return non null objects.<br>
Local methods with such annotation are still distrusted.<br>
<a>rdar://24291919</a><br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D44341" rel="noreferrer" target="_blank">https://reviews.llvm.org/D44341</a><br>
<br>
Added:<br>
cfe/trunk/lib/StaticAnalyzer/Checkers/TrustNonnullChecker.cpp<br>
cfe/trunk/test/Analysis/trustnonnullchecker_test.m<br>
Modified:<br>
cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td<br>
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h<br>
cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt<br>
cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp<br>
cfe/trunk/lib/StaticAnalyzer/Core/CheckerHelpers.cpp<br>
cfe/trunk/test/Analysis/Inputs/system-header-simulator-for-nullability.h<br>
<br>
Modified: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td?rev=328282&r1=328281&r2=328282&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td?rev=328282&r1=328281&r2=328282&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td (original)<br>
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td Thu Mar 22 17:16:03 2018<br>
@@ -218,6 +218,14 @@ def NullableReturnedFromNonnullChecker :<br>
<br>
} // end "nullability"<br>
<br>
+let ParentPackage = APIModeling in {<br>
+<br>
+def TrustNonnullChecker : Checker<"TrustNonnull">,<br>
+ HelpText<"Trust that returns from framework methods annotated with _Nonnull are not null">,<br>
+ DescFile<"TrustNonnullChecker.cpp">;<br>
+<br>
+}<br>
+<br>
//===----------------------------------------------------------------------===//<br>
// Evaluate "builtin" functions.<br>
//===----------------------------------------------------------------------===//<br>
<br>
Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h?rev=328282&r1=328281&r2=328282&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h?rev=328282&r1=328281&r2=328282&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h (original)<br>
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h Thu Mar 22 17:16:03 2018<br>
@@ -21,6 +21,8 @@ namespace clang {<br>
<br>
class Expr;<br>
class VarDecl;<br>
+class QualType;<br>
+class AttributedType;<br>
<br>
namespace ento {<br>
<br>
@@ -42,6 +44,25 @@ template <class T> bool containsStmt(con<br>
std::pair<const clang::VarDecl *, const clang::Expr *><br>
parseAssignment(const Stmt *S);<br>
<br>
+// Do not reorder! The getMostNullable method relies on the order.<br>
+// Optimization: Most pointers expected to be unspecified. When a symbol has an<br>
+// unspecified or nonnull type non of the rules would indicate any problem for<br>
+// that symbol. For this reason only nullable and contradicted nullability are<br>
+// stored for a symbol. When a symbol is already contradicted, it can not be<br>
+// casted back to nullable.<br>
+enum class Nullability : char {<br>
+ Contradicted, // Tracked nullability is contradicted by an explicit cast. Do<br>
+ // not report any nullability related issue for this symbol.<br>
+ // This nullability is propagated aggressively to avoid false<br>
+ // positive results. See the comment on getMostNullable method.<br>
+ Nullable,<br>
+ Unspecified,<br>
+ Nonnull<br>
+};<br>
+<br>
+/// Get nullability annotation for a given type.<br>
+Nullability getNullabilityAnnotation(QualType Type);<br>
+<br>
} // end GR namespace<br>
<br>
} // end clang namespace<br>
<br>
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt?rev=328282&r1=328281&r2=328282&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt?rev=328282&r1=328281&r2=328282&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt (original)<br>
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt Thu Mar 22 17:16:03 2018<br>
@@ -84,6 +84,7 @@ add_clang_library(clangStaticAnalyzerChe<br>
TaintTesterChecker.cpp<br>
TestAfterDivZeroChecker.cpp<br>
TraversalChecker.cpp<br>
+ TrustNonnullChecker.cpp<br>
UndefBranchChecker.cpp<br>
UndefCapturedBlockVarChecker.cpp<br>
UndefResultChecker.cpp<br>
<br>
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp?rev=328282&r1=328281&r2=328282&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp?rev=328282&r1=328281&r2=328282&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp (original)<br>
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp Thu Mar 22 17:16:03 2018<br>
@@ -30,6 +30,7 @@<br>
#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"<br>
#include "clang/StaticAnalyzer/Core/Checker.h"<br>
#include "clang/StaticAnalyzer/Core/CheckerManager.h"<br>
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h"<br>
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"<br>
#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"<br>
<br>
@@ -40,21 +41,6 @@ using namespace clang;<br>
using namespace ento;<br>
<br>
namespace {<br>
-// Do not reorder! The getMostNullable method relies on the order.<br>
-// Optimization: Most pointers expected to be unspecified. When a symbol has an<br>
-// unspecified or nonnull type non of the rules would indicate any problem for<br>
-// that symbol. For this reason only nullable and contradicted nullability are<br>
-// stored for a symbol. When a symbol is already contradicted, it can not be<br>
-// casted back to nullable.<br>
-enum class Nullability : char {<br>
- Contradicted, // Tracked nullability is contradicted by an explicit cast. Do<br>
- // not report any nullability related issue for this symbol.<br>
- // This nullability is propagated aggressively to avoid false<br>
- // positive results. See the comment on getMostNullable method.<br>
- Nullable,<br>
- Unspecified,<br>
- Nonnull<br>
-};<br>
<br>
/// Returns the most nullable nullability. This is used for message expressions<br>
/// like [receiver method], where the nullability of this expression is either<br>
@@ -345,17 +331,6 @@ NullabilityChecker::NullabilityBugVisito<br>
nullptr);<br>
}<br>
<br>
-static Nullability getNullabilityAnnotation(QualType Type) {<br>
- const auto *AttrType = Type->getAs<AttributedType>();<br>
- if (!AttrType)<br>
- return Nullability::Unspecified;<br>
- if (AttrType->getAttrKind() == AttributedType::attr_nullable)<br>
- return Nullability::Nullable;<br>
- else if (AttrType->getAttrKind() == AttributedType::attr_nonnull)<br>
- return Nullability::Nonnull;<br>
- return Nullability::Unspecified;<br>
-}<br>
-<br>
/// Returns true when the value stored at the given location is null<br>
/// and the passed in type is nonnnull.<br>
static bool checkValueAtLValForInvariantViolation(ProgramStateRef State,<br>
@@ -872,7 +847,7 @@ void NullabilityChecker::checkPostObjCMe<br>
// are either item retrieval related or not interesting nullability wise.<br>
// Using this fact, to keep the code easier to read just ignore the return<br>
// value of every instance method of dictionaries.<br>
- if (M.isInstanceMessage() && Name.find("Dictionary") != StringRef::npos) {<br>
+ if (M.isInstanceMessage() && Name.contains("Dictionary")) {<br>
State =<br>
State->set<NullabilityMap>(ReturnRegion, Nullability::Contradicted);<br>
C.addTransition(State);<br>
@@ -880,7 +855,7 @@ void NullabilityChecker::checkPostObjCMe<br>
}<br>
// For similar reasons ignore some methods of Cocoa arrays.<br>
StringRef FirstSelectorSlot = M.getSelector().getNameForSlot(0);<br>
- if (Name.find("Array") != StringRef::npos &&<br>
+ if (Name.contains("Array") &&<br>
(FirstSelectorSlot == "firstObject" ||<br>
FirstSelectorSlot == "lastObject")) {<br>
State =<br>
@@ -893,7 +868,7 @@ void NullabilityChecker::checkPostObjCMe<br>
// encodings are used. Using lossless encodings is so frequent that ignoring<br>
// this class of methods reduced the emitted diagnostics by about 30% on<br>
// some projects (and all of that was false positives).<br>
- if (Name.find("String") != StringRef::npos) {<br>
+ if (Name.contains("String")) {<br>
for (auto Param : M.parameters()) {<br>
if (Param->getName() == "encoding") {<br>
State = State->set<NullabilityMap>(ReturnRegion,<br>
<br>
Added: cfe/trunk/lib/StaticAnalyzer/Checkers/TrustNonnullChecker.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/TrustNonnullChecker.cpp?rev=328282&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/TrustNonnullChecker.cpp?rev=328282&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/lib/StaticAnalyzer/Checkers/TrustNonnullChecker.cpp (added)<br>
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/TrustNonnullChecker.cpp Thu Mar 22 17:16:03 2018<br>
@@ -0,0 +1,52 @@<br>
+//== TrustNonnullChecker.cpp - Checker for trusting annotations -*- C++ -*--==//<br>
+//<br>
+// The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===----------------------------------------------------------------------===//<br>
+//<br>
+// This checker adds an assumption that methods annotated with _Nonnull<br>
+// which come from system headers actually return a non-null pointer.<br>
+//<br>
+//===----------------------------------------------------------------------===//<br>
+<br>
+#include "ClangSACheckers.h"<br>
+#include "clang/StaticAnalyzer/Core/Checker.h"<br>
+#include "clang/StaticAnalyzer/Core/CheckerManager.h"<br>
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"<br>
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h"<br>
+#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"<br>
+<br>
+using namespace clang;<br>
+using namespace ento;<br>
+<br>
+namespace {<br>
+<br>
+class TrustNonnullChecker : public Checker<check::PostCall> {<br>
+public:<br>
+ void checkPostCall(const CallEvent &Call, CheckerContext &C) const {<br>
+ // Only trust annotations for system headers for non-protocols.<br>
+ if (!Call.isInSystemHeader())<br>
+ return;<br>
+<br>
+ QualType RetType = Call.getResultType();<br>
+ if (!RetType->isAnyPointerType())<br>
+ return;<br>
+<br>
+ ProgramStateRef State = C.getState();<br>
+ if (getNullabilityAnnotation(RetType) == Nullability::Nonnull)<br>
+ if (auto L = Call.getReturnValue().getAs<Loc>())<br>
+ State = State->assume(*L, /*Assumption=*/true);<br>
+<br>
+ C.addTransition(State);<br>
+ }<br>
+};<br>
+<br>
+} // end empty namespace<br>
+<br>
+<br>
+void ento::registerTrustNonnullChecker(CheckerManager &Mgr) {<br>
+ Mgr.registerChecker<TrustNonnullChecker>();<br>
+}<br>
<br>
Modified: cfe/trunk/lib/StaticAnalyzer/Core/CheckerHelpers.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CheckerHelpers.cpp?rev=328282&r1=328281&r2=328282&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CheckerHelpers.cpp?rev=328282&r1=328281&r2=328282&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/StaticAnalyzer/Core/CheckerHelpers.cpp (original)<br>
+++ cfe/trunk/lib/StaticAnalyzer/Core/CheckerHelpers.cpp Thu Mar 22 17:16:03 2018<br>
@@ -15,8 +15,12 @@<br>
#include "clang/AST/Decl.h"<br>
#include "clang/AST/Expr.h"<br>
<br>
+namespace clang {<br>
+<br>
+namespace ento {<br>
+<br>
// Recursively find any substatements containing macros<br>
-bool clang::ento::containsMacro(const Stmt *S) {<br>
+bool containsMacro(const Stmt *S) {<br>
if (S->getLocStart().isMacroID())<br>
return true;<br>
<br>
@@ -31,7 +35,7 @@ bool clang::ento::containsMacro(const St<br>
}<br>
<br>
// Recursively find any substatements containing enum constants<br>
-bool clang::ento::containsEnum(const Stmt *S) {<br>
+bool containsEnum(const Stmt *S) {<br>
const DeclRefExpr *DR = dyn_cast<DeclRefExpr>(S);<br>
<br>
if (DR && isa<EnumConstantDecl>(DR->getDecl()))<br>
@@ -45,7 +49,7 @@ bool clang::ento::containsEnum(const Stm<br>
}<br>
<br>
// Recursively find any substatements containing static vars<br>
-bool clang::ento::containsStaticLocal(const Stmt *S) {<br>
+bool containsStaticLocal(const Stmt *S) {<br>
const DeclRefExpr *DR = dyn_cast<DeclRefExpr>(S);<br>
<br>
if (DR)<br>
@@ -61,7 +65,7 @@ bool clang::ento::containsStaticLocal(co<br>
}<br>
<br>
// Recursively find any substatements containing __builtin_offsetof<br>
-bool clang::ento::containsBuiltinOffsetOf(const Stmt *S) {<br>
+bool containsBuiltinOffsetOf(const Stmt *S) {<br>
if (isa<OffsetOfExpr>(S))<br>
return true;<br>
<br>
@@ -74,7 +78,7 @@ bool clang::ento::containsBuiltinOffsetO<br>
<br>
// Extract lhs and rhs from assignment statement<br>
std::pair<const clang::VarDecl *, const clang::Expr *><br>
-clang::ento::parseAssignment(const Stmt *S) {<br>
+parseAssignment(const Stmt *S) {<br>
const VarDecl *VD = nullptr;<br>
const Expr *RHS = nullptr;<br>
<br>
@@ -94,3 +98,18 @@ clang::ento::parseAssignment(const Stmt<br>
<br>
return std::make_pair(VD, RHS);<br>
}<br>
+<br>
+Nullability getNullabilityAnnotation(QualType Type) {<br>
+ const auto *AttrType = Type->getAs<AttributedType>();<br>
+ if (!AttrType)<br>
+ return Nullability::Unspecified;<br>
+ if (AttrType->getAttrKind() == AttributedType::attr_nullable)<br>
+ return Nullability::Nullable;<br>
+ else if (AttrType->getAttrKind() == AttributedType::attr_nonnull)<br>
+ return Nullability::Nonnull;<br>
+ return Nullability::Unspecified;<br>
+}<br>
+<br>
+<br>
+} // end namespace ento<br>
+} // end namespace clang<br>
<br>
Modified: cfe/trunk/test/Analysis/Inputs/system-header-simulator-for-nullability.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/Inputs/system-header-simulator-for-nullability.h?rev=328282&r1=328281&r2=328282&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/Inputs/system-header-simulator-for-nullability.h?rev=328282&r1=328281&r2=328282&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/Analysis/Inputs/system-header-simulator-for-nullability.h (original)<br>
+++ cfe/trunk/test/Analysis/Inputs/system-header-simulator-for-nullability.h Thu Mar 22 17:16:03 2018<br>
@@ -32,6 +32,8 @@ NSObject<NSObject><br>
@interface NSString : NSObject<NSCopying><br>
- (BOOL)isEqualToString : (NSString *)aString;<br>
- (NSString *)stringByAppendingString:(NSString *)aString;<br>
++ (_Nonnull NSString *) generateString;<br>
++ (_Nullable NSString *) generatePossiblyNullString;<br>
@end<br>
<br>
void NSSystemFunctionTakingNonnull(NSString *s);<br>
@@ -40,4 +42,11 @@ void NSSystemFunctionTakingNonnull(NSStr<br>
- (void) takesNonnull:(NSString *)s;<br>
@end<br>
<br>
+NSString* _Nullable getPossiblyNullString();<br>
+NSString* _Nonnull getString();<br>
+<br>
+@protocol MyProtocol<br>
+- (_Nonnull NSString *) getString;<br>
+@end<br>
+<br>
NS_ASSUME_NONNULL_END<br>
<br>
Added: cfe/trunk/test/Analysis/trustnonnullchecker_test.m<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/trustnonnullchecker_test.m?rev=328282&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/trustnonnullchecker_test.m?rev=328282&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/Analysis/trustnonnullchecker_test.m (added)<br>
+++ cfe/trunk/test/Analysis/trustnonnullchecker_test.m Thu Mar 22 17:16:03 2018<br>
@@ -0,0 +1,43 @@<br>
+// RUN: %clang_analyze_cc1 -fblocks -analyze -analyzer-checker=core,nullability,apiModeling -verify %s<br>
+<br>
+#include "Inputs/system-header-simulator-for-nullability.h"<br>
+<br>
+NSString* getUnknownString();<br>
+<br>
+NSString* _Nonnull trust_nonnull_framework_annotation() {<br>
+ NSString* out = [NSString generateString];<br>
+ if (out) {}<br>
+ return out; // no-warning<br>
+}<br>
+<br>
+NSString* _Nonnull distrust_without_annotation() {<br>
+ NSString* out = [NSString generatePossiblyNullString];<br>
+ if (out) {}<br>
+ return out; // expected-warning{{}}<br>
+}<br>
+<br>
+NSString* _Nonnull nonnull_please_trust_me();<br>
+<br>
+NSString* _Nonnull distrust_local_nonnull_annotation() {<br>
+ NSString* out = nonnull_please_trust_me();<br>
+ if (out) {}<br>
+ return out; // expected-warning{{}}<br>
+}<br>
+<br>
+NSString* _Nonnull trust_c_function() {<br>
+ NSString* out = getString();<br>
+ if (out) {};<br>
+ return out; // no-warning<br>
+}<br>
+<br>
+NSString* _Nonnull distrust_unannoted_function() {<br>
+ NSString* out = getPossiblyNullString();<br>
+ if (out) {};<br>
+ return out; // expected-warning{{}}<br>
+}<br>
+<br>
+NSString * _Nonnull distrustProtocol(id<MyProtocol> o) {<br>
+ NSString* out = [o getString];<br>
+ if (out) {};<br>
+ return out; // expected-warning{{}}<br>
+}<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div>
</div></blockquote></div><br></div></blockquote></div>