[PATCH] D135099: [C2x] Implement support for nullptr and nullptr_t

Erich Keane via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 3 13:41:18 PDT 2022


erichkeane added inline comments.


================
Comment at: clang/include/clang/AST/PrettyPrinter.h:68
         SuppressDefaultTemplateArgs(true), Bool(LO.Bool),
-        Nullptr(LO.CPlusPlus11), Restrict(LO.C99), Alignof(LO.CPlusPlus11),
+        Nullptr(LO.CPlusPlus11), NullptrTypeInNamespace(LO.CPlusPlus),
+        Restrict(LO.C99), Alignof(LO.CPlusPlus11),
----------------
Does Nullptr here not have to change?  Shouldn't we care to use the "nullptr" in C mode instead of '0' now?


================
Comment at: clang/include/clang/AST/PrettyPrinter.h:201
+  /// Whether 'nullptr_t' is in namespace 'std' or not.
+  unsigned NullptrTypeInNamespace;
+
----------------
Is there a reason this isn't a bitfield as well?


================
Comment at: clang/include/clang/Basic/TokenKinds.def:393
 CXX11_KEYWORD(noexcept              , 0)
-CXX11_KEYWORD(nullptr               , 0)
+CXX11_KEYWORD(nullptr               , KEYC2X)
 CXX11_KEYWORD(static_assert         , KEYMSCOMPAT|KEYC2X)
----------------
Its a shame we have to do this... the CXX11_KEYWORD (and presumably the reverse) is used for 'future' diagnostics IIRC.  So not having this as a C2X_KEYWORD means we lose the 'future keyword' diagnostics, right?


================
Comment at: clang/lib/Sema/SemaExpr.cpp:8730
+  //   result also has that type.
+  if (LHSTy->isNullPtrType() && Context.hasSameType(LHSTy, RHSTy))
+    return ResTy;
----------------
what does this do with the GNU ternary-thing?  


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135099/new/

https://reviews.llvm.org/D135099



More information about the cfe-commits mailing list