[PATCH] D54903: [Sema] Improve static_assert diagnostics.

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 27 13:48:28 PST 2018


aaron.ballman added inline comments.


================
Comment at: lib/Sema/SemaTemplate.cpp:3070
+// and returns true.
+static bool prettyPrintTypeTrait(const NestedNameSpecifier *const NNS,
+                                 llvm::raw_string_ostream &OS,
----------------
No need for the pointer itself to be `const` qualified -- drop the top-level `const` qualifier (here and elsewhere).


================
Comment at: lib/Sema/SemaTemplate.cpp:3073-3085
+  // We are looking for a type.
+  if (NNS == nullptr || NNS->getKind() != NestedNameSpecifier::TypeSpec)
+    return false;
+  // In namespace "::std".
+  const NestedNameSpecifier *const Parent = NNS->getPrefix();
+  if (Parent == nullptr ||
+      Parent->getKind() != NestedNameSpecifier::Namespace ||
----------------
I would drop all of this logic and replace it (see below).


================
Comment at: lib/Sema/SemaTemplate.cpp:3096
+  OS << "std::" << Record->getName() << "<";
+  auto Args = TmplDecl->getTemplateArgs().asArray();
+  Args.front().print(PrintPolicy, OS);
----------------
Please don't use `auto` here.


================
Comment at: lib/Sema/SemaTemplate.cpp:3115
+    // This might be `std::some_type_trait<U,V>::value`.
+    if (Var && Var->isStaticDataMember() && Var->getName() == "value" &&
+        prettyPrintTypeTrait(DR->getQualifier(), OS, PrintPolicy)) {
----------------
You can also check `Var->isInStdNamespace()` here to simplify the logic above.


Repository:
  rC Clang

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

https://reviews.llvm.org/D54903





More information about the cfe-commits mailing list