diff options
Diffstat (limited to 'clang/lib/Frontend')
-rw-r--r-- | clang/lib/Frontend/DiagnosticRenderer.cpp | 7 | ||||
-rw-r--r-- | clang/lib/Frontend/FrontendActions.cpp | 10 |
2 files changed, 14 insertions, 3 deletions
diff --git a/clang/lib/Frontend/DiagnosticRenderer.cpp b/clang/lib/Frontend/DiagnosticRenderer.cpp index 4eee59548c8..b52f0103e6b 100644 --- a/clang/lib/Frontend/DiagnosticRenderer.cpp +++ b/clang/lib/Frontend/DiagnosticRenderer.cpp @@ -499,8 +499,11 @@ DiagnosticNoteRenderer::emitBuildingModuleLocation(SourceLocation Loc, // Generate a note indicating the include location. SmallString<200> MessageStorage; llvm::raw_svector_ostream Message(MessageStorage); - Message << "while building module '" << ModuleName << "' imported from " - << PLoc.getFilename() << ':' << PLoc.getLine() << ":"; + if (PLoc.getFilename()) + Message << "while building module '" << ModuleName << "' imported from " + << PLoc.getFilename() << ':' << PLoc.getLine() << ":"; + else + Message << "while building module '" << ModuleName << ":"; emitNote(Loc, Message.str(), &SM); } diff --git a/clang/lib/Frontend/FrontendActions.cpp b/clang/lib/Frontend/FrontendActions.cpp index f587d829b39..4ed2df3a25c 100644 --- a/clang/lib/Frontend/FrontendActions.cpp +++ b/clang/lib/Frontend/FrontendActions.cpp @@ -240,7 +240,15 @@ bool GenerateModuleAction::BeginSourceFileAction(CompilerInstance &CI, // map with a single module (the common case). return false; } - + + // If we're being run from the command-line, the module build stack will not + // have been filled in yet, so complete it now in order to allow us to detect + // module cycles. + SourceManager &SourceMgr = CI.getSourceManager(); + if (SourceMgr.getModuleBuildStack().empty()) + SourceMgr.pushModuleBuildStack(CI.getLangOpts().CurrentModule, + FullSourceLoc(SourceLocation(), SourceMgr)); + // Dig out the module definition. Module = HS.lookupModule(CI.getLangOpts().CurrentModule, /*AllowSearch=*/false); |