diff options
Diffstat (limited to 'clang/lib/Frontend/Rewrite/FrontendActions.cpp')
-rw-r--r-- | clang/lib/Frontend/Rewrite/FrontendActions.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/clang/lib/Frontend/Rewrite/FrontendActions.cpp b/clang/lib/Frontend/Rewrite/FrontendActions.cpp index 45feffbcb5b..2ccdc263951 100644 --- a/clang/lib/Frontend/Rewrite/FrontendActions.cpp +++ b/clang/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(), |