[libclang] When logging a CXTranslationUnit that came from an AST file, print out the filename.

llvm-svn: 176511
This commit is contained in:
Argyrios Kyrtzidis 2013-03-05 20:21:14 +00:00
parent 43c8df8153
commit 37f2ab4824
3 changed files with 14 additions and 0 deletions

View File

@ -485,6 +485,9 @@ public:
StringRef getMainFileName() const;
/// \brief If this ASTUnit came from an AST file, returns the filename for it.
StringRef getASTFileName() const;
typedef std::vector<Decl *>::iterator top_level_iterator;
top_level_iterator top_level_begin() {

View File

@ -1711,6 +1711,15 @@ StringRef ASTUnit::getMainFileName() const {
return StringRef();
}
StringRef ASTUnit::getASTFileName() const {
if (!isMainFileAST())
return StringRef();
serialization::ModuleFile &
Mod = Reader->getModuleManager().getPrimaryModule();
return Mod.FileName;
}
ASTUnit *ASTUnit::create(CompilerInvocation *CI,
IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
bool CaptureDiagnostics,

View File

@ -6387,6 +6387,8 @@ Logger &cxindex::Logger::operator<<(CXTranslationUnit TU) {
if (TU) {
if (ASTUnit *Unit = cxtu::getASTUnit(TU)) {
LogOS << '<' << Unit->getMainFileName() << '>';
if (Unit->isMainFileAST())
LogOS << " (" << Unit->getASTFileName() << ')';
return *this;
}
}