Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions clang/include/clang/Serialization/ASTWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -997,13 +997,15 @@ class CXX20ModulesGenerator : public PCHGenerator {
virtual Module *getEmittingModule(ASTContext &Ctx) override;

CXX20ModulesGenerator(Preprocessor &PP, InMemoryModuleCache &ModuleCache,
StringRef OutputFile, bool GeneratingReducedBMI);
StringRef OutputFile, bool GeneratingReducedBMI,
bool AllowASTWithErrors);

public:
CXX20ModulesGenerator(Preprocessor &PP, InMemoryModuleCache &ModuleCache,
StringRef OutputFile)
StringRef OutputFile, bool AllowASTWithErrors = false)
: CXX20ModulesGenerator(PP, ModuleCache, OutputFile,
/*GeneratingReducedBMI=*/false) {}
/*GeneratingReducedBMI=*/false,
AllowASTWithErrors) {}

void HandleTranslationUnit(ASTContext &Ctx) override;
};
Expand All @@ -1013,9 +1015,10 @@ class ReducedBMIGenerator : public CXX20ModulesGenerator {

public:
ReducedBMIGenerator(Preprocessor &PP, InMemoryModuleCache &ModuleCache,
StringRef OutputFile)
StringRef OutputFile, bool AllowASTWithErrors = false)
: CXX20ModulesGenerator(PP, ModuleCache, OutputFile,
/*GeneratingReducedBMI=*/true) {}
/*GeneratingReducedBMI=*/true,
AllowASTWithErrors) {}
};

/// If we can elide the definition of \param D in reduced BMI.
Expand Down
6 changes: 4 additions & 2 deletions clang/lib/Frontend/FrontendActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,14 @@ GenerateModuleInterfaceAction::CreateASTConsumer(CompilerInstance &CI,
!CI.getFrontendOpts().ModuleOutputPath.empty()) {
Consumers.push_back(std::make_unique<ReducedBMIGenerator>(
CI.getPreprocessor(), CI.getModuleCache(),
CI.getFrontendOpts().ModuleOutputPath));
CI.getFrontendOpts().ModuleOutputPath,
+CI.getFrontendOpts().AllowPCMWithCompilerErrors));
}

Consumers.push_back(std::make_unique<CXX20ModulesGenerator>(
CI.getPreprocessor(), CI.getModuleCache(),
CI.getFrontendOpts().OutputFile));
CI.getFrontendOpts().OutputFile,
+CI.getFrontendOpts().AllowPCMWithCompilerErrors));

return std::make_unique<MultiplexConsumer>(std::move(Consumers));
}
Expand Down
5 changes: 3 additions & 2 deletions clang/lib/Serialization/GeneratePCH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,13 @@ void PCHGenerator::anchor() {}
CXX20ModulesGenerator::CXX20ModulesGenerator(Preprocessor &PP,
InMemoryModuleCache &ModuleCache,
StringRef OutputFile,
bool GeneratingReducedBMI)
bool GeneratingReducedBMI,
bool AllowASTWithErrors)
: PCHGenerator(
PP, ModuleCache, OutputFile, llvm::StringRef(),
std::make_shared<PCHBuffer>(),
/*Extensions=*/ArrayRef<std::shared_ptr<ModuleFileExtension>>(),
/*AllowASTWithErrors*/ false, /*IncludeTimestamps=*/false,
AllowASTWithErrors, /*IncludeTimestamps=*/false,
/*BuildingImplicitModule=*/false, /*ShouldCacheASTInMemory=*/false,
GeneratingReducedBMI) {}

Expand Down
26 changes: 26 additions & 0 deletions clang/test/Modules/pcm-with-errors.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// RUN: rm -rf %t
// RUN: split-file %s %t
// RUN: cd %t

// RUN: %clang_cc1 -std=c++23 m.cppm -emit-module-interface -o m.pcm -fallow-pcm-with-compiler-errors -verify
// RUN: %clang_cc1 -std=c++23 main.cpp -fmodule-file=m=m.pcm -verify -fallow-pcm-with-compiler-errors -verify

// RUN: %clang_cc1 -std=c++23 m.cppm -fmodules-reduced-bmi -emit-module-interface -o m.pcm -fallow-pcm-with-compiler-errors -verify
// RUN: %clang_cc1 -std=c++23 main.cpp -fmodule-file=m=m.pcm -verify -fallow-pcm-with-compiler-errors -verify

//--- m.cppm
export module m;

export int f() {
return 0;
}

export struct Foo {
__Int bar; // expected-error {{unknown type name '__Int'}}
};

//--- main.cpp
// expected-no-diagnostics
import m; // ok

static_assert(__is_same(decltype(f), int())); // ok
Loading