summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/DiagnosticRenderer.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-11-30 18:38:50 +0000
committerDouglas Gregor <dgregor@apple.com>2012-11-30 18:38:50 +0000
commitaf8f02634b879fac795e8d88961ebe3dd3b02b19 (patch)
tree80e3fb4b01f40615b94f3d596ad64960e3483f7c /clang/lib/Frontend/DiagnosticRenderer.cpp
parenta820e7feffdb4ed21eead966fc283d5737d43846 (diff)
downloadbcm5719-llvm-af8f02634b879fac795e8d88961ebe3dd3b02b19.tar.gz
bcm5719-llvm-af8f02634b879fac795e8d88961ebe3dd3b02b19.zip
When an error occurs while building a module on demand, provide "While
building module 'Foo' imported from..." notes (the same we we provide "In file included from..." notes) in the diagnostic, so that we know how this module got included in the first place. This is part of <rdar://problem/12696425>. llvm-svn: 169021
Diffstat (limited to 'clang/lib/Frontend/DiagnosticRenderer.cpp')
-rw-r--r--clang/lib/Frontend/DiagnosticRenderer.cpp33
1 files changed, 32 insertions, 1 deletions
diff --git a/clang/lib/Frontend/DiagnosticRenderer.cpp b/clang/lib/Frontend/DiagnosticRenderer.cpp
index 3143cc7b324..3599df82c79 100644
--- a/clang/lib/Frontend/DiagnosticRenderer.cpp
+++ b/clang/lib/Frontend/DiagnosticRenderer.cpp
@@ -205,8 +205,10 @@ void DiagnosticRenderer::emitIncludeStack(SourceLocation Loc,
/// on the way back down.
void DiagnosticRenderer::emitIncludeStackRecursively(SourceLocation Loc,
const SourceManager &SM) {
- if (Loc.isInvalid())
+ if (Loc.isInvalid()) {
+ emitModuleBuildPath(SM);
return;
+ }
PresumedLoc PLoc = SM.getPresumedLoc(Loc, DiagOpts->ShowPresumedLoc);
if (PLoc.isInvalid())
@@ -219,6 +221,21 @@ void DiagnosticRenderer::emitIncludeStackRecursively(SourceLocation Loc,
emitIncludeLocation(Loc, PLoc, SM);
}
+/// \brief Emit the module build path, for cases where a module is (re-)built
+/// on demand.
+void DiagnosticRenderer::emitModuleBuildPath(const SourceManager &SM) {
+ ModuleBuildPath Path = SM.getModuleBuildPath();
+ for (unsigned I = 0, N = Path.size(); I != N; ++I) {
+ const SourceManager &CurSM = Path[I].second.getManager();
+ SourceLocation CurLoc = Path[I].second;
+ emitBuildingModuleLocation(CurLoc,
+ CurSM.getPresumedLoc(CurLoc,
+ DiagOpts->ShowPresumedLoc),
+ Path[I].first,
+ CurSM);
+ }
+}
+
// Helper function to fix up source ranges. It takes in an array of ranges,
// and outputs an array of ranges where we want to draw the range highlighting
// around the location specified by CaretLoc.
@@ -390,6 +407,20 @@ void DiagnosticNoteRenderer::emitIncludeLocation(SourceLocation Loc,
emitNote(Loc, Message.str(), &SM);
}
+void
+DiagnosticNoteRenderer::emitBuildingModuleLocation(SourceLocation Loc,
+ PresumedLoc PLoc,
+ StringRef ModuleName,
+ const SourceManager &SM) {
+ // 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() << ":";
+ emitNote(Loc, Message.str(), &SM);
+}
+
+
void DiagnosticNoteRenderer::emitBasicNote(StringRef Message) {
emitNote(SourceLocation(), Message, 0);
}
OpenPOWER on IntegriCloud