[PATCH] D154290: [WIP][Clang] Implement P2741R3 - user-generated static_assert messages

Timm Bäder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 7 08:43:54 PDT 2023


tbaeder added inline comments.


================
Comment at: clang/lib/Sema/SemaDeclCXX.cpp:16893
+
+  if (const StringLiteral *SL = dyn_cast<StringLiteral>(Message);
+      SL && SL->getCharByteWidth() == 1) {
----------------



================
Comment at: clang/lib/Sema/SemaDeclCXX.cpp:16898
+  }
+
+  QualType T = Message->getType().getNonReferenceType();
----------------
What if the message is ` StringLiteral` but `getCharByteWidth()` doesn't return `1`? We would get the `err_static_assert_invalid_message` because` !RD` is true, right?


================
Comment at: clang/lib/Sema/SemaDeclCXX.cpp:16900
+  QualType T = Message->getType().getNonReferenceType();
+  auto *RD = T->getAsCXXRecordDecl();
+  if (!RD) {
----------------



================
Comment at: clang/lib/Sema/SemaDeclCXX.cpp:16912
+      return std::nullopt;
+    for (NamedDecl *D : MemberLookup) {
+      if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D->getUnderlyingDecl());
----------------



================
Comment at: clang/lib/Sema/SemaDeclCXX.cpp:16913
+    for (NamedDecl *D : MemberLookup) {
+      if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D->getUnderlyingDecl());
+          FD && FD->getMinRequiredArguments() == 0 &&
----------------



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154290



More information about the cfe-commits mailing list