r342306 - [modules] Support use of -E on modules built from the command line.
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 14 18:21:18 PDT 2018
Author: rsmith
Date: Fri Sep 14 18:21:18 2018
New Revision: 342306
URL: http://llvm.org/viewvc/llvm-project?rev=342306&view=rev
Log:
[modules] Support use of -E on modules built from the command line.
Modified:
cfe/trunk/lib/Frontend/FrontendAction.cpp
cfe/trunk/lib/Frontend/FrontendActions.cpp
cfe/trunk/lib/Frontend/Rewrite/FrontendActions.cpp
cfe/trunk/test/Modules/no-module-map.cpp
Modified: cfe/trunk/lib/Frontend/FrontendAction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendAction.cpp?rev=342306&r1=342305&r2=342306&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/FrontendAction.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendAction.cpp Fri Sep 14 18:21:18 2018
@@ -587,12 +587,12 @@ bool FrontendAction::BeginSourceFile(Com
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));
}
Modified: cfe/trunk/lib/Frontend/FrontendActions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendActions.cpp?rev=342306&r1=342305&r2=342306&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/FrontendActions.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendActions.cpp Fri Sep 14 18:21:18 2018
@@ -825,7 +825,7 @@ void PrintPreprocessedAction::ExecuteAct
}
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
@@ -837,8 +837,6 @@ void PrintPreprocessedAction::ExecuteAct
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";
}
Modified: cfe/trunk/lib/Frontend/Rewrite/FrontendActions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/Rewrite/FrontendActions.cpp?rev=342306&r1=342305&r2=342306&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/Rewrite/FrontendActions.cpp (original)
+++ cfe/trunk/lib/Frontend/Rewrite/FrontendActions.cpp Fri Sep 14 18:21:18 2018
@@ -181,7 +181,7 @@ RewriteObjCAction::CreateASTConsumer(Com
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());
@@ -190,7 +190,7 @@ void RewriteMacrosAction::ExecuteAction(
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());
@@ -265,7 +265,8 @@ public:
bool RewriteIncludesAction::BeginSourceFileAction(CompilerInstance &CI) {
if (!OutputStream) {
- OutputStream = CI.createDefaultOutputFile(true, getCurrentFile());
+ OutputStream =
+ CI.createDefaultOutputFile(true, getCurrentFileOrBufferName());
if (!OutputStream)
return false;
}
Modified: cfe/trunk/test/Modules/no-module-map.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/no-module-map.cpp?rev=342306&r1=342305&r2=342306&view=diff
==============================================================================
--- cfe/trunk/test/Modules/no-module-map.cpp (original)
+++ cfe/trunk/test/Modules/no-module-map.cpp Fri Sep 14 18:21:18 2018
@@ -4,6 +4,11 @@
// 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
More information about the cfe-commits
mailing list