diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-06-26 20:33:12 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-06-26 20:33:12 +0000 |
commit | ef915aab0ac566c55bfb0d7a9f6635bb5d94d4af (patch) | |
tree | ac935cfa19985d33098fc13e288b5ac830672dba /lib/Frontend/Rewrite/FrontendActions.cpp | |
parent | 325377b57338e700317f5e423e5b0f1c08d99a39 (diff) |
Notes
Diffstat (limited to 'lib/Frontend/Rewrite/FrontendActions.cpp')
-rw-r--r-- | lib/Frontend/Rewrite/FrontendActions.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/Frontend/Rewrite/FrontendActions.cpp b/lib/Frontend/Rewrite/FrontendActions.cpp index 45feffbcb5b54..e93f737c47fdf 100644 --- a/lib/Frontend/Rewrite/FrontendActions.cpp +++ b/lib/Frontend/Rewrite/FrontendActions.cpp @@ -9,6 +9,7 @@ #include "clang/Rewrite/Frontend/FrontendActions.h" #include "clang/AST/ASTConsumer.h" +#include "clang/Basic/CharInfo.h" #include "clang/Frontend/CompilerInstance.h" #include "clang/Frontend/FrontendActions.h" #include "clang/Frontend/FrontendDiagnostic.h" @@ -224,7 +225,15 @@ public: auto OS = Out.lock(); assert(OS && "loaded module file after finishing rewrite action?"); - (*OS) << "#pragma clang module build " << MF->ModuleName << "\n"; + (*OS) << "#pragma clang module build "; + if (isValidIdentifier(MF->ModuleName)) + (*OS) << MF->ModuleName; + else { + (*OS) << '"'; + OS->write_escaped(MF->ModuleName); + (*OS) << '"'; + } + (*OS) << '\n'; // Rewrite the contents of the module in a separate compiler instance. CompilerInstance Instance(CI.getPCHContainerOperations(), @@ -234,9 +243,12 @@ public: Instance.createDiagnostics( new ForwardingDiagnosticConsumer(CI.getDiagnosticClient()), /*ShouldOwnClient=*/true); + Instance.getFrontendOpts().DisableFree = false; Instance.getFrontendOpts().Inputs.clear(); Instance.getFrontendOpts().Inputs.emplace_back( Filename, InputKind(InputKind::Unknown, InputKind::Precompiled)); + Instance.getFrontendOpts().ModuleFiles.clear(); + Instance.getFrontendOpts().ModuleMapFiles.clear(); // Don't recursively rewrite imports. We handle them all at the top level. Instance.getPreprocessorOutputOpts().RewriteImports = false; |