[PATCH] D55409: [clang-tidy] check for using declarations not in an anonymous namespace when there exists one

Shyan Akmal via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 10 17:24:53 PDT 2019


Naysh marked an inline comment as done.
Naysh added inline comments.


================
Comment at: clang-tidy/abseil/AnonymousEnclosedAliasesCheck.cpp:41
+    // to the vector containing all candidate using declarations.
+    if (AnonymousNamespaceDecl) {
+  		diag(MatchedUsingDecl->getLocation(),
----------------
aaron.ballman wrote:
> I don't think this logic works in practice because there's no way to determine that the anonymous namespace is even a candidate for putting the using declaration into it. Consider a common scenario where there's an anonymous namespace declared in a header file (like an STL header outside of the user's control), and a using declaration inside of an implementation file. Just because the STL declared an anonymous namespace doesn't mean that the user could have put their using declaration in it.
If we altered the check to only apply to anonymous namespaces and using declarations at namespace scope (that is, we only suggest aliases be moved to anonymous namespaces when the unnamed namespace and alias are themselves inside some other namespace), would this issue be resolved? 


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

https://reviews.llvm.org/D55409





More information about the cfe-commits mailing list