[cfe-dev] AST bug parsing tags.cpp file?
David Rector via cfe-dev
cfe-dev at lists.llvm.org
Wed Jul 29 17:27:55 PDT 2020
I think you are not distinguishing properly between the declaration of the destructor and its usage (via a CXXMemberCallExpr) within the implementation/"body" of some other method declaration (this body should be enclosed in a "CompoundStmt").
For example, the dump of
```
struct ColorTag {
~ColorTag() {}
void destroy() {
ColorTag::~ColorTag();
}
};
```
looks like this:
```
TranslationUnitDecl
`-CXXRecordDecl <line:1:1, line:5:1> line:1:8 struct ColorTag definition
...(Definition data, implicitly-generated declarations)...
|-CXXDestructorDecl <line:2:5, col:18> col:5 used ~ColorTag 'void () noexcept'
|-CXXMethodDecl <line:2:5, line:4:5> line:2:10 destroy 'void ()'
| `-CompoundStmt <col:20, line:4:5>
| `-CXXMemberCallExpr <line:3:9, col:29> 'void'
| `-MemberExpr <col:9, col:20> '<bound member function type>' ->~ColorTag 0x55790cbbaa40
| `-CXXThisExpr <col:19> 'ColorTag *' implicit this
...
```
Hope that helps, good luck,
Dave
> On Jul 29, 2020, at 10:40 AM, Billy Araujo via cfe-dev <cfe-dev at lists.llvm.org> wrote:
>
> Hi,
>
> On project opentoonz there is a file called:
> opentoonz/toonz/sources/image/pli/tags.cp
>
> If I run clang-check, the AST it builds seems wrong.
>
> clang-check -ast-dump /home/opentoonz/toonz/sources/image/pli/tags.cpp | grep -B 1 -A 1 "~ColorTag"
>
> |-CXXMemberCallExpr 0x22893e8 <line:253:1, col:21> 'void'
> | `-MemberExpr 0x22893a0 <col:1, col:12> '<bound member function type>' ->~ColorTag 0x2274c00
> | `-CXXThisExpr 0x2289390 <col:11> 'ColorTag *' implicit this
>
> Line 253 appears as a CXXMemberCallExpr instead of a CXXDestructorDecl.
>
> So the AST thinks it is calling an explicit destructor method call although it is a destructor implementation.
>
> clang-check --version
> LLVM (http://llvm.org/ <http://llvm.org/>):
> LLVM version 10.0.0
>
> Optimized build.
> Default target: x86_64-pc-linux-gnu
> Host CPU: nehalem
>
> Is this a bug or am I missing something?
>
> Regards,
>
> Billy.
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200729/9a528d42/attachment.html>
More information about the cfe-dev
mailing list