llvm-project/clang/lib/StaticAnalyzer/Checkers
Devin Coughlin ab139a9e79 [analyzer] ObjCGenerics: Warn only on mismatch for invariant type parameters
On a method call, the ObjCGenerics checker uses the type tracked by
DynamicTypePropagation for the receiver to to infer substituted parmeter types
for the called methods and warns when the argument type does not match the
parameter.

Unfortunately, using the tracked type can result in false positives when the
receiver has a non-invariant type parameter and has been intentionally upcast.
For example, becaue NSArray's type parameter is covaraint, the following code
is perfectly safe:

NSArray<NSString *> *allStrings = ...
NSDate *date = ...;
NSArray<NSObject *> *allObjects = allStrings;
NSArray<NSObject *> *moreObjects = [allObjects arrayByAddingObject:date];

but the checker currently warns that the date parameter is not an NSString *.

To avoid this kind of false positive, the checker will now only warn when
the class defining the called method has only invariant type parameters.

rdar://problem/28803951

llvm-svn: 288677
2016-12-05 16:28:47 +00:00
..
MPI-Checker Revert test commit 2016-08-12 17:46:23 +00:00
AllocationDiagnostics.cpp
AllocationDiagnostics.h
AnalysisOrderChecker.cpp [analyzer] Add PostStmt callback for ArraySubscriptExpr 2016-10-04 20:49:31 +00:00
AnalyzerStatsChecker.cpp Avoid overly large SmallPtrSet/SmallSet 2016-01-30 01:27:06 +00:00
ArrayBoundChecker.cpp [analyzer] Add generateErrorNode() APIs to CheckerContext. 2015-09-16 22:03:05 +00:00
ArrayBoundCheckerV2.cpp [analyzer] Calculate extent size for memory regions allocated by new expression. 2016-09-19 20:39:52 +00:00
BasicObjCFoundationChecks.cpp [analyzer] Report CFNumberGetValue API misuse 2016-10-26 22:51:47 +00:00
BlockInCriticalSectionChecker.cpp [analyzer] Add a checker that detects blocks in critical sections 2016-09-20 20:28:50 +00:00
BoolAssignmentChecker.cpp [analyzer] Add generateErrorNode() APIs to CheckerContext. 2015-09-16 22:03:05 +00:00
BuiltinFunctionChecker.cpp Add support for __builtin_alloca_with_align 2016-10-31 05:37:48 +00:00
CMakeLists.txt [analyzer] Add StdLibraryFunctions checker. 2016-10-24 09:41:38 +00:00
CStringChecker.cpp [analyzer] Remove unused check::RegionChanges::wantsRegionChangeUpdate callback 2016-11-16 22:59:01 +00:00
CStringSyntaxChecker.cpp Rewrite users of Stmt::child_begin/end into for-range loops. 2015-07-03 15:12:24 +00:00
CXXSelfAssignmentChecker.cpp [analyzer] Add checker modeling potential C++ self-assignment 2016-07-21 23:42:31 +00:00
CallAndMessageChecker.cpp [analyzer] Add check for when block is called with too few arguments. 2016-11-15 18:40:46 +00:00
CastSizeChecker.cpp Refactor: Simplify boolean conditional return statements in lib/StaticAnalyzer/Checkers 2015-12-28 13:06:58 +00:00
CastToStructChecker.cpp [analyzer] Improve CastToStruct checker so it can also detect widening casts of struct data 2016-09-26 15:17:18 +00:00
CheckObjCDealloc.cpp Revert "[analyzer] Re-apply r283093 "Add extra notes to ObjCDeallocChecker"" 2016-10-16 00:30:08 +00:00
CheckObjCInstMethSignature.cpp
CheckSecuritySyntaxOnly.cpp Test commit 2015-11-26 22:08:58 +00:00
CheckSizeofPointer.cpp [analyzer] Apply whitespace cleanups by Honggyu Kim. 2015-09-08 03:50:52 +00:00
CheckerDocumentation.cpp [analyzer] Add check::BeginFunction to CheckerDocumentation checks. NFC. 2016-07-28 00:52:10 +00:00
ChrootChecker.cpp [NFC] Header cleanup 2016-07-18 19:02:11 +00:00
ClangCheckers.cpp [analyzer] Move Checkers.inc to clang/include/... 2016-04-28 01:09:09 +00:00
ClangSACheckers.h [analyzer] Move Checkers.inc to clang/include/... 2016-04-28 01:09:09 +00:00
CloneChecker.cpp [analyzer] Re-apply r283094 "Improve CloneChecker diagnostics" 2016-10-08 10:54:30 +00:00
ConversionChecker.cpp [analyzer] Add a checker for loss of sign or precision in integral casts. 2016-08-17 16:02:45 +00:00
DeadStoresChecker.cpp DeadStoresChecker: Don't warn about dead stores into volatile variables 2016-06-24 16:26:43 +00:00
DebugCheckers.cpp [analyzer] Fix IssueHash generation. 2015-12-01 09:00:41 +00:00
DereferenceChecker.cpp [analyzer] Improve Nullability checker diagnostics 2016-01-29 18:43:15 +00:00
DirectIvarAssignment.cpp Use instance_properties instead of properties. NFC. 2016-01-26 18:05:23 +00:00
DivZeroChecker.cpp [analyzer] Add generateErrorNode() APIs to CheckerContext. 2015-09-16 22:03:05 +00:00
DynamicTypeChecker.cpp [analyzer] Small cleanups when checkers retrieving statements from exploded 2016-08-18 07:54:50 +00:00
DynamicTypePropagation.cpp [analyzer] ObjCGenerics: Warn only on mismatch for invariant type parameters 2016-12-05 16:28:47 +00:00
ExprInspectionChecker.cpp [analyzer] Minor fixes and improvements to debug.ExprInspection 2016-11-30 17:57:18 +00:00
FixedAddressChecker.cpp [analyzer] Add generateErrorNode() APIs to CheckerContext. 2015-09-16 22:03:05 +00:00
GenericTaintChecker.cpp Refactor: Simplify boolean conditional return statements in lib/StaticAnalyzer/Checkers 2015-12-28 13:06:58 +00:00
IdenticalExprChecker.cpp Refactor: Simplify boolean conditional return statements in lib/StaticAnalyzer/Checkers 2015-12-28 13:06:58 +00:00
InterCheckerAPI.h Add a missing forward def of CheckerManager. NFC. 2015-04-17 17:00:16 +00:00
IvarInvalidationChecker.cpp Remove redundant conditions of the form (A || (!A && B)) -> (A || B) 2016-04-11 08:26:13 +00:00
LLVMConventionsChecker.cpp Remove and forbid raw_svector_ostream::flush() calls. 2015-08-13 18:12:56 +00:00
LocalizationChecker.cpp [analyzer] Use lazily created buffer in EmptyLocalizationContextChecker 2016-08-30 23:07:14 +00:00
MacOSKeychainAPIChecker.cpp [analyzer] Small cleanups when checkers retrieving statements from exploded 2016-08-18 07:54:50 +00:00
MacOSXAPIChecker.cpp [analyzer] MacOSXAPIChecker: Improve warnings for __block vars in dispatch_once. 2016-10-31 21:04:54 +00:00
MallocChecker.cpp Revert "Revert "[analyzer] Make MallocChecker more robust against custom redeclarations"" 2016-10-16 22:19:03 +00:00
MallocOverflowSecurityChecker.cpp [analyzer] Older version of GCC 4.7 crash on lambdas in default arguments. 2016-07-09 12:16:58 +00:00
MallocSizeofChecker.cpp [analyzer] Apply whitespace cleanups by Honggyu Kim. 2015-09-08 03:50:52 +00:00
NSAutoreleasePoolChecker.cpp [analyzer] Add generateErrorNode() APIs to CheckerContext. 2015-09-16 22:03:05 +00:00
NSErrorChecker.cpp Use more ArrayRefs 2016-06-24 04:05:48 +00:00
NoReturnFunctionChecker.cpp [analyzer] Handle another Android assert function. 2015-12-30 00:08:59 +00:00
NonNullParamChecker.cpp [analyzer] Add generateErrorNode() APIs to CheckerContext. 2015-09-16 22:03:05 +00:00
NullabilityChecker.cpp [analyzer] Fix crash in NullabilityChecker calling block with too few arguments 2016-11-14 22:46:02 +00:00
NumberObjectConversionChecker.cpp [analyzer] NumberObjectConversion: Workaround for a linker error with modules. 2016-11-15 22:22:57 +00:00
ObjCAtSyncChecker.cpp [analyzer] Add generateErrorNode() APIs to CheckerContext. 2015-09-16 22:03:05 +00:00
ObjCContainersASTChecker.cpp Refactor: Simplify boolean conditional return statements in lib/StaticAnalyzer/Checkers 2015-12-28 13:06:58 +00:00
ObjCContainersChecker.cpp Fix some Clang-tidy readability-redundant-control-flow warnings; other minor fixes. 2016-02-10 19:11:58 +00:00
ObjCMissingSuperCallChecker.cpp [analyzer] Apply whitespace cleanups by Honggyu Kim. 2015-09-08 03:50:52 +00:00
ObjCSelfInitChecker.cpp Refactor: Simplify boolean conditional return statements in lib/StaticAnalyzer/Checkers 2015-12-28 13:06:58 +00:00
ObjCSuperDeallocChecker.cpp [analyzer] Fix capitalization in ObjCSuperDealloc checker diagnostic. 2016-11-01 22:16:39 +00:00
ObjCUnusedIVarsChecker.cpp Rewrite users of Stmt::child_begin/end into for-range loops. 2015-07-03 15:12:24 +00:00
PaddingChecker.cpp StaticAnalyzer: Report found fields order in PaddingChecker 2016-08-15 20:16:13 +00:00
PointerArithChecker.cpp [NFC] Header cleanup 2016-07-18 19:02:11 +00:00
PointerSubChecker.cpp [analyzer] Add generateErrorNode() APIs to CheckerContext. 2015-09-16 22:03:05 +00:00
PthreadLockChecker.cpp [NFC] Header cleanup 2016-07-18 19:02:11 +00:00
RetainCountChecker.cpp [analyzer] Remove unused check::RegionChanges::wantsRegionChangeUpdate callback 2016-11-16 22:59:01 +00:00
ReturnPointerRangeChecker.cpp [analyzer] Add generateErrorNode() APIs to CheckerContext. 2015-09-16 22:03:05 +00:00
ReturnUndefChecker.cpp [analyzer] Add generateErrorNode() APIs to CheckerContext. 2015-09-16 22:03:05 +00:00
SelectorExtras.h Use the new LLVM_END_WITH_NULL name 2014-11-04 01:13:43 +00:00
SimpleStreamChecker.cpp Apply clang-tidy's misc-move-constructor-init throughout Clang. 2016-05-27 14:27:13 +00:00
StackAddrEscapeChecker.cpp [Analyzer] Correct stack address escape diagnostic 2016-05-26 14:02:17 +00:00
StdLibraryFunctionsChecker.cpp [analyzer] Rename assumeWithinInclusiveRange*() 2016-11-15 01:54:41 +00:00
StreamChecker.cpp [NFC] Header cleanup 2016-07-18 19:02:11 +00:00
TaintTesterChecker.cpp [analyzer] Add generateErrorNode() APIs to CheckerContext. 2015-09-16 22:03:05 +00:00
TestAfterDivZeroChecker.cpp [analyzer] Add generateErrorNode() APIs to CheckerContext. 2015-09-16 22:03:05 +00:00
TraversalChecker.cpp [analyzer] Add checker callback for beginning of function. 2016-02-19 01:35:10 +00:00
UndefBranchChecker.cpp Apply clang-tidy's misc-move-constructor-init throughout Clang. 2016-05-27 14:27:13 +00:00
UndefCapturedBlockVarChecker.cpp [analyzer] Add generateErrorNode() APIs to CheckerContext. 2015-09-16 22:03:05 +00:00
UndefResultChecker.cpp [analyzer] Add generateErrorNode() APIs to CheckerContext. 2015-09-16 22:03:05 +00:00
UndefinedArraySubscriptChecker.cpp [analyzer] Add generateErrorNode() APIs to CheckerContext. 2015-09-16 22:03:05 +00:00
UndefinedAssignmentChecker.cpp [analyzer] Add generateErrorNode() APIs to CheckerContext. 2015-09-16 22:03:05 +00:00
UnixAPIChecker.cpp Add support for __builtin_alloca_with_align 2016-10-31 05:37:48 +00:00
UnreachableCodeChecker.cpp alpha.core.UnreachableCode - don't warn about unreachable code inside macro 2016-10-18 13:16:53 +00:00
VLASizeChecker.cpp Fix some Clang-tidy readability-redundant-control-flow warnings; other minor fixes. 2016-02-10 19:11:58 +00:00
ValistChecker.cpp Reapply "[analyzer] Added valist related checkers." 2016-08-22 11:21:30 +00:00
VforkChecker.cpp Fix Clang-tidy modernize-use-nullptr warnings; other minor fixes. 2016-01-26 19:01:06 +00:00
VirtualCallChecker.cpp [analyzer] Apply whitespace cleanups by Honggyu Kim. 2015-09-08 03:50:52 +00:00