[clang-tools-extra] a0f13b3 - Revert "[clangd] Copy existing includes in ReplayPreamble"
Kadir Cetinkaya via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 2 05:33:13 PDT 2020
Author: Kadir Cetinkaya
Date: 2020-06-02T14:31:45+02:00
New Revision: a0f13b33742372bf00640eb18a2f3229176fc77d
URL: https://github.com/llvm/llvm-project/commit/a0f13b33742372bf00640eb18a2f3229176fc77d
DIFF: https://github.com/llvm/llvm-project/commit/a0f13b33742372bf00640eb18a2f3229176fc77d.diff
LOG: Revert "[clangd] Copy existing includes in ReplayPreamble"
This reverts commit bff0c56ff92106afad22b54a90e1c612da4d6f99. I've
pushed the earlier version of the patch by mistake.
Added:
Modified:
clang-tools-extra/clangd/ParsedAST.cpp
clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/ParsedAST.cpp b/clang-tools-extra/clangd/ParsedAST.cpp
index 9eed9bc3199f..082c7cae0021 100644
--- a/clang-tools-extra/clangd/ParsedAST.cpp
+++ b/clang-tools-extra/clangd/ParsedAST.cpp
@@ -136,8 +136,7 @@ class ReplayPreamble : private PPCallbacks {
ReplayPreamble(const IncludeStructure &Includes, PPCallbacks *Delegate,
const SourceManager &SM, Preprocessor &PP,
const LangOptions &LangOpts, const PreambleBounds &PB)
- : IncludesToReplay(Includes.MainFileIncludes), Delegate(Delegate), SM(SM),
- PP(PP) {
+ : Includes(Includes), Delegate(Delegate), SM(SM), PP(PP) {
// Only tokenize the preamble section of the main file, as we are not
// interested in the rest of the tokens.
MainFileTokens = syntax::tokenize(
@@ -168,7 +167,7 @@ class ReplayPreamble : private PPCallbacks {
}
void replay() {
- for (const auto &Inc : IncludesToReplay) {
+ for (const auto &Inc : Includes.MainFileIncludes) {
const FileEntry *File = nullptr;
if (Inc.Resolved != "")
if (auto FE = SM.getFileManager().getFile(Inc.Resolved))
@@ -228,7 +227,7 @@ class ReplayPreamble : private PPCallbacks {
}
}
- std::vector<Inclusion> IncludesToReplay;
+ const IncludeStructure &Includes;
PPCallbacks *Delegate;
const SourceManager &SM;
Preprocessor &PP;
diff --git a/clang-tools-extra/clangd/unittests/ParsedASTTests.cpp b/clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
index 0ad4a9f20ccb..d86f741d9e72 100644
--- a/clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
@@ -328,8 +328,6 @@ TEST(ParsedASTTest, CollectsMainFileMacroExpansions) {
testing::UnorderedElementsAreArray(TestCase.points()));
}
-MATCHER_P(WithFileName, Inc, "") { return arg.FileName == Inc; }
-
TEST(ParsedASTTest, ReplayPreambleForTidyCheckers) {
struct Inclusion {
Inclusion(const SourceManager &SM, SourceLocation HashLoc,
@@ -441,24 +439,6 @@ TEST(ParsedASTTest, ReplayPreambleForTidyCheckers) {
Code.substr(FileRange.Begin - 1, FileRange.End - FileRange.Begin + 2));
EXPECT_EQ(SkippedFiles[I].kind(), tok::header_name);
}
-
- // Make sure replay logic works with patched preambles.
- TU.Code = "";
- StoreDiags Diags;
- auto Inputs = TU.inputs();
- auto CI = buildCompilerInvocation(Inputs, Diags);
- auto EmptyPreamble =
- buildPreamble(testPath(TU.Filename), *CI, Inputs, true, nullptr);
- ASSERT_TRUE(EmptyPreamble);
- TU.Code = "#include <a.h>";
- Includes.clear();
- auto PatchedAST = ParsedAST::build(testPath(TU.Filename), TU.inputs(),
- std::move(CI), {}, EmptyPreamble);
- ASSERT_TRUE(PatchedAST);
- // Make sure includes were seen only once.
- EXPECT_THAT(Includes,
- ElementsAre(WithFileName(testPath("__preamble_patch__.h")),
- WithFileName("a.h")));
}
TEST(ParsedASTTest, PatchesAdditionalIncludes) {
More information about the cfe-commits
mailing list