[PATCH] D145917: [clangd] Remove the IncludeStructure::isSelfContained API.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 13 02:54:47 PDT 2023
hokein created this revision.
hokein added a reviewer: kadircet.
Herald added a subscriber: arphaman.
Herald added a project: All.
hokein requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.
This API was merely used in the old unused-include implementation, with
the removal, this API is not used anymore.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D145917
Files:
clang-tools-extra/clangd/Headers.cpp
clang-tools-extra/clangd/Headers.h
clang-tools-extra/clangd/unittests/HeadersTests.cpp
Index: clang-tools-extra/clangd/unittests/HeadersTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/HeadersTests.cpp
+++ clang-tools-extra/clangd/unittests/HeadersTests.cpp
@@ -402,48 +402,6 @@
Contains(AllOf(includeLine(2), written("<a.h>"))));
}
-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
Index: clang-tools-extra/clangd/Headers.h
===================================================================
--- clang-tools-extra/clangd/Headers.h
+++ clang-tools-extra/clangd/Headers.h
@@ -150,10 +150,6 @@
return RealPathNames[static_cast<unsigned>(ID)];
}
- bool isSelfContained(HeaderID ID) const {
- return !NonSelfContained.contains(ID);
- }
-
// Return all transitively reachable files.
llvm::ArrayRef<std::string> allHeaders() const { return RealPathNames; }
@@ -196,9 +192,6 @@
// and RealPathName and UniqueID are not preserved in
// the preamble.
llvm::DenseMap<llvm::sys::fs::UniqueID, HeaderID> UIDToIndex;
- // Contains HeaderIDs of all non self-contained entries in the
- // IncludeStructure.
- llvm::DenseSet<HeaderID> NonSelfContained;
// Maps written includes to indices in MainFileInclude for easier lookup by
// spelling.
Index: clang-tools-extra/clangd/Headers.cpp
===================================================================
--- clang-tools-extra/clangd/Headers.cpp
+++ 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:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145917.504568.patch
Type: text/x-patch
Size: 3493 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230313/84af518e/attachment-0001.bin>
More information about the cfe-commits
mailing list