Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Correctly set CompilingPCH in PrecompilePreambleAction.
This fixes a crash bug in clangd when used with modules. ASTWriter would end up writing references to submodules into the PCH file, but upon reading the submodules would not exists and HeaderFileInfoTrait::ReadData would crash. Differential Revision: https://reviews.llvm.org/D85532
- Loading branch information
Showing
4 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
//===-- ModulesTests.cpp ---------------------------------------*- C++ -*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "Annotations.h" | ||
#include "TestFS.h" | ||
#include "TestTU.h" | ||
#include "gmock/gmock.h" | ||
#include "gtest/gtest.h" | ||
|
||
#include <memory> | ||
#include <string> | ||
|
||
namespace clang { | ||
namespace clangd { | ||
namespace { | ||
|
||
TEST(Modules, TextualIncludeInPreamble) { | ||
TestTU TU = TestTU::withCode(R"cpp( | ||
#include "Textual.h" | ||
void foo() {} | ||
)cpp"); | ||
TU.ExtraArgs.push_back("-fmodule-name=M"); | ||
TU.ExtraArgs.push_back("-fmodule-map-file=m.modulemap"); | ||
TU.AdditionalFiles["Textual.h"] = "void foo();"; | ||
TU.AdditionalFiles["m.modulemap"] = R"modulemap( | ||
module M { | ||
module Textual { | ||
textual header "Textual.h" | ||
} | ||
} | ||
)modulemap"; | ||
// Test that we do not crash. | ||
TU.index(); | ||
} | ||
|
||
} // namespace | ||
} // namespace clangd | ||
} // namespace clang |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters