<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/122268>122268</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
The SourceLocation of the decl node related to macro extension is invalid. How to obtain the file and line number information according to the decl node?
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
yaqianp
</td>
</tr>
</table>
<pre>
example:
![Image](https://github.com/user-attachments/assets/a4069154-22bd-44ad-bbea-d428c0dd0b06)
`
bool ClangASTVisitor::TraverseDecl(clang::Decl* decl)
{
if (decl == nullptr) {
return true;
}
if (auto* cxxRecordDecl = llvm::dyn_cast<clang::CXXRecordDecl>(decl);
IsTemplateCXXRecordUninstantiated(cxxRecordDecl)) {
return true;
}
const std::string& currFilename =
m_astContext->getSourceManager().getFilename(decl->getEndLoc()).str();
if (decl->getBeginLoc().isInvalid()) {
// How to obtain the file and line number information according to the decl node?
}
}
`
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVMFu4zYQ_RrqQtigKFmWDjo4UYwG2F66abG3xYgcyywo0iVHWefvC4reOLkUPawggILmvZl5j0NCjGZyiD3bPbDdUMBCZx_6N_jHgLsUo9dvPV5hvlhk1YGJA5Ml2z08zzAh2w1MtmeiS0wxeWTyOBk6L-NW-ZnJ4xIxbIAI1HlGR5HJI8SI-aMWTVfu6o2Uo97UNejNOCJsdC1bJbQWo2iY7FLF_DaCicPoveWPFtx0-Pryl4mGfEi1q8NLgFcMEQdUlslWJUyO5D8Hrtd1zbh_YOLAOefmxJlsU4SzamDVwN1i7YUCkx2_w9ITkJbgOIUFWfUzwPbDp0ywkE-11PX6Byof9HBLza19nXM_-s19VxCJVY8funz89u3OYNXTra3UcK72HF9wvlggfIf-6YyLBI4MEOqk-mPZRP0fKu4SlHeReCSdO4oUjJuYbLhaQjgaiw5mXH0SBz5_h0iP3hFeacOqpwnpq1-Cwt_BwYSByZbJbjsh_WTeFN3AT05_8SqjEjDSjZLbSiXum3PjPOBk3Dtra-KzewVr9HuWj2LzPPLf_A9OnvuRwDhOZ-QnY5GD09wah9wt84iBG3fyYQYy3nFQyULjpkRMjHU-nNfIqmNOn01bR2nIw1novtJd1UGBfbmvmlrua9EU574TgAJKLPUJQXTNvtXYtG19akaUCLowvRRyJ0rRlXLX1M0W9vtGV2O760bV6lKyWuAMxm7TDG19mAoT44J9KaVs2sLCiDauB1hKhz_4GmVSpvMc-kTajMsUWS2siRTvaciQxf7ljDxv3RevsgP-9Fk3D5gGTydDZlDBc7wSupiwJnKTt2H7y80ulmD7_7hg1kOVl80l-L9REZPHVX-6Y24Gvfby3wAAAP__YIeGDQ">