llvm-project/clang/lib
Artem Dergachev 9d3ca9a5ae [analyzer] Fix zero-initialization of stack VLAs under ObjC ARC.
Using ARC, strong, weak, and autoreleasing stack variables are implicitly
initialized with nil. This includes variable-length arrays of Objective-C object
pointers. However, in the analyzer we don't zero-initialize them. We used to,
but it accidentally regressed after r289618.

Under ARC, the array variable's initializer within DeclStmt is an
ImplicitValueInitExpr. Environment doesn't maintain any bindings for this
expression kind - instead it always knows that it's a known constant
(0 in our case), so it just returns the known value by calling
SValBuilder::makeZeroVal() (see EnvironmentManager::getSVal().
Commit r289618 had introduced reasonable behavior of SValBuilder::makeZeroVal()
for the arrays, which produces a zero-length compoundVal{}. When such value
is bound to arrays, in RegionStoreManager::bindArray() "remaining" items in the
array are default-initialized with zero, as in
RegionStoreManager::setImplicitDefaultValue(). The similar mechanism works when
an array is initialized by an initializer list that is too short, eg.
  int a[3] = { 1, 2 };
would result in a[2] initialized with 0. However, in case of variable-length
arrays it didn't know if any more items need to be added,
because, well, the length is variable.

Add the default binding anyway, regardless of how many actually need
to be added. We don't really care how many, because the default binding covers
the whole array anyway.

Differential Revision: https://reviews.llvm.org/D41478
rdar://problem/35477763

llvm-svn: 321290
2017-12-21 18:43:02 +00:00
..
ARCMigrate Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC. 2017-06-03 06:23:19 +00:00
AST Reverting r321223 and its follow-up commit because of failing bots due to Misc/ast-dump-color.cpp. 2017-12-20 23:17:29 +00:00
ASTMatchers Remove creation of out-of-bounds value of enumeration type (resulting in UB). 2017-12-08 23:29:59 +00:00
Analysis Refactor overridden methods iteration to avoid double lookups. 2017-12-17 23:52:45 +00:00
Basic Make DiagnosticIDs::getAllDiagnostics use std::vector. NFC. 2017-12-20 16:55:41 +00:00
CodeGen [CodeGen] Fix access sizes in new-format TBAA tags 2017-12-21 08:14:16 +00:00
CrossTU [CrossTU] Fix handling of Cross Translation Unit directory path 2017-10-27 12:53:37 +00:00
Driver [Driver] Ensure no overlap between trapping & recoverable sanitizers. NFC. 2017-12-21 00:10:24 +00:00
Edit [clang] Fix format specifiers fixits for nested macros 2017-06-20 20:46:58 +00:00
Format Revert "[ClangFormat] IndentWrappedFunctionNames should be true in the google ObjC style" 2017-12-14 21:44:11 +00:00
Frontend Added helper to get size of PrecompiledPreamble 2017-12-21 14:04:39 +00:00
FrontendTool [CMake] Use #cmakedefine01 for CLANG_ENABLE_(ARCMT|OBJC_REWRITER|STATIC_ANALYZER) 2017-10-18 05:21:17 +00:00
Headers [X86] Add more CPUID bits to cpuid.h to match gcc and support icelake features. 2017-12-20 00:46:09 +00:00
Index Refactor overridden methods iteration to avoid double lookups. 2017-12-17 23:52:45 +00:00
Lex Remove llvm::MemoryBuffer const_casts 2017-12-20 11:34:38 +00:00
Parse Fix more inconsistent line endings. NFC. 2017-12-18 19:46:56 +00:00
Rewrite [Analyzer] Add support for displaying cross-file diagnostic paths in HTML output 2017-08-03 18:12:22 +00:00
Sema Add support for ObjectFormat to TargetSpecificAttr 2017-12-20 18:51:08 +00:00
Serialization Refactor overridden methods iteration to avoid double lookups. 2017-12-17 23:52:45 +00:00
StaticAnalyzer [analyzer] Fix zero-initialization of stack VLAs under ObjC ARC. 2017-12-21 18:43:02 +00:00
Tooling [Tooling] Acknowledge that many CompilationDatabases don't support enumeration. 2017-11-24 12:13:55 +00:00
CMakeLists.txt Add Cross Translation Unit support library 2017-09-22 11:11:01 +00:00