[clang] [clang-tools-extra] [clang-tidy] Add support for bsl::optional (PR #101450)

Yitzhak Mandelbaum via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 2 11:16:48 PDT 2024


================
@@ -38,10 +38,22 @@
 namespace clang {
 namespace dataflow {
 
-static bool isTopLevelNamespaceWithName(const NamespaceDecl &NS,
-                                        llvm::StringRef Name) {
-  return NS.getDeclName().isIdentifier() && NS.getName() == Name &&
-         NS.getParent() != nullptr && NS.getParent()->isTranslationUnit();
+template <class... NameTypes>
+static bool hasNestedNamespace(const NamespaceDecl &NS, llvm::StringRef Name,
----------------
ymand wrote:

I think this function name makes the callsites harder to understand. E.g. for "absl", we're not querying for a nested namespace of "absl".  Please either find a more precise name or document behavior in a comment. When I read "hasNestedNamespace", I think of a function that searches a namespace for another one nested inside. At the least, why not "isNestedNamespace", since the query is on the NamespaceDecl itself and is an exact match, so "is" seems more appropriate than "has"?

https://github.com/llvm/llvm-project/pull/101450


More information about the cfe-commits mailing list