From d80c7c4808a7705decdcf9f4d9937ac02db6d6a1 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Fri, 3 Jun 2016 08:05:11 +0000 Subject: [clang-tidy] Ignore function context in misc-unused-using-decls. Summary: Make the check's behavior more correct when handling using-decls in multiple scopes. Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D20909 llvm-svn: 271632 --- .../test/clang-tidy/misc-unused-using-decls.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'clang-tools-extra/test/clang-tidy/misc-unused-using-decls.cpp') diff --git a/clang-tools-extra/test/clang-tidy/misc-unused-using-decls.cpp b/clang-tools-extra/test/clang-tidy/misc-unused-using-decls.cpp index 92977cc048d..4d6b33252f1 100644 --- a/clang-tools-extra/test/clang-tidy/misc-unused-using-decls.cpp +++ b/clang-tools-extra/test/clang-tidy/misc-unused-using-decls.cpp @@ -17,6 +17,8 @@ class I { static int ii; }; template class J {}; +class G; +class H; class Base { public: @@ -99,6 +101,24 @@ DEFINE_INT(test); USING_FUNC #undef USING_FUNC +namespace N1 { +// n::G is used in namespace N2. +// Currently, the check doesn't support multiple scopes. All the relevant +// using-decls will be marked as used once we see an usage even the usage is in +// other scope. +using n::G; +} + +namespace N2 { +using n::G; +void f(G g); +} + +void IgnoreFunctionScope() { +// Using-decls defined in function scope will be ignored. +using n::H; +} + // ----- Usages ----- void f(B b); void g() { @@ -112,4 +132,3 @@ void g() { UsedTemplateFunc(); cout << endl; } - -- cgit v1.2.3