r176511 - [libclang] When logging a CXTranslationUnit that came from an AST file, print out the filename.
Argyrios Kyrtzidis
akyrtzi at gmail.com
Tue Mar 5 12:21:14 PST 2013
Author: akirtzidis
Date: Tue Mar 5 14:21:14 2013
New Revision: 176511
URL: http://llvm.org/viewvc/llvm-project?rev=176511&view=rev
Log:
[libclang] When logging a CXTranslationUnit that came from an AST file, print out the filename.
Modified:
cfe/trunk/include/clang/Frontend/ASTUnit.h
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/tools/libclang/CIndex.cpp
Modified: cfe/trunk/include/clang/Frontend/ASTUnit.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTUnit.h?rev=176511&r1=176510&r2=176511&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/ASTUnit.h (original)
+++ cfe/trunk/include/clang/Frontend/ASTUnit.h Tue Mar 5 14:21:14 2013
@@ -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() {
Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=176511&r1=176510&r2=176511&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Tue Mar 5 14:21:14 2013
@@ -1711,6 +1711,15 @@ StringRef ASTUnit::getMainFileName() con
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,
Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=176511&r1=176510&r2=176511&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Tue Mar 5 14:21:14 2013
@@ -6387,6 +6387,8 @@ Logger &cxindex::Logger::operator<<(CXTr
if (TU) {
if (ASTUnit *Unit = cxtu::getASTUnit(TU)) {
LogOS << '<' << Unit->getMainFileName() << '>';
+ if (Unit->isMainFileAST())
+ LogOS << " (" << Unit->getASTFileName() << ')';
return *this;
}
}
More information about the cfe-commits
mailing list