aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/clang-cc/clang-cc.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/tools/clang-cc/clang-cc.cpp b/tools/clang-cc/clang-cc.cpp
index 784b19e61c..f6eec11c1c 100644
--- a/tools/clang-cc/clang-cc.cpp
+++ b/tools/clang-cc/clang-cc.cpp
@@ -783,7 +783,7 @@ static void ProcessInputFile(const CompilerInvocation &CompOpts,
const std::string &ImplicitPCHInclude =
CompOpts.getPreprocessorOpts().getImplicitPCHInclude();
- if (!ImplicitPCHInclude.empty()) {
+ if (Consumer && !ImplicitPCHInclude.empty()) {
// If the user specified -isysroot, it will be used for relocatable PCH
// files.
const char *isysrootPCH = CompOpts.getHeaderSearchOpts().Sysroot.c_str();
@@ -826,6 +826,18 @@ static void ProcessInputFile(const CompilerInvocation &CompOpts,
// the source location entries for the PCH file.
if (InitializeSourceManager(PP, InFile))
return;
+ } else if (!ImplicitPCHInclude.empty()) {
+ // If we have an implicit PCH, the source manager initialization was
+ // delayed, do it now.
+ //
+ // FIXME: Clean this up.
+
+ // Finish preprocessor initialization. We do this now (rather
+ // than earlier) because this initialization creates new source
+ // location entries in the source manager, which must come after
+ // the source location entries for the PCH file.
+ if (InitializeSourceManager(PP, InFile))
+ return;
}
// If we have an ASTConsumer, run the parser with it.