Skip to content

Commit a8684e9

Browse files
committed
Revert "make -fmodules-codegen and -fmodules-debuginfo work also with PCHs"
This caused PR44953. See also the discussion on D74846. This reverts commit cbc9d22. (cherry picked from commit 7ea9a6e)
1 parent 7e3ebf3 commit a8684e9

File tree

6 files changed

+11
-60
lines changed

6 files changed

+11
-60
lines changed

clang/lib/Serialization/ASTReader.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3224,8 +3224,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
32243224
case MODULAR_CODEGEN_DECLS:
32253225
// FIXME: Skip reading this record if our ASTConsumer doesn't care about
32263226
// them (ie: if we're not codegenerating this module).
3227-
if (F.Kind == MK_MainFile ||
3228-
getContext().getLangOpts().BuildingPCHWithObjectFile)
3227+
if (F.Kind == MK_MainFile)
32293228
for (unsigned I = 0, N = Record.size(); I != N; ++I)
32303229
EagerlyDeserializedDecls.push_back(getGlobalDeclID(F, Record[I]));
32313230
break;

clang/lib/Serialization/ASTReaderDecl.cpp

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -502,12 +502,8 @@ uint64_t ASTDeclReader::GetCurrentCursorOffset() {
502502
}
503503

504504
void ASTDeclReader::ReadFunctionDefinition(FunctionDecl *FD) {
505-
if (Record.readInt()) {
505+
if (Record.readInt())
506506
Reader.DefinitionSource[FD] = Loc.F->Kind == ModuleKind::MK_MainFile;
507-
if (Reader.getContext().getLangOpts().BuildingPCHWithObjectFile &&
508-
Reader.DeclIsFromPCHWithObjectFile(FD))
509-
Reader.DefinitionSource[FD] = true;
510-
}
511507
if (auto *CD = dyn_cast<CXXConstructorDecl>(FD)) {
512508
CD->setNumCtorInitializers(Record.readInt());
513509
if (CD->getNumCtorInitializers())
@@ -1422,12 +1418,8 @@ ASTDeclReader::RedeclarableResult ASTDeclReader::VisitVarDeclImpl(VarDecl *VD) {
14221418
Reader.getContext().setBlockVarCopyInit(VD, CopyExpr, Record.readInt());
14231419
}
14241420

1425-
if (VD->getStorageDuration() == SD_Static && Record.readInt()) {
1421+
if (VD->getStorageDuration() == SD_Static && Record.readInt())
14261422
Reader.DefinitionSource[VD] = Loc.F->Kind == ModuleKind::MK_MainFile;
1427-
if (Reader.getContext().getLangOpts().BuildingPCHWithObjectFile &&
1428-
Reader.DeclIsFromPCHWithObjectFile(VD))
1429-
Reader.DefinitionSource[VD] = true;
1430-
}
14311423

14321424
enum VarKind {
14331425
VarNotTemplate = 0, VarTemplate, StaticDataMemberSpecialization
@@ -1686,12 +1678,8 @@ void ASTDeclReader::ReadCXXDefinitionData(
16861678
Data.ODRHash = Record.readInt();
16871679
Data.HasODRHash = true;
16881680

1689-
if (Record.readInt()) {
1681+
if (Record.readInt())
16901682
Reader.DefinitionSource[D] = Loc.F->Kind == ModuleKind::MK_MainFile;
1691-
if (Reader.getContext().getLangOpts().BuildingPCHWithObjectFile &&
1692-
Reader.DeclIsFromPCHWithObjectFile(D))
1693-
Reader.DefinitionSource[D] = true;
1694-
}
16951683

16961684
Data.NumBases = Record.readInt();
16971685
if (Data.NumBases)

clang/lib/Serialization/ASTWriter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5596,8 +5596,8 @@ void ASTRecordWriter::AddCXXDefinitionData(const CXXRecordDecl *D) {
55965596

55975597
// getODRHash will compute the ODRHash if it has not been previously computed.
55985598
Record->push_back(D->getODRHash());
5599-
bool ModulesDebugInfo =
5600-
Writer->Context->getLangOpts().ModulesDebugInfo && !D->isDependentType();
5599+
bool ModulesDebugInfo = Writer->Context->getLangOpts().ModulesDebugInfo &&
5600+
Writer->WritingModule && !D->isDependentType();
56015601
Record->push_back(ModulesDebugInfo);
56025602
if (ModulesDebugInfo)
56035603
Writer->ModularCodegenDecls.push_back(Writer->GetDeclRef(D));

clang/lib/Serialization/ASTWriterDecl.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,16 +1011,15 @@ void ASTDeclWriter::VisitVarDecl(VarDecl *D) {
10111011

10121012
if (D->getStorageDuration() == SD_Static) {
10131013
bool ModulesCodegen = false;
1014-
if (!D->getDescribedVarTemplate() && !D->getMemberSpecializationInfo() &&
1014+
if (Writer.WritingModule &&
1015+
!D->getDescribedVarTemplate() && !D->getMemberSpecializationInfo() &&
10151016
!isa<VarTemplateSpecializationDecl>(D)) {
10161017
// When building a C++ Modules TS module interface unit, a strong
10171018
// definition in the module interface is provided by the compilation of
10181019
// that module interface unit, not by its users. (Inline variables are
10191020
// still emitted in module users.)
10201021
ModulesCodegen =
1021-
(((Writer.WritingModule &&
1022-
Writer.WritingModule->Kind == Module::ModuleInterfaceUnit) ||
1023-
Writer.Context->getLangOpts().BuildingPCHWithObjectFile) &&
1022+
(Writer.WritingModule->Kind == Module::ModuleInterfaceUnit &&
10241023
Writer.Context->GetGVALinkageForVariable(D) == GVA_StrongExternal);
10251024
}
10261025
Record.push_back(ModulesCodegen);
@@ -2449,11 +2448,9 @@ void ASTRecordWriter::AddFunctionDefinition(const FunctionDecl *FD) {
24492448

24502449
assert(FD->doesThisDeclarationHaveABody());
24512450
bool ModulesCodegen = false;
2452-
if (!FD->isDependentContext()) {
2451+
if (Writer->WritingModule && !FD->isDependentContext()) {
24532452
Optional<GVALinkage> Linkage;
2454-
if ((Writer->WritingModule &&
2455-
Writer->WritingModule->Kind == Module::ModuleInterfaceUnit) ||
2456-
Writer->Context->getLangOpts().BuildingPCHWithObjectFile) {
2453+
if (Writer->WritingModule->Kind == Module::ModuleInterfaceUnit) {
24572454
// When building a C++ Modules TS module interface unit, a strong
24582455
// definition in the module interface is provided by the compilation of
24592456
// that module interface unit, not by its users. (Inline functions are
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
#ifndef FOO_H
2-
#define FOO_H
31
struct foo {
42
};
53
inline void f1() {
64
}
7-
#endif

clang/test/PCH/codegen.cpp

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)