hanchenye-llvm-project/clang/lib
Jordan Rose 801916baf1 [analyzer] Suppress paths involving a reference whose rvalue is null.
Most map types have an operator[] that inserts a new element if the key
isn't found, then returns a reference to the value slot so that you can
assign into it. However, if the value type is a pointer, it will be
initialized to null. This is usually no problem.

However, if the user /knows/ the map contains a value for a particular key,
they may just use it immediately:

   // From ClangSACheckersEmitter.cpp
   recordGroupMap[group]->Checkers

In this case the analyzer reports a null dereference on the path where the
key is not in the map, even though the user knows that path is impossible
here. They could silence the warning by adding an assertion, but that means
splitting up the expression and introducing a local variable. (Note that
the analyzer has no way of knowing that recordGroupMap[group] will return
the same reference if called twice in a row!)

We already have logic that says a null dereference has a high chance of
being a false positive if the null came from an inlined function. This
patch simply extends that to references whose rvalues are null as well,
silencing several false positives in LLVM.

<rdar://problem/13239854>

llvm-svn: 176371
2013-03-01 19:45:10 +00:00
..
ARCMigrate [preprocessor] Use MacroDirective in the preprocessor callbacks to make available the 2013-02-24 00:05:14 +00:00
AST Better support for constructors with -cxx-abi microsoft, partly fixes PR12784 2013-02-27 13:46:31 +00:00
ASTMatchers First step towards adding a parent map to the ASTContext. 2013-02-28 13:21:39 +00:00
Analysis Remove the CFGElement "Invalid" state. 2013-02-23 00:29:34 +00:00
Basic Add one more sanity check in SourceManager::getFileIDLoaded(). 2013-03-01 03:43:33 +00:00
CodeGen Restore order to placate test. I had no real reason to switch them. 2013-03-01 01:38:54 +00:00
Driver Fix global overflow in types::lookupTypeForTypeSpecifier. 2013-02-28 07:53:32 +00:00
Edit Include llvm::Optional in clang/Basic/LLVM.h 2013-02-20 22:23:23 +00:00
Format Remove whitespace at end of file. 2013-03-01 18:11:39 +00:00
Frontend [preprocessor] Use MacroDirective in the preprocessor callbacks to make available the 2013-02-24 00:05:14 +00:00
FrontendTool use early returns to simplify and de-nest 2013-01-06 07:49:41 +00:00
Headers libstdc++'s <cstdalign> #includes <stdalign.h> and expects it to guard against 2013-02-21 02:17:58 +00:00
Lex [preprocessor] Use MacroDirective in the preprocessor callbacks to make available the 2013-02-24 00:05:14 +00:00
Parse [Sema] Semantic analysis for empty-declaration and attribute-declaration. 2013-02-22 17:15:32 +00:00
Rewrite Use trailing documentation comments properly 2013-02-16 22:21:38 +00:00
Sema Perform the receiver-expression transformations regardless of 2013-03-01 09:20:14 +00:00
Serialization [PCH] Remove building a SmallPtrSet that is not actually used for anything. 2013-03-01 17:01:31 +00:00
StaticAnalyzer [analyzer] Suppress paths involving a reference whose rvalue is null. 2013-03-01 19:45:10 +00:00
Tooling Nuke SetUpBuildDumpLog. 2013-01-20 01:58:28 +00:00
CMakeLists.txt Initial version of formatting library. 2012-12-03 18:12:45 +00:00
Makefile Dont use/link ARCMT, StaticAnalyzer and Rewriter to clang when the user 2012-12-13 16:09:42 +00:00