diff options
| author | Douglas Gregor <dgregor@apple.com> | 2012-11-30 21:58:49 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2012-11-30 21:58:49 +0000 |
| commit | 22103e3416cfba9780fcd25c9182df5a8acae634 (patch) | |
| tree | 2dbef767b712674939978d25be74c87eb56e604f /clang/lib/Serialization | |
| parent | f505d554725faa8737ac01104518310f53f405c8 (diff) | |
| download | bcm5719-llvm-22103e3416cfba9780fcd25c9182df5a8acae634.tar.gz bcm5719-llvm-22103e3416cfba9780fcd25c9182df5a8acae634.zip | |
When we're emitting a diagnostic with a source location in an imported
module, provide a module import stack similar to what we would get for
an include stack, e.g.,
In module 'DependsOnModule' imported from build-fail-notes.m:4:
In module 'Module' imported from DependsOnModule.framework/Headers/DependsOnModule.h:1:
Inputs/Module.framework/Headers/Module.h:15:12: note: previous definition is here
@interface Module
<rdar://problem/12696425>
llvm-svn: 169042
Diffstat (limited to 'clang/lib/Serialization')
| -rw-r--r-- | clang/lib/Serialization/ASTReader.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index c1428d5c68b..908d8c573c0 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -1000,6 +1000,25 @@ bool ASTReader::ReadSLocEntry(int ID) { return false; } +std::pair<SourceLocation, StringRef> ASTReader::getModuleImportLoc(int ID) { + if (ID == 0) + return std::make_pair(SourceLocation(), ""); + + if (unsigned(-ID) - 2 >= getTotalNumSLocs() || ID > 0) { + Error("source location entry ID out-of-range for AST file"); + return std::make_pair(SourceLocation(), ""); + } + + // Find which module file this entry lands in. + ModuleFile *M = GlobalSLocEntryMap.find(-ID)->second; + if (M->Kind != MK_Module) + return std::make_pair(SourceLocation(), ""); + + // FIXME: Can we map this down to a particular submodule? That would be + // ideal. + return std::make_pair(M->ImportLoc, llvm::sys::path::stem(M->FileName)); +} + /// \brief Find the location where the module F is imported. SourceLocation ASTReader::getImportLocation(ModuleFile *F) { if (F->ImportLoc.isValid()) |

