if (!visibleContext(T->getDeclContext())
->Equals(TargetDirective->getNominatedNamespace()))
return;
+ auto Kind = T->getDeclName().getNameKind();
// Avoid adding qualifiers before operators, e.g.
// using namespace std;
// cout << "foo"; // Must not changed to std::cout std:: << "foo"
- // FIXME: User-defined literals are not handled
- if (T->isInIdentifierNamespace(
- Decl::IdentifierNamespace::IDNS_NonMemberOperator))
+ if (Kind == DeclarationName::CXXOperatorName)
+ return;
+ // Avoid adding qualifiers before user-defined literals, e.g.
+ // using namespace std;
+ // auto s = "foo"s; // Must not changed to auto s = "foo" std::s;
+ // FIXME: Add a using-directive for user-defined literals
+ // declared in an inline namespace, e.g.
+ // using namespace s^td;
+ // int main() { cout << "foo"s; }
+ // change to
+ // using namespace std::literals;
+ // int main() { std::cout << "foo"s; }
+ if (Kind == DeclarationName::NameKind::CXXLiteralOperatorName)
return;
}
SourceLocation Loc = Ref.NameLoc;
ns::Foo foo;
foo + 10;
}
+ )cpp"},
+ {// Does not qualify user-defined literals
+ R"cpp(
+ namespace ns {
+ long double operator "" _w(long double);
+ }
+ using namespace n^s;
+ int main() { 1.5_w; }
+ )cpp",
+ R"cpp(
+ namespace ns {
+ long double operator "" _w(long double);
+ }
+
+ int main() { 1.5_w; }
)cpp"}};
for (auto C : Cases)
EXPECT_EQ(C.second, apply(C.first)) << C.first;