diff --git a/clang-tools-extra/clangd/Headers.h b/clang-tools-extra/clangd/Headers.h --- a/clang-tools-extra/clangd/Headers.h +++ b/clang-tools-extra/clangd/Headers.h @@ -150,10 +150,6 @@ return RealPathNames[static_cast(ID)]; } - bool isSelfContained(HeaderID ID) const { - return !NonSelfContained.contains(ID); - } - // Return all transitively reachable files. llvm::ArrayRef allHeaders() const { return RealPathNames; } @@ -196,9 +192,6 @@ // and RealPathName and UniqueID are not preserved in // the preamble. llvm::DenseMap UIDToIndex; - // Contains HeaderIDs of all non self-contained entries in the - // IncludeStructure. - llvm::DenseSet NonSelfContained; // Maps written includes to indices in MainFileInclude for easier lookup by // spelling. diff --git a/clang-tools-extra/clangd/Headers.cpp b/clang-tools-extra/clangd/Headers.cpp --- a/clang-tools-extra/clangd/Headers.cpp +++ b/clang-tools-extra/clangd/Headers.cpp @@ -105,17 +105,6 @@ --Level; if (PrevFID == BuiltinFile) InBuiltinFile = false; - // At file exit time HeaderSearchInfo is valid and can be used to - // determine whether the file was a self-contained header or not. - if (const FileEntry *FE = SM.getFileEntryForID(PrevFID)) { - // isSelfContainedHeader only returns true once the full header-guard - // structure has been seen, i.e. when exiting the *outer* copy of the - // file. So last result wins. - if (tooling::isSelfContainedHeader(FE, SM, HeaderInfo)) - Out->NonSelfContained.erase(*Out->getID(FE)); - else - Out->NonSelfContained.insert(*Out->getID(FE)); - } break; } case PPCallbacks::RenameFile: diff --git a/clang-tools-extra/clangd/unittests/HeadersTests.cpp b/clang-tools-extra/clangd/unittests/HeadersTests.cpp --- a/clang-tools-extra/clangd/unittests/HeadersTests.cpp +++ b/clang-tools-extra/clangd/unittests/HeadersTests.cpp @@ -402,48 +402,6 @@ Contains(AllOf(includeLine(2), written("")))); } -TEST_F(HeadersTest, SelfContainedHeaders) { - // Including through non-builtin file has no effects. - FS.Files[MainFile] = R"cpp( -#include "includeguarded.h" -#include "nonguarded.h" -#include "pp_depend.h" -#include "pragmaguarded.h" -#include "recursive.h" -)cpp"; - FS.Files["pragmaguarded.h"] = R"cpp( -#pragma once -)cpp"; - FS.Files["includeguarded.h"] = R"cpp( -#ifndef INCLUDE_GUARDED_H -#define INCLUDE_GUARDED_H -void foo(); -#endif // INCLUDE_GUARDED_H -)cpp"; - FS.Files["nonguarded.h"] = R"cpp( -)cpp"; - FS.Files["pp_depend.h"] = R"cpp( - #ifndef REQUIRED_PP_DIRECTIVE - # error You have to have PP directive set to include this one! - #endif -)cpp"; - FS.Files["recursive.h"] = R"cpp( - #ifndef RECURSIVE_H - #define RECURSIVE_H - - #include "recursive.h" - - #endif // RECURSIVE_H -)cpp"; - - auto Includes = collectIncludes(); - EXPECT_TRUE(Includes.isSelfContained(getID("pragmaguarded.h", Includes))); - EXPECT_TRUE(Includes.isSelfContained(getID("includeguarded.h", Includes))); - EXPECT_TRUE(Includes.isSelfContained(getID("recursive.h", Includes))); - EXPECT_FALSE(Includes.isSelfContained(getID("nonguarded.h", Includes))); - EXPECT_FALSE(Includes.isSelfContained(getID("pp_depend.h", Includes))); -} - } // namespace } // namespace clangd } // namespace clang