diff options
author | Erich Keane <erich.keane@intel.com> | 2018-12-14 22:22:29 +0000 |
---|---|---|
committer | Erich Keane <erich.keane@intel.com> | 2018-12-14 22:22:29 +0000 |
commit | 07325c80d9bc8060ac1e7dceabeecfcb141146bf (patch) | |
tree | c0a0f136dbf9f6b978c9e70e5501f5562f7259b3 /clang/test/Analysis/nullptr.cpp | |
parent | 574d737e06fb9efc53b196536b3bf2124219d7e0 (diff) | |
download | bcm5719-llvm-07325c80d9bc8060ac1e7dceabeecfcb141146bf.tar.gz bcm5719-llvm-07325c80d9bc8060ac1e7dceabeecfcb141146bf.zip |
Add extension to always default-initialize nullptr_t.
Core issue 1013 suggests that having an uninitialied std::nullptr_t be
UB is a bit foolish, since there is only a single valid value. This DR
reports that DR616 fixes it, which does so by making lvalue-to-rvalue
conversions from nullptr_t be equal to nullptr.
However, just implementing that results in warnings/etc in many places.
In order to fix all situations where nullptr_t would seem uninitialized,
this patch instead (as an otherwise transparent extension) default
initializes uninitialized VarDecls of nullptr_t.
Differential Revision: https://reviews.llvm.org/D53713
Change-Id: I84d72a9290054fa55341e8cbdac43c8e7f25b885
llvm-svn: 349201
Diffstat (limited to 'clang/test/Analysis/nullptr.cpp')
-rw-r--r-- | clang/test/Analysis/nullptr.cpp | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/clang/test/Analysis/nullptr.cpp b/clang/test/Analysis/nullptr.cpp index 38e099b7fbd..1d913c11d3c 100644 --- a/clang/test/Analysis/nullptr.cpp +++ b/clang/test/Analysis/nullptr.cpp @@ -125,21 +125,16 @@ struct Type { }; void shouldNotCrash() { - decltype(nullptr) p; // expected-note{{'p' declared without an initial value}} - if (getSymbol()) // expected-note {{Assuming the condition is false}} - // expected-note@-1{{Taking false branch}} - // expected-note@-2{{Assuming the condition is false}} - // expected-note@-3{{Taking false branch}} - // expected-note@-4{{Assuming the condition is true}} - // expected-note@-5{{Taking true branch}} - invokeF(p); // expected-warning{{1st function call argument is an uninitialized value}} - // expected-note@-1{{1st function call argument is an uninitialized value}} + decltype(nullptr) p; // expected-note{{'p' initialized to a null pointer value}} if (getSymbol()) // expected-note {{Assuming the condition is false}} // expected-note@-1{{Taking false branch}} // expected-note@-2{{Assuming the condition is true}} // expected-note@-3{{Taking true branch}} - invokeF(nullptr); // expected-note {{Calling 'invokeF'}} - // expected-note@-1{{Passing null pointer value via 1st parameter 'x'}} + invokeF(p); // expected-note{{Passing null pointer value via 1st parameter 'x'}} + // expected-note@-1{{Calling 'invokeF'}} + if (getSymbol()) // expected-note {{Assuming the condition is false}} + // expected-note@-1{{Taking false branch}} + invokeF(nullptr); if (getSymbol()) { // expected-note {{Assuming the condition is true}} // expected-note@-1{{Taking true branch}} X *xx = Type().x; // expected-note {{Null pointer value stored to field 'x'}} |