v1nh1shungry created this revision. v1nh1shungry added reviewers: thesamesam, tom-anders, junaire. Herald added subscribers: kadircet, arphaman. Herald added a project: All. v1nh1shungry requested review of this revision. Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov. Herald added a project: clang-tools-extra.
Avoid adding qualifiers before C++ operators declared in a non-class context Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D137494 Files: clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp Index: clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp =================================================================== --- clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp +++ clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp @@ -155,6 +155,13 @@ if (!visibleContext(T->getDeclContext()) ->Equals(TargetDirective->getNominatedNamespace())) return; + // Avoid adding qualifiers before operators, e.g. + // using namespace std; + // cout << "foo"; // Must not changed to std::cout std:: << "foo" + // FIXME: Operators declared in a class context are not handled + if (T->isInIdentifierNamespace( + Decl::IdentifierNamespace::IDNS_NonMemberOperator)) + return; } SourceLocation Loc = Ref.NameLoc; if (Loc.isMacroID()) {
Index: clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp =================================================================== --- clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp +++ clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp @@ -155,6 +155,13 @@ if (!visibleContext(T->getDeclContext()) ->Equals(TargetDirective->getNominatedNamespace())) return; + // Avoid adding qualifiers before operators, e.g. + // using namespace std; + // cout << "foo"; // Must not changed to std::cout std:: << "foo" + // FIXME: Operators declared in a class context are not handled + if (T->isInIdentifierNamespace( + Decl::IdentifierNamespace::IDNS_NonMemberOperator)) + return; } SourceLocation Loc = Ref.NameLoc; if (Loc.isMacroID()) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits