alexfh requested changes to this revision.
alexfh added inline comments.
This revision now requires changes to proceed.


================
Comment at: clang-tidy/google/UsingNamespaceDirectiveCheck.cpp:43
+  if (StandardLiteralsNamespaceRE.match(
+          U->getNominatedNamespace()->getQualifiedNameAsString())) {
+    // Do not warn if name matches std::.*literals. User-defined literals in
----------------
`getQualifiedNameAsString()` is pretty expensive, since it allocates a string 
and reconstructs the qualified name by going up all declaration contexts. 
Instead, consider checking the names directly, something like this:

  const NamespaceDecl *NS = U->getNominatedNamespace();
  if (NS->getName().ends_with("literals")) {
    const auto *Parent = dyn_cast_or_null<NamespaceDecl>(NS->getParent());
    if (Parent && (Parent->isStdNamespace() || (Parent->getName() == "literals" 
&& Parent->getParent() && Parent->getParent()->isStdNamespace())))
      return;
  }
  


https://reviews.llvm.org/D33010



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to