Index: cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt +++ cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt @@ -33,6 +33,7 @@ DirectIvarAssignment.cpp DivZeroChecker.cpp DynamicTypePropagation.cpp + DynamicTypeChecker.cpp ExprInspectionChecker.cpp FixedAddressChecker.cpp GenericTaintChecker.cpp Index: cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td +++ cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td @@ -129,6 +129,10 @@ HelpText<"Check for division by variable that is later compared against 0. Either the comparison is useless or there is division by zero.">, DescFile<"TestAfterDivZeroChecker.cpp">; +def DynamicTypeChecker : Checker<"DynamicTypeChecker">, + HelpText<"Check for cases where the dynamic and the static type of an object are unrelated.">, + DescFile<"DynamicTypeChecker.cpp">; + } // end "alpha.core" let ParentPackage = Nullability in { Index: cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypeChecker.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypeChecker.cpp +++ cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypeChecker.cpp @@ -0,0 +1,202 @@ +//== DynamicTypeChecker.cpp ------------------------------------ -*- C++ -*--=// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This checker looks for cases where the dynamic type of an object is unrelated +// to its static type. The type information utilized by this check is collected +// by the DynamicTypePropagation checker. This check does not report any type +// error for ObjC Generic types, in order to avoid duplicate erros from the +// ObjC Generics checker. This checker is not supposed to modify the program +// state, it is just the observer of the type information provided by other +// checkers. +// +//===----------------------------------------------------------------------===// + +#include "ClangSACheckers.h" +#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h" +#include "clang/StaticAnalyzer/Core/Checker.h" +#include "clang/StaticAnalyzer/Core/CheckerManager.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h" + +using namespace clang; +using namespace ento; + +namespace { +class DynamicTypeChecker : public Checker> { + mutable std::unique_ptr BT; + void initBugType() const { + if (!BT) + BT.reset( + new BugType(this, "Dynamic and static type mismatch", "Type Error")); + } + + class DynamicTypeBugVisitor + : public BugReporterVisitorImpl { + public: + DynamicTypeBugVisitor(const MemRegion *Reg) : Reg(Reg) {} + + void Profile(llvm::FoldingSetNodeID &ID) const override { + static int X = 0; + ID.AddPointer(&X); + ID.AddPointer(Reg); + } + + PathDiagnosticPiece *VisitNode(const ExplodedNode *N, + const ExplodedNode *PrevN, + BugReporterContext &BRC, + BugReport &BR) override; + + private: + // The tracked region. + const MemRegion *Reg; + }; + + void reportTypeError(QualType DynamicType, QualType StaticType, + const MemRegion *Reg, const Stmt *ReportedNode, + CheckerContext &C) const; + +public: + void checkPostStmt(const ImplicitCastExpr *CE, CheckerContext &C) const; +}; +} + +void DynamicTypeChecker::reportTypeError(QualType DynamicType, + QualType StaticType, + const MemRegion *Reg, + const Stmt *ReportedNode, + CheckerContext &C) const { + initBugType(); + SmallString<192> Buf; + llvm::raw_svector_ostream OS(Buf); + OS << "Object has a dynamic type '"; + QualType::print(DynamicType.getTypePtr(), Qualifiers(), OS, C.getLangOpts(), + llvm::Twine()); + OS << "' which is incompatible with static type '"; + QualType::print(StaticType.getTypePtr(), Qualifiers(), OS, C.getLangOpts(), + llvm::Twine()); + OS << "'"; + std::unique_ptr R( + new BugReport(*BT, OS.str(), C.generateNonFatalErrorNode())); + R->markInteresting(Reg); + R->addVisitor(llvm::make_unique(Reg)); + R->addRange(ReportedNode->getSourceRange()); + C.emitReport(std::move(R)); +} + +PathDiagnosticPiece *DynamicTypeChecker::DynamicTypeBugVisitor::VisitNode( + const ExplodedNode *N, const ExplodedNode *PrevN, BugReporterContext &BRC, + BugReport &BR) { + ProgramStateRef State = N->getState(); + ProgramStateRef StatePrev = PrevN->getState(); + + DynamicTypeInfo TrackedType = getDynamicTypeInfo(State, Reg); + DynamicTypeInfo TrackedTypePrev = getDynamicTypeInfo(StatePrev, Reg); + if (!TrackedType.isValid()) + return nullptr; + + if (TrackedTypePrev.isValid() && + TrackedTypePrev.getType() == TrackedType.getType()) + return nullptr; + + // Retrieve the associated statement. + const Stmt *S = nullptr; + ProgramPoint ProgLoc = N->getLocation(); + if (Optional SP = ProgLoc.getAs()) { + S = SP->getStmt(); + } + + if (!S) + return nullptr; + + const LangOptions &LangOpts = BRC.getASTContext().getLangOpts(); + + SmallString<256> Buf; + llvm::raw_svector_ostream OS(Buf); + OS << "Type '"; + QualType::print(TrackedType.getType().getTypePtr(), Qualifiers(), OS, + LangOpts, llvm::Twine()); + OS << "' is inferred from "; + + if (const auto *ExplicitCast = dyn_cast(S)) { + OS << "explicit cast (from '"; + QualType::print(ExplicitCast->getSubExpr()->getType().getTypePtr(), + Qualifiers(), OS, LangOpts, llvm::Twine()); + OS << "' to '"; + QualType::print(ExplicitCast->getType().getTypePtr(), Qualifiers(), OS, + LangOpts, llvm::Twine()); + OS << "')"; + } else if (const auto *ImplicitCast = dyn_cast(S)) { + OS << "implicit cast (from '"; + QualType::print(ImplicitCast->getSubExpr()->getType().getTypePtr(), + Qualifiers(), OS, LangOpts, llvm::Twine()); + OS << "' to '"; + QualType::print(ImplicitCast->getType().getTypePtr(), Qualifiers(), OS, + LangOpts, llvm::Twine()); + OS << "')"; + } else { + OS << "this context"; + } + + // Generate the extra diagnostic. + PathDiagnosticLocation Pos(S, BRC.getSourceManager(), + N->getLocationContext()); + return new PathDiagnosticEventPiece(Pos, OS.str(), true, nullptr); +} + +// TODO: consider checking explicit casts? +void DynamicTypeChecker::checkPostStmt(const ImplicitCastExpr *CE, + CheckerContext &C) const { + // TODO: C++ support. + if (CE->getCastKind() != CK_BitCast) + return; + + const MemRegion *Region = C.getSVal(CE).getAsRegion(); + if (!Region) + return; + + ProgramStateRef State = C.getState(); + DynamicTypeInfo DynTypeInfo = getDynamicTypeInfo(State, Region); + + if (!DynTypeInfo.isValid()) + return; + + QualType DynType = DynTypeInfo.getType(); + QualType StaticType = CE->getType(); + + const auto *DynObjCType = DynType->getAs(); + const auto *StaticObjCType = StaticType->getAs(); + + if (!DynObjCType || !StaticObjCType) + return; + + ASTContext &ASTCtxt = C.getASTContext(); + + // Strip kindeofness to correctly detect subtyping relationships. + DynObjCType = DynObjCType->stripObjCKindOfTypeAndQuals(ASTCtxt); + StaticObjCType = StaticObjCType->stripObjCKindOfTypeAndQuals(ASTCtxt); + + // Specialized objects are handled by the generics checker. + if (StaticObjCType->isSpecialized()) + return; + + if (ASTCtxt.canAssignObjCInterfaces(StaticObjCType, DynObjCType)) + return; + + if (DynTypeInfo.canBeASubClass() && + ASTCtxt.canAssignObjCInterfaces(DynObjCType, StaticObjCType)) + return; + + reportTypeError(DynType, StaticType, Region, CE, C); +} + +void ento::registerDynamicTypeChecker(CheckerManager &mgr) { + mgr.registerChecker(); +} Index: cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp +++ cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp @@ -22,7 +22,6 @@ //===----------------------------------------------------------------------===// #include "ClangSACheckers.h" -#include "clang/AST/ParentMap.h" #include "clang/AST/RecursiveASTVisitor.h" #include "clang/Basic/Builtins.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h" @@ -98,13 +97,6 @@ const ObjCObjectPointerType *To, ExplodedNode *N, SymbolRef Sym, CheckerContext &C, const Stmt *ReportedNode = nullptr) const; - - bool isReturnValueMisused(const ObjCMessageExpr *MessageExpr, - const ObjCObjectPointerType *TrackedType, - SymbolRef Sym, const ObjCMethodDecl *Method, - ArrayRef TypeArgs, - bool SubscriptOrProperty, CheckerContext &C) const; - public: void checkPreCall(const CallEvent &Call, CheckerContext &C) const; void checkPostCall(const CallEvent &Call, CheckerContext &C) const; @@ -684,46 +676,6 @@ return ResultType; } -/// Validate that the return type of a message expression is used correctly. -/// Returns true in case an error is detected. -bool DynamicTypePropagation::isReturnValueMisused( - const ObjCMessageExpr *MessageExpr, - const ObjCObjectPointerType *ResultPtrType, SymbolRef Sym, - const ObjCMethodDecl *Method, ArrayRef TypeArgs, - bool SubscriptOrProperty, CheckerContext &C) const { - if (!ResultPtrType) - return false; - - ASTContext &ASTCtxt = C.getASTContext(); - const Stmt *Parent = - C.getCurrentAnalysisDeclContext()->getParentMap().getParent(MessageExpr); - if (SubscriptOrProperty) { - // Properties and subscripts are not direct parents. - Parent = - C.getCurrentAnalysisDeclContext()->getParentMap().getParent(Parent); - } - - const auto *ImplicitCast = dyn_cast_or_null(Parent); - if (!ImplicitCast || ImplicitCast->getCastKind() != CK_BitCast) - return false; - - const auto *ExprTypeAboveCast = - ImplicitCast->getType()->getAs(); - if (!ExprTypeAboveCast) - return false; - - // Only warn on unrelated types to avoid too many false positives on - // downcasts. - if (!ASTCtxt.canAssignObjCInterfaces(ExprTypeAboveCast, ResultPtrType) && - !ASTCtxt.canAssignObjCInterfaces(ResultPtrType, ExprTypeAboveCast)) { - static CheckerProgramPointTag Tag(this, "ReturnTypeMismatch"); - ExplodedNode *N = C.addTransition(C.getState(), &Tag); - reportGenericsBug(ResultPtrType, ExprTypeAboveCast, N, Sym, C); - return true; - } - return false; -} - /// When the receiver has a tracked type, use that type to validate the /// argumments of the message expression and the return value. void DynamicTypePropagation::checkPreObjCMessage(const ObjCMethodCall &M, @@ -881,10 +833,6 @@ const auto *ResultPtrType = ResultType->getAs(); - if (isReturnValueMisused(MessageExpr, ResultPtrType, RecSym, Method, - *TypeArgs, M.getMessageKind() != OCM_Message, C)) - return; - if (!ResultPtrType || ResultPtrType->isUnspecialized()) return; Index: cfe/trunk/test/Analysis/dynamic_type_check.m =================================================================== --- cfe/trunk/test/Analysis/dynamic_type_check.m +++ cfe/trunk/test/Analysis/dynamic_type_check.m @@ -0,0 +1,33 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core.DynamicTypeChecker -verify %s + + +#define nil 0 +typedef unsigned long NSUInteger; +typedef int BOOL; + +@protocol NSObject ++ (id)alloc; +- (id)init; +@end + +@protocol NSCopying +@end + +__attribute__((objc_root_class)) +@interface NSObject +@end + +@interface NSString : NSObject +@end + +@interface NSMutableString : NSString +@end + +@interface NSNumber : NSObject +@end + +void testTypeCheck(NSString* str) { + id obj = str; + NSNumber *num = obj; // expected-warning {{}} + (void)num; +} Index: cfe/trunk/test/Analysis/generics.m =================================================================== --- cfe/trunk/test/Analysis/generics.m +++ cfe/trunk/test/Analysis/generics.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.osx.cocoa.ObjCGenerics -verify -Wno-objc-method-access %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.osx.cocoa.ObjCGenerics -verify -Wno-objc-method-access %s -analyzer-output=plist -o %t.plist +// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.osx.cocoa.ObjCGenerics,alpha.core.DynamicTypeChecker -verify -Wno-objc-method-access %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.osx.cocoa.ObjCGenerics,alpha.core.DynamicTypeChecker -verify -Wno-objc-method-access %s -analyzer-output=plist -o %t.plist // RUN: FileCheck --input-file %t.plist %s #if !__has_feature(objc_generics) @@ -236,13 +236,13 @@ void workWithProperties(NSArray *a) { NSArray *b = a; - NSString *str = [b getObjAtIndex: 0]; // expected-warning {{Conversion}} + NSString *str = [b getObjAtIndex: 0]; // expected-warning {{Object has a dynamic type 'NSNumber *' which is incompatible with static type 'NSString *'}} NSNumber *num = [b getObjAtIndex: 0]; - str = [b firstObject]; // expected-warning {{Conversion}} + str = [b firstObject]; // expected-warning {{Object has a dynamic type 'NSNumber *' which is incompatible with static type 'NSString *'}} num = [b firstObject]; - str = b.firstObject; // expected-warning {{Conversion}} + str = b.firstObject; // expected-warning {{Object has a dynamic type 'NSNumber *' which is incompatible with static type 'NSString *'}} num = b.firstObject; - str = b[0]; // expected-warning {{Conversion}} + str = b[0]; // expected-warning {{Object has a dynamic type 'NSNumber *' which is incompatible with static type 'NSString *'}} num = b[0]; } @@ -318,15 +318,14 @@ void returnToUnrelatedType(NSArray *> *arr) { NSArray *erased = arr; - NSSet* a = [erased firstObject]; // expected-warning {{Conversion}} + NSSet* a = [erased firstObject]; // expected-warning {{Object has a dynamic type 'NSArray *' which is incompatible with static type 'NSSet *'}} (void)a; } void returnToIdVariable(NSArray *arr) { NSArray *erased = arr; id a = [erased firstObject]; - // TODO: Warn in this case. Possibly in a separate checker. - NSNumber *res = a; + NSNumber *res = a; // expected-warning {{Object has a dynamic type 'NSString *' which is incompatible with static type 'NSNumber *'}} } // CHECK: @@ -4428,35 +4427,6 @@ // CHECK: path // CHECK: // CHECK: -// CHECK: kindevent -// CHECK: location -// CHECK: -// CHECK: line238 -// CHECK: col16 -// CHECK: file0 -// CHECK: -// CHECK: ranges -// CHECK: -// CHECK: -// CHECK: -// CHECK: line238 -// CHECK: col16 -// CHECK: file0 -// CHECK: -// CHECK: -// CHECK: line238 -// CHECK: col16 -// CHECK: file0 -// CHECK: -// CHECK: -// CHECK: -// CHECK: depth0 -// CHECK: extended_message -// CHECK: Type 'NSArray<NSNumber *> *' is inferred from implicit cast (from 'NSArray<NSNumber *> *' to 'NSArray *') -// CHECK: message -// CHECK: Type 'NSArray<NSNumber *> *' is inferred from implicit cast (from 'NSArray<NSNumber *> *' to 'NSArray *') -// CHECK: -// CHECK: // CHECK: kindcontrol // CHECK: edges // CHECK: @@ -4549,57 +4519,57 @@ // CHECK: // CHECK: depth0 // CHECK: extended_message -// CHECK: Conversion from value of type 'NSNumber *' to incompatible type 'NSString *' +// CHECK: Type 'NSNumber *' is inferred from this context // CHECK: message -// CHECK: Conversion from value of type 'NSNumber *' to incompatible type 'NSString *' +// CHECK: Type 'NSNumber *' is inferred from this context // CHECK: -// CHECK: -// CHECK: descriptionConversion from value of type 'NSNumber *' to incompatible type 'NSString *' -// CHECK: categoryCore Foundation/Objective-C -// CHECK: typeGenerics -// CHECK: check_namecore.DynamicTypePropagation -// CHECK: issue_context_kindfunction -// CHECK: issue_contextworkWithProperties -// CHECK: issue_hash2 -// CHECK: location -// CHECK: -// CHECK: line239 -// CHECK: col19 -// CHECK: file0 -// CHECK: -// CHECK: -// CHECK: -// CHECK: path -// CHECK: // CHECK: // CHECK: kindevent // CHECK: location // CHECK: -// CHECK: line238 -// CHECK: col16 +// CHECK: line239 +// CHECK: col19 // CHECK: file0 // CHECK: // CHECK: ranges // CHECK: // CHECK: // CHECK: -// CHECK: line238 -// CHECK: col16 +// CHECK: line239 +// CHECK: col19 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line238 -// CHECK: col16 +// CHECK: line239 +// CHECK: col38 // CHECK: file0 // CHECK: // CHECK: // CHECK: // CHECK: depth0 // CHECK: extended_message -// CHECK: Type 'NSArray<NSNumber *> *' is inferred from implicit cast (from 'NSArray<NSNumber *> *' to 'NSArray *') +// CHECK: Object has a dynamic type 'NSNumber *' which is incompatible with static type 'NSString *' // CHECK: message -// CHECK: Type 'NSArray<NSNumber *> *' is inferred from implicit cast (from 'NSArray<NSNumber *> *' to 'NSArray *') +// CHECK: Object has a dynamic type 'NSNumber *' which is incompatible with static type 'NSString *' // CHECK: +// CHECK: +// CHECK: descriptionObject has a dynamic type 'NSNumber *' which is incompatible with static type 'NSString *' +// CHECK: categoryType Error +// CHECK: typeDynamic and static type mismatch +// CHECK: check_namealpha.core.DynamicTypeChecker +// CHECK: issue_context_kindfunction +// CHECK: issue_contextworkWithProperties +// CHECK: issue_hash2 +// CHECK: location +// CHECK: +// CHECK: line239 +// CHECK: col19 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: // CHECK: // CHECK: kindcontrol // CHECK: edges @@ -4693,57 +4663,57 @@ // CHECK: // CHECK: depth0 // CHECK: extended_message -// CHECK: Conversion from value of type 'NSNumber *' to incompatible type 'NSString *' +// CHECK: Type 'NSNumber *' is inferred from this context // CHECK: message -// CHECK: Conversion from value of type 'NSNumber *' to incompatible type 'NSString *' +// CHECK: Type 'NSNumber *' is inferred from this context // CHECK: -// CHECK: -// CHECK: descriptionConversion from value of type 'NSNumber *' to incompatible type 'NSString *' -// CHECK: categoryCore Foundation/Objective-C -// CHECK: typeGenerics -// CHECK: check_namecore.DynamicTypePropagation -// CHECK: issue_context_kindfunction -// CHECK: issue_contextworkWithProperties -// CHECK: issue_hash4 -// CHECK: location -// CHECK: -// CHECK: line241 -// CHECK: col9 -// CHECK: file0 -// CHECK: -// CHECK: -// CHECK: -// CHECK: path -// CHECK: // CHECK: // CHECK: kindevent // CHECK: location // CHECK: -// CHECK: line238 -// CHECK: col16 +// CHECK: line241 +// CHECK: col9 // CHECK: file0 // CHECK: // CHECK: ranges // CHECK: // CHECK: // CHECK: -// CHECK: line238 -// CHECK: col16 +// CHECK: line241 +// CHECK: col9 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line238 -// CHECK: col16 +// CHECK: line241 +// CHECK: col23 // CHECK: file0 // CHECK: // CHECK: // CHECK: // CHECK: depth0 // CHECK: extended_message -// CHECK: Type 'NSArray<NSNumber *> *' is inferred from implicit cast (from 'NSArray<NSNumber *> *' to 'NSArray *') +// CHECK: Object has a dynamic type 'NSNumber *' which is incompatible with static type 'NSString *' // CHECK: message -// CHECK: Type 'NSArray<NSNumber *> *' is inferred from implicit cast (from 'NSArray<NSNumber *> *' to 'NSArray *') +// CHECK: Object has a dynamic type 'NSNumber *' which is incompatible with static type 'NSString *' // CHECK: +// CHECK: +// CHECK: descriptionObject has a dynamic type 'NSNumber *' which is incompatible with static type 'NSString *' +// CHECK: categoryType Error +// CHECK: typeDynamic and static type mismatch +// CHECK: check_namealpha.core.DynamicTypeChecker +// CHECK: issue_context_kindfunction +// CHECK: issue_contextworkWithProperties +// CHECK: issue_hash4 +// CHECK: location +// CHECK: +// CHECK: line241 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: // CHECK: // CHECK: kindcontrol // CHECK: edges @@ -4837,57 +4807,57 @@ // CHECK: // CHECK: depth0 // CHECK: extended_message -// CHECK: Conversion from value of type 'NSNumber *' to incompatible type 'NSString *' +// CHECK: Type 'NSNumber *' is inferred from this context // CHECK: message -// CHECK: Conversion from value of type 'NSNumber *' to incompatible type 'NSString *' +// CHECK: Type 'NSNumber *' is inferred from this context // CHECK: -// CHECK: -// CHECK: descriptionConversion from value of type 'NSNumber *' to incompatible type 'NSString *' -// CHECK: categoryCore Foundation/Objective-C -// CHECK: typeGenerics -// CHECK: check_namecore.DynamicTypePropagation -// CHECK: issue_context_kindfunction -// CHECK: issue_contextworkWithProperties -// CHECK: issue_hash6 -// CHECK: location -// CHECK: -// CHECK: line243 -// CHECK: col11 -// CHECK: file0 -// CHECK: -// CHECK: -// CHECK: -// CHECK: path -// CHECK: // CHECK: // CHECK: kindevent // CHECK: location // CHECK: -// CHECK: line238 -// CHECK: col16 +// CHECK: line243 +// CHECK: col9 // CHECK: file0 // CHECK: // CHECK: ranges // CHECK: // CHECK: // CHECK: -// CHECK: line238 -// CHECK: col16 +// CHECK: line243 +// CHECK: col9 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line238 -// CHECK: col16 +// CHECK: line243 +// CHECK: col21 // CHECK: file0 // CHECK: // CHECK: // CHECK: // CHECK: depth0 // CHECK: extended_message -// CHECK: Type 'NSArray<NSNumber *> *' is inferred from implicit cast (from 'NSArray<NSNumber *> *' to 'NSArray *') +// CHECK: Object has a dynamic type 'NSNumber *' which is incompatible with static type 'NSString *' // CHECK: message -// CHECK: Type 'NSArray<NSNumber *> *' is inferred from implicit cast (from 'NSArray<NSNumber *> *' to 'NSArray *') +// CHECK: Object has a dynamic type 'NSNumber *' which is incompatible with static type 'NSString *' // CHECK: +// CHECK: +// CHECK: descriptionObject has a dynamic type 'NSNumber *' which is incompatible with static type 'NSString *' +// CHECK: categoryType Error +// CHECK: typeDynamic and static type mismatch +// CHECK: check_namealpha.core.DynamicTypeChecker +// CHECK: issue_context_kindfunction +// CHECK: issue_contextworkWithProperties +// CHECK: issue_hash6 +// CHECK: location +// CHECK: +// CHECK: line243 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: // CHECK: // CHECK: kindcontrol // CHECK: edges @@ -4981,15 +4951,44 @@ // CHECK: // CHECK: depth0 // CHECK: extended_message -// CHECK: Conversion from value of type 'NSNumber *' to incompatible type 'NSString *' +// CHECK: Type 'NSNumber *' is inferred from this context // CHECK: message -// CHECK: Conversion from value of type 'NSNumber *' to incompatible type 'NSString *' +// CHECK: Type 'NSNumber *' is inferred from this context +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line245 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line245 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line245 +// CHECK: col12 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Object has a dynamic type 'NSNumber *' which is incompatible with static type 'NSString *' +// CHECK: message +// CHECK: Object has a dynamic type 'NSNumber *' which is incompatible with static type 'NSString *' // CHECK: // CHECK: -// CHECK: descriptionConversion from value of type 'NSNumber *' to incompatible type 'NSString *' -// CHECK: categoryCore Foundation/Objective-C -// CHECK: typeGenerics -// CHECK: check_namecore.DynamicTypePropagation +// CHECK: descriptionObject has a dynamic type 'NSNumber *' which is incompatible with static type 'NSString *' +// CHECK: categoryType Error +// CHECK: typeDynamic and static type mismatch +// CHECK: check_namealpha.core.DynamicTypeChecker // CHECK: issue_context_kindfunction // CHECK: issue_contextworkWithProperties // CHECK: issue_hash8 @@ -5436,35 +5435,6 @@ // CHECK: path // CHECK: // CHECK: -// CHECK: kindevent -// CHECK: location -// CHECK: -// CHECK: line289 -// CHECK: col13 -// CHECK: file0 -// CHECK: -// CHECK: ranges -// CHECK: -// CHECK: -// CHECK: -// CHECK: line289 -// CHECK: col13 -// CHECK: file0 -// CHECK: -// CHECK: -// CHECK: line289 -// CHECK: col39 -// CHECK: file0 -// CHECK: -// CHECK: -// CHECK: -// CHECK: depth0 -// CHECK: extended_message -// CHECK: Type 'NSArray<NSString *> *' is inferred from this context -// CHECK: message -// CHECK: Type 'NSArray<NSString *> *' is inferred from this context -// CHECK: -// CHECK: // CHECK: kindcontrol // CHECK: edges // CHECK: @@ -5557,46 +5527,28 @@ // CHECK: // CHECK: depth0 // CHECK: extended_message -// CHECK: Conversion from value of type 'NSArray<NSString *> *' to incompatible type 'NSArray<NSNumber *> *' +// CHECK: Type 'NSArray<NSString *> *' is inferred from this context // CHECK: message -// CHECK: Conversion from value of type 'NSArray<NSString *> *' to incompatible type 'NSArray<NSNumber *> *' +// CHECK: Type 'NSArray<NSString *> *' is inferred from this context // CHECK: -// CHECK: -// CHECK: descriptionConversion from value of type 'NSArray<NSString *> *' to incompatible type 'NSArray<NSNumber *> *' -// CHECK: categoryCore Foundation/Objective-C -// CHECK: typeGenerics -// CHECK: check_namecore.DynamicTypePropagation -// CHECK: issue_context_kindfunction -// CHECK: issue_contexttrackedClassVariables -// CHECK: issue_hash2 -// CHECK: location -// CHECK: -// CHECK: line290 -// CHECK: col28 -// CHECK: file0 -// CHECK: -// CHECK: -// CHECK: -// CHECK: path -// CHECK: // CHECK: // CHECK: kindevent // CHECK: location // CHECK: -// CHECK: line289 -// CHECK: col13 +// CHECK: line290 +// CHECK: col28 // CHECK: file0 // CHECK: // CHECK: ranges // CHECK: // CHECK: // CHECK: -// CHECK: line289 -// CHECK: col13 +// CHECK: line290 +// CHECK: col28 // CHECK: file0 // CHECK: // CHECK: -// CHECK: line289 +// CHECK: line290 // CHECK: col39 // CHECK: file0 // CHECK: @@ -5604,10 +5556,28 @@ // CHECK: // CHECK: depth0 // CHECK: extended_message -// CHECK: Type 'NSArray<NSString *> *' is inferred from this context +// CHECK: Conversion from value of type 'NSArray<NSString *> *' to incompatible type 'NSArray<NSNumber *> *' // CHECK: message -// CHECK: Type 'NSArray<NSString *> *' is inferred from this context +// CHECK: Conversion from value of type 'NSArray<NSString *> *' to incompatible type 'NSArray<NSNumber *> *' // CHECK: +// CHECK: +// CHECK: descriptionConversion from value of type 'NSArray<NSString *> *' to incompatible type 'NSArray<NSNumber *> *' +// CHECK: categoryCore Foundation/Objective-C +// CHECK: typeGenerics +// CHECK: check_namecore.DynamicTypePropagation +// CHECK: issue_context_kindfunction +// CHECK: issue_contexttrackedClassVariables +// CHECK: issue_hash2 +// CHECK: location +// CHECK: +// CHECK: line290 +// CHECK: col28 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: path +// CHECK: // CHECK: // CHECK: kindcontrol // CHECK: edges @@ -5701,6 +5671,35 @@ // CHECK: // CHECK: depth0 // CHECK: extended_message +// CHECK: Type 'NSArray<NSString *> *' is inferred from this context +// CHECK: message +// CHECK: Type 'NSArray<NSString *> *' is inferred from this context +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line291 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line291 +// CHECK: col7 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line291 +// CHECK: col19 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message // CHECK: Conversion from value of type 'NSArray<NSString *> *' to incompatible type 'NSArray<NSNumber *> *' // CHECK: message // CHECK: Conversion from value of type 'NSArray<NSString *> *' to incompatible type 'NSArray<NSNumber *> *' @@ -6224,35 +6223,6 @@ // CHECK: path // CHECK: // CHECK: -// CHECK: kindevent -// CHECK: location -// CHECK: -// CHECK: line320 -// CHECK: col21 -// CHECK: file0 -// CHECK: -// CHECK: ranges -// CHECK: -// CHECK: -// CHECK: -// CHECK: line320 -// CHECK: col21 -// CHECK: file0 -// CHECK: -// CHECK: -// CHECK: line320 -// CHECK: col23 -// CHECK: file0 -// CHECK: -// CHECK: -// CHECK: -// CHECK: depth0 -// CHECK: extended_message -// CHECK: Type 'NSArray<NSArray<NSString *> *> *' is inferred from implicit cast (from 'NSArray<NSArray<NSString *> *> *' to 'NSArray *') -// CHECK: message -// CHECK: Type 'NSArray<NSArray<NSString *> *> *' is inferred from implicit cast (from 'NSArray<NSArray<NSString *> *> *' to 'NSArray *') -// CHECK: -// CHECK: // CHECK: kindcontrol // CHECK: edges // CHECK: @@ -6345,15 +6315,44 @@ // CHECK: // CHECK: depth0 // CHECK: extended_message -// CHECK: Conversion from value of type 'NSArray<NSString *> *' to incompatible type 'NSSet *' +// CHECK: Type 'NSArray<NSString *> *' is inferred from this context +// CHECK: message +// CHECK: Type 'NSArray<NSString *> *' is inferred from this context +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line321 +// CHECK: col14 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line321 +// CHECK: col14 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line321 +// CHECK: col33 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Object has a dynamic type 'NSArray<NSString *> *' which is incompatible with static type 'NSSet *' // CHECK: message -// CHECK: Conversion from value of type 'NSArray<NSString *> *' to incompatible type 'NSSet *' +// CHECK: Object has a dynamic type 'NSArray<NSString *> *' which is incompatible with static type 'NSSet *' // CHECK: // CHECK: -// CHECK: descriptionConversion from value of type 'NSArray<NSString *> *' to incompatible type 'NSSet *' -// CHECK: categoryCore Foundation/Objective-C -// CHECK: typeGenerics -// CHECK: check_namecore.DynamicTypePropagation +// CHECK: descriptionObject has a dynamic type 'NSArray<NSString *> *' which is incompatible with static type 'NSSet *' +// CHECK: categoryType Error +// CHECK: typeDynamic and static type mismatch +// CHECK: check_namealpha.core.DynamicTypeChecker // CHECK: issue_context_kindfunction // CHECK: issue_contextreturnToUnrelatedType // CHECK: issue_hash2 @@ -6364,4 +6363,182 @@ // CHECK: file0 // CHECK: // CHECK: +// CHECK: +// CHECK: path +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line326 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line326 +// CHECK: col9 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line327 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line327 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line327 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line327 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line327 +// CHECK: col29 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Type 'NSString *' is inferred from this context +// CHECK: message +// CHECK: Type 'NSString *' is inferred from this context +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line327 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line327 +// CHECK: col4 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line328 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line328 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindcontrol +// CHECK: edges +// CHECK: +// CHECK: +// CHECK: start +// CHECK: +// CHECK: +// CHECK: line328 +// CHECK: col3 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line328 +// CHECK: col10 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: end +// CHECK: +// CHECK: +// CHECK: line328 +// CHECK: col19 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line328 +// CHECK: col19 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: +// CHECK: kindevent +// CHECK: location +// CHECK: +// CHECK: line328 +// CHECK: col19 +// CHECK: file0 +// CHECK: +// CHECK: ranges +// CHECK: +// CHECK: +// CHECK: +// CHECK: line328 +// CHECK: col19 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: line328 +// CHECK: col19 +// CHECK: file0 +// CHECK: +// CHECK: +// CHECK: +// CHECK: depth0 +// CHECK: extended_message +// CHECK: Object has a dynamic type 'NSString *' which is incompatible with static type 'NSNumber *' +// CHECK: message +// CHECK: Object has a dynamic type 'NSString *' which is incompatible with static type 'NSNumber *' +// CHECK: +// CHECK: +// CHECK: descriptionObject has a dynamic type 'NSString *' which is incompatible with static type 'NSNumber *' +// CHECK: categoryType Error +// CHECK: typeDynamic and static type mismatch +// CHECK: check_namealpha.core.DynamicTypeChecker +// CHECK: issue_context_kindfunction +// CHECK: issue_contextreturnToIdVariable +// CHECK: issue_hash3 +// CHECK: location +// CHECK: +// CHECK: line328 +// CHECK: col19 +// CHECK: file0 +// CHECK: +// CHECK: // CHECK: