Skip to content

Commit 3f06999

Browse files
Becca Royal-GordonBecca Royal-Gordon
authored andcommitted
[NFC] Print clang location of imported decls
…in DeclContext::dumpContext(). This makes the dumps more usable since these declarations otherwise don’t have usable filenames or line numbers.
1 parent c1534d5 commit 3f06999

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/AST/DeclContext.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "llvm/ADT/Statistic.h"
3131
#include "llvm/Support/raw_ostream.h"
3232
#include "llvm/Support/SaveAndRestore.h"
33+
#include "clang/AST/ASTContext.h"
3334
using namespace swift;
3435

3536
#define DEBUG_TYPE "Name lookup"
@@ -734,6 +735,14 @@ unsigned DeclContext::printContext(raw_ostream &OS, const unsigned indent,
734735
}
735736
}
736737

738+
if (auto decl = getAsDecl())
739+
if (decl->getClangNode().getLocation().isValid()) {
740+
auto &clangSM = getASTContext().getClangModuleLoader()
741+
->getClangASTContext().getSourceManager();
742+
OS << " clang_loc=";
743+
decl->getClangNode().getLocation().print(OS, clangSM);
744+
}
745+
737746
if (!onlyAPartialLine)
738747
OS << "\n";
739748
return Depth + 1;

0 commit comments

Comments
 (0)