diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-08-11 00:05:21 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-08-11 00:05:21 +0000 |
commit | a24ff5545bbd80ac78c6db1e1ebf826d3482da9d (patch) | |
tree | e97b860513c1a255d25764aa72d82e5051d05fa1 /clang/lib | |
parent | 629d8e6f18922a2c0a9df6b59ab8ac2bdeb16d2f (diff) | |
download | bcm5719-llvm-a24ff5545bbd80ac78c6db1e1ebf826d3482da9d.tar.gz bcm5719-llvm-a24ff5545bbd80ac78c6db1e1ebf826d3482da9d.zip |
[modules] Properly diagnose errors in module files for which we have no
corresponding include location (those specified on the command line).
llvm-svn: 244538
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Frontend/DiagnosticRenderer.cpp | 13 | ||||
-rw-r--r-- | clang/lib/Frontend/TextDiagnostic.cpp | 6 |
2 files changed, 10 insertions, 9 deletions
diff --git a/clang/lib/Frontend/DiagnosticRenderer.cpp b/clang/lib/Frontend/DiagnosticRenderer.cpp index fe62c2a5044..46bef1937a7 100644 --- a/clang/lib/Frontend/DiagnosticRenderer.cpp +++ b/clang/lib/Frontend/DiagnosticRenderer.cpp @@ -245,7 +245,7 @@ void DiagnosticRenderer::emitIncludeStackRecursively(SourceLocation Loc, // import stack rather than the // FIXME: We want submodule granularity here. std::pair<SourceLocation, StringRef> Imported = SM.getModuleImportLoc(Loc); - if (Imported.first.isValid()) { + if (!Imported.second.empty()) { // This location was imported by a module. Emit the module import stack. emitImportStackRecursively(Imported.first, Imported.second, SM); return; @@ -276,13 +276,11 @@ void DiagnosticRenderer::emitImportStack(SourceLocation Loc, void DiagnosticRenderer::emitImportStackRecursively(SourceLocation Loc, StringRef ModuleName, const SourceManager &SM) { - if (Loc.isInvalid()) { + if (ModuleName.empty()) { return; } PresumedLoc PLoc = SM.getPresumedLoc(Loc, DiagOpts->ShowPresumedLoc); - if (PLoc.isInvalid()) - return; // Emit the other import frames first. std::pair<SourceLocation, StringRef> NextImportLoc @@ -501,8 +499,11 @@ void DiagnosticNoteRenderer::emitImportLocation(SourceLocation Loc, // Generate a note indicating the include location. SmallString<200> MessageStorage; llvm::raw_svector_ostream Message(MessageStorage); - Message << "in module '" << ModuleName << "' imported from " - << PLoc.getFilename() << ':' << PLoc.getLine() << ":"; + Message << "in module '" << ModuleName; + if (!PLoc.isInvalid()) + Message << "' imported from " << PLoc.getFilename() << ':' + << PLoc.getLine(); + Message << ":"; emitNote(Loc, Message.str(), &SM); } diff --git a/clang/lib/Frontend/TextDiagnostic.cpp b/clang/lib/Frontend/TextDiagnostic.cpp index aaf17a98337..ee24c3b1c58 100644 --- a/clang/lib/Frontend/TextDiagnostic.cpp +++ b/clang/lib/Frontend/TextDiagnostic.cpp @@ -875,7 +875,7 @@ void TextDiagnostic::emitDiagnosticLoc(SourceLocation Loc, PresumedLoc PLoc, void TextDiagnostic::emitIncludeLocation(SourceLocation Loc, PresumedLoc PLoc, const SourceManager &SM) { - if (DiagOpts->ShowLocation) + if (DiagOpts->ShowLocation && PLoc.getFilename()) OS << "In file included from " << PLoc.getFilename() << ':' << PLoc.getLine() << ":\n"; else @@ -885,11 +885,11 @@ void TextDiagnostic::emitIncludeLocation(SourceLocation Loc, void TextDiagnostic::emitImportLocation(SourceLocation Loc, PresumedLoc PLoc, StringRef ModuleName, const SourceManager &SM) { - if (DiagOpts->ShowLocation) + if (DiagOpts->ShowLocation && PLoc.getFilename()) OS << "In module '" << ModuleName << "' imported from " << PLoc.getFilename() << ':' << PLoc.getLine() << ":\n"; else - OS << "In module " << ModuleName << "':\n"; + OS << "In module '" << ModuleName << "':\n"; } void TextDiagnostic::emitBuildingModuleLocation(SourceLocation Loc, |