<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/97140>97140</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
why VD->dump() show invalid vartype?
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
boluo250
</td>
</tr>
</table>
<pre>
mycode
```
bool Visitor::VisitVarDecl(VarDecl *VD)
{
SourceLocation srcLoc = VD->getLocation();
if (srcMgr.isInSystemHeader(srcMgr.getExpansionLoc(VD->getBeginLoc()))) {
return true;
}
if (srcMgr.getFileCharacteristic(srcLoc) == SrcMgr::C_System ||
srcMgr.getFileCharacteristic(srcLoc) == SrcMgr::C_ExternCSystem) {
return true;
}
// 检查变量是否有初始化表达式
if (!VD->hasInit()) {
VD->dump();
return true;
}
VD->dump();
}
```
'''
'''
print
```
VarDecl 0x55d65df37a68 </root/h30038243/k30056123/test/tmp_case5/e.cpp:16:2, col:14> col:14 invalid s2 'std::string':'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >'
s2
VarDecl 0x55d65df37b18 </root/h30038243/k30056123/test/tmp_case5/e.cpp:17:2, col:9> col:9 invalid s1 'std::string':'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >'
s1
VarDecl 0x55d65df37ba8 </root/h30038243/k30056123/test/tmp_case5/e.cpp:18:2, col:9> col:9 invalid s3 'std::string':'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >'
s3
```
my analyze code
```
#include "e.h"
#include <memory>
#include <string>
int main(int argc, const char *argv[]){
std::string s2 = "abc";
string s1 = func();
string s3 = "a";
int a = 1;
int b = func2();
int64_t c = 2;
return 0;
}
```
why VD->dump() show string invalid vartype? but int type show no invalid
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMVl1vqzgQ_TWTF-tGxubDPPBAAmiv1H2q1NfIGB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