[cfe-dev] Crash in TagType::getAsString()
Alexei Svitkine
alexei.svitkine at gmail.com
Tue Jan 13 13:55:37 PST 2009
I have the following input:
int main(void)
{
struct X { int a, b; };
struct X x;
x;
return 0;
}
Which becomes:
(CompoundStmt 0x1c087c0
(DeclStmt 0x1c086f0
0x1c08580 "struct X;"
(DeclStmt 0x1c08740
0x1c08710 "struct X x"
(DeclRefExpr 0x1c08770 'struct X' Var='x' 0x1c08710)
(ReturnStmt 0x1c087b0
(IntegerLiteral 0x1c08790 'int' 0)))
Now when I take the DeclRefExpr and call getType().getAsString(), I get a crash:
clang::TagType::getAsStringInternal (this=0x1c0a080,
InnerString=@0xbffff62c) at Type.cpp:1148
It seems that "getDecl()->getIdentifier()->getName()" on TagType
returns something invalid.
Interestingly, the dump shows "struct X" just fine, so perhaps it's
another user error on my part... though this time I am retaining the
AST and I am getting correct results with other inputs...
-Alexei
More information about the cfe-dev
mailing list