Commit 131e8786 authored by David Blaikie's avatar David Blaikie
Browse files

Print nullptr_t namespace qualified within std::

This improves diagnostic (& important to me, DWARF) accuracy - otherwise
there could be ambiguities between "std::nullptr_t" and some user-defined
type that's /actually/ "nullptr_t" defined in the global namespace.

Differential Revision: https://reviews.llvm.org/D110044
parent 1a332946
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3042,7 +3042,7 @@ StringRef BuiltinType::getName(const PrintingPolicy &Policy) const {
  case Char32:
    return "char32_t";
  case NullPtr:
    return "nullptr_t";
    return "std::nullptr_t";
  case Overload:
    return "<overloaded function type>";
  case BoundMember:
+1 −1
Original line number Diff line number Diff line
@@ -250,7 +250,7 @@ using Escape = decltype([] { return undef(); }());
// CHECK-NEXT: `-RecoveryExpr {{.*}} '<dependent type>' contains-errors lvalue
// CHECK-NEXT:   `-InitListExpr
// CHECK-NEXT:     `-DesignatedInitExpr {{.*}} 'void'
// CHECK-NEXT:       `-CXXNullPtrLiteralExpr {{.*}} 'nullptr_t'
// CHECK-NEXT:       `-CXXNullPtrLiteralExpr {{.*}} 'std::nullptr_t'
struct {
  int& abc;
} NoCrashOnInvalidInitList = {
+1 −1
Original line number Diff line number Diff line
@@ -38,5 +38,5 @@ int main() {

// CHECK:      <string>Calling constructor for &apos;DivByZero&lt;int, float, double, 0&gt;&apos;</string>
// CHECK:      <string>Calling constructor for &apos;DivByZero&lt;char, float, double, 0&gt;&apos;</string>
// CHECK:      <string>Calling constructor for &apos;DivByZeroVariadic&lt;char, float, double, nullptr_t&gt;&apos;</string>
// CHECK:      <string>Calling constructor for &apos;DivByZeroVariadic&lt;char, float, double, std::nullptr_t&gt;&apos;</string>
+2 −2
Original line number Diff line number Diff line
@@ -113,7 +113,7 @@ namespace dr1512 { // dr1512: 4
  }

#if __cplusplus >= 201103L
  template<typename T> struct Wrap { operator T(); }; // expected-note 4{{converted to type 'nullptr_t'}} expected-note 4{{converted to type 'int *'}}
  template<typename T> struct Wrap { operator T(); }; // expected-note 4{{converted to type 'std::nullptr_t'}} expected-note 4{{converted to type 'int *'}}
  void test_overload() {
    using nullptr_t = decltype(nullptr);
    void(Wrap<nullptr_t>() == Wrap<nullptr_t>());
@@ -127,7 +127,7 @@ namespace dr1512 { // dr1512: 4
    // but then only convert as far as 'nullptr_t', which we then can't convert to 'int*'.
    void(Wrap<nullptr_t>() == Wrap<int*>());
    void(Wrap<nullptr_t>() != Wrap<int*>());
    void(Wrap<nullptr_t>() < Wrap<int*>()); // expected-error {{invalid operands to binary expression ('Wrap<nullptr_t>' and 'Wrap<int *>')}}
    void(Wrap<nullptr_t>() < Wrap<int*>()); // expected-error {{invalid operands to binary expression ('Wrap<nullptr_t>' (aka 'Wrap<std::nullptr_t>') and 'Wrap<int *>')}}
    void(Wrap<nullptr_t>() > Wrap<int*>()); // expected-error {{invalid operands}}
    void(Wrap<nullptr_t>() <= Wrap<int*>()); // expected-error {{invalid operands}}
    void(Wrap<nullptr_t>() >= Wrap<int*>()); // expected-error {{invalid operands}}
+1 −1
Original line number Diff line number Diff line
@@ -590,7 +590,7 @@ namespace dr652 { // dr652: yes
namespace dr654 { // dr654: sup 1423
  void f() {
    if (nullptr) {} // expected-warning {{implicit conversion of nullptr constant to 'bool'}}
    bool b = nullptr; // expected-error {{cannot initialize a variable of type 'bool' with an rvalue of type 'nullptr_t'}}
    bool b = nullptr; // expected-error {{cannot initialize a variable of type 'bool' with an rvalue of type 'std::nullptr_t'}}
    if (nullptr == 0) {}
    if (nullptr != 0) {}
    if (nullptr <= 0) {} // expected-error {{invalid operands}}
Loading