diff --git a/clang-tools-extra/clangd/IncludeCleaner.cpp b/clang-tools-extra/clangd/IncludeCleaner.cpp --- a/clang-tools-extra/clangd/IncludeCleaner.cpp +++ b/clang-tools-extra/clangd/IncludeCleaner.cpp @@ -133,6 +133,11 @@ return true; } + bool VisitUsingDirectiveDecl(UsingDirectiveDecl *D) { + add(D->getNominatedNamespace()); + return true; + } + // Enums may be usefully forward-declared as *complete* types by specifying // an underlying type. In this case, the definition should see the declaration // so they can be checked for compatibility. diff --git a/clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp b/clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp --- a/clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp +++ b/clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp @@ -77,7 +77,7 @@ "using ns::foo;", }, { - "namespace ns { void foo(); void foo() {}; }", + "namespace ^ns { void foo(); void foo() {}; }", "using namespace ns;", }, {