Skip to content
Open
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
15 changes: 12 additions & 3 deletions clang/lib/CIR/FrontendAction/CIRGenAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,18 @@ class CIRGenConsumer : public clang::ASTConsumer {
void HandleTranslationUnit(ASTContext &C) override {
Gen->HandleTranslationUnit(C);

mlir::ModuleOp MlirModule = Gen->getModule();
mlir::MLIRContext &MlirCtx = Gen->getMLIRContext();

SourceManager &ClangSourceMgr = C.getSourceManager();
FileID MainFileID = ClangSourceMgr.getMainFileID();
std::unique_ptr<llvm::MemoryBuffer> FileBuf =
llvm::MemoryBuffer::getMemBuffer(
ClangSourceMgr.getBufferOrFake(MainFileID));
llvm::SourceMgr MlirSourceMgr;
MlirSourceMgr.AddNewSourceBuffer(std::move(FileBuf), llvm::SMLoc());
mlir::SourceMgrDiagnosticHandler DiagnosticHandler(MlirSourceMgr, &MlirCtx);

if (!FEOptions.ClangIRDisableCIRVerifier) {
if (!Gen->verifyModule()) {
CI.getDiagnostics().Report(
Expand All @@ -105,9 +117,6 @@ class CIRGenConsumer : public clang::ASTConsumer {
}
}

mlir::ModuleOp MlirModule = Gen->getModule();
mlir::MLIRContext &MlirCtx = Gen->getMLIRContext();

if (!FEOptions.ClangIRDisablePasses) {
// Setup and run CIR pipeline.
if (runCIRToCIRPasses(MlirModule, MlirCtx, C,
Expand Down