llvm-project/clang/lib
JF Bastien d39fbc7e20 Variable auto-init: don't initialize aggregate padding of all aggregates
Summary:
C guarantees that brace-init with fewer initializers than members in the
aggregate will initialize the rest of the aggregate as-if it were static
initialization. In turn static initialization guarantees that padding is
initialized to zero bits.

Quoth the Standard:

C17 6.7.9 Initialization ❡21

If there are fewer initializers in a brace-enclosed list than there are elements
or members of an aggregate, or fewer characters in a string literal used to
initialize an array of known size than there are elements in the array, the
remainder of the aggregate shall be initialized implicitly the same as objects
that have static storage duration.

C17 6.7.9 Initialization ❡10

If an object that has automatic storage duration is not initialized explicitly,
its value is indeterminate. If an object that has static or thread storage
duration is not initialized explicitly, then:

 * if it has pointer type, it is initialized to a null pointer;
 * if it has arithmetic type, it is initialized to (positive or unsigned) zero;
 * if it is an aggregate, every member is initialized (recursively) according to
   these rules, and any padding is initialized to zero bits;
 * if it is a union, the first named member is initialized (recursively)
   according to these rules, and any padding is initialized to zero bits;

<rdar://problem/50188861>

Reviewers: glider, pcc, kcc, rjmccall, erik.pilkington

Subscribers: jkorous, dexonsmith, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D61280

llvm-svn: 359628
2019-04-30 22:56:53 +00:00
..
ARCMigrate Range-style std::find{,_if} -> llvm::find{,_if}. NFC 2019-03-31 08:48:19 +00:00
AST [NFC] typo 2019-04-30 00:11:53 +00:00
ASTMatchers [ASTMatchers] Introduce Objective-C matchers `isClassMessage`, `isClassMethod`, and `isInstanceMethod` 2019-04-22 17:54:11 +00:00
Analysis [analyzer] Treat functions without run-time branches as "small". 2019-04-30 03:01:02 +00:00
Basic AMDGPU: Enable _Float16 2019-04-30 18:35:37 +00:00
CodeGen Variable auto-init: don't initialize aggregate padding of all aggregates 2019-04-30 22:56:53 +00:00
CrossTU [analyzer][CrossTU] Extend CTU to VarDecls with initializer 2019-04-23 11:04:41 +00:00
Driver [Driver] Support compiler-rt crtbegin.o/crtend.o for Linux 2019-04-30 19:35:14 +00:00
Edit Range-style std::find{,_if} -> llvm::find{,_if}. NFC 2019-03-31 08:48:19 +00:00
Format Use llvm::stable_sort 2019-04-24 14:43:05 +00:00
Frontend [analyzer][NFC] Reimplement checker options 2019-04-19 12:32:10 +00:00
FrontendTool [analyzer][NFC] Supply CheckerRegistry with AnalyzerOptions 2019-01-26 15:59:21 +00:00
Headers [AArch64] Add support for MTE intrinsics 2019-04-26 21:08:11 +00:00
Index Use llvm::stable_sort 2019-04-24 14:43:05 +00:00
Lex When skipping code at the start of a file during PCH use, Preprocessor::Lex 2019-04-29 21:21:17 +00:00
Parse [c++2a] Implement semantic restrictions for 'export' declarations. 2019-04-22 22:50:11 +00:00
Rewrite Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Sema [NFC] typo 2019-04-30 00:19:43 +00:00
Serialization [Serialization] Stable serialization order for OpenCLTypeExtMap and OpenCLDeclExtMap 2019-04-18 15:13:27 +00:00
StaticAnalyzer [analyzer][UninitializedObjectChecker] PR41611: Regard vector types as primitive 2019-04-30 08:47:56 +00:00
Tooling [LibTooling] Change Transformer's TextGenerator to a partial function. 2019-04-30 16:48:33 +00:00
CMakeLists.txt