assert(ASTModule && "module file does not define its own module");
Input = FrontendInputFile(ASTModule->PresumedModuleMapFile, Kind);
} else {
- auto &SM = CI.getSourceManager();
- FileID ID = SM.getMainFileID();
- if (auto *File = SM.getFileEntryForID(ID))
+ auto &OldSM = AST->getSourceManager();
+ FileID ID = OldSM.getMainFileID();
+ if (auto *File = OldSM.getFileEntryForID(ID))
Input = FrontendInputFile(File->getName(), Kind);
else
- Input = FrontendInputFile(SM.getBuffer(ID), Kind);
+ Input = FrontendInputFile(OldSM.getBuffer(ID), Kind);
}
setCurrentInput(Input, std::move(AST));
}
}
std::unique_ptr<raw_ostream> OS =
- CI.createDefaultOutputFile(BinaryMode, getCurrentFile());
+ CI.createDefaultOutputFile(BinaryMode, getCurrentFileOrBufferName());
if (!OS) return;
// If we're preprocessing a module map, start by dumping the contents of the
OS->write_escaped(Input.getFile());
(*OS) << "\"\n";
}
- // FIXME: Include additional information here so that we don't need the
- // original source files to exist on disk.
getCurrentModule()->print(*OS);
(*OS) << "#pragma clang module contents\n";
}
void RewriteMacrosAction::ExecuteAction() {
CompilerInstance &CI = getCompilerInstance();
std::unique_ptr<raw_ostream> OS =
- CI.createDefaultOutputFile(true, getCurrentFile());
+ CI.createDefaultOutputFile(true, getCurrentFileOrBufferName());
if (!OS) return;
RewriteMacrosInInput(CI.getPreprocessor(), OS.get());
void RewriteTestAction::ExecuteAction() {
CompilerInstance &CI = getCompilerInstance();
std::unique_ptr<raw_ostream> OS =
- CI.createDefaultOutputFile(false, getCurrentFile());
+ CI.createDefaultOutputFile(false, getCurrentFileOrBufferName());
if (!OS) return;
DoRewriteTest(CI.getPreprocessor(), OS.get());
bool RewriteIncludesAction::BeginSourceFileAction(CompilerInstance &CI) {
if (!OutputStream) {
- OutputStream = CI.createDefaultOutputFile(true, getCurrentFile());
+ OutputStream =
+ CI.createDefaultOutputFile(true, getCurrentFileOrBufferName());
if (!OutputStream)
return false;
}
// RUN: %clang_cc1 -fmodules-ts -fmodule-file=%t.pcm %s -I%S/Inputs/no-module-map -verify -DB
// RUN: %clang_cc1 -fmodules-ts -fmodule-file=%t.pcm %s -I%S/Inputs/no-module-map -verify -DA -DB
+// RUN: %clang_cc1 -E %t.pcm -o - | FileCheck %s
+// RUN: %clang_cc1 -frewrite-imports -E %t.pcm -o - | FileCheck %s
+// CHECK: # {{.*}}a.h
+// CHECK: # {{.*}}b.h
+
#ifdef B
// expected-no-diagnostics
#endif