This is an archive of the discontinued LLVM Phabricator instance.

[clang][AST] TextNodeDumper learned to output exception specifications
ClosedPublic

Authored by strimo378 on Jul 15 2023, 2:19 PM.

Details

Summary

Extended TextNodeDumper::VisitFunctionProtoType to output exception specifications

Diff Detail

Event Timeline

strimo378 created this revision.Jul 15 2023, 2:19 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 15 2023, 2:19 PM
strimo378 requested review of this revision.Jul 15 2023, 2:19 PM
shafik added a subscriber: shafik.Jul 17 2023, 1:46 PM

I think we at least need some tests for this, looks like we have the AST tests in clang/test/AST/ast-dump*

There are many ast-dump tests about decls but there are nearly no other type tests.

There are many ast-dump tests about decls but there are nearly no other type tests.

We should still be adding tests for these changes, to ensure we don't regress the behavior later by accident. It also helps the code reviewers to see what the output looks like and whether we spot any concerns with it.

clang/lib/AST/TextNodeDumper.cpp
1549
1555
1561
1564
1567
1570
strimo378 updated this revision to Diff 548964.Aug 10 2023, 4:06 AM

Added test cases and applied review comments.

I added a test case for demonstrating NoexceptExpr and Exceptions output. I don't know how to produce a FunctionProtoType output with ExceptionSourceDecl and ExceptionSourceTemplate. typedef/using is the only way I know to output types for the current AST dump and all my attempts failed to produce an uninstantiated exception information within a typedef.

Here is an example from my (slightly extended) AST dump where I output every type stored within ASTContext:

FunctionProtoType #267 0x20c10fd58a0 'void ()' (canonical FunctionProtoType #210 0x20c10fd6580) exceptionspec_uninstantiated
|-ExceptionSourceDecl CXXConstructor 0x20c10fd5798 #266 'e' 'void () noexcept(b<__is_same(d<>, d<>)>::c && b<__is_same(d<>, d<>)>::c)'#286 cdecl
|-ExceptionSourceTemplate CXXConstructor 0x20c10fd6608 #212 'e' 'void () noexcept(b<__is_same(d<>, d<>)>::c && b<__is_same(d<>, d<f::c...>)>::c)'#251
`-BuiltinType #2 0x20c0f5bf7f0 'void'
aaron.ballman accepted this revision.Aug 10 2023, 5:37 AM

I added a test case for demonstrating NoexceptExpr and Exceptions output. I don't know how to produce a FunctionProtoType output with ExceptionSourceDecl and ExceptionSourceTemplate. typedef/using is the only way I know to output types for the current AST dump and all my attempts failed to produce an uninstantiated exception information within a typedef.

Here is an example from my (slightly extended) AST dump where I output every type stored within ASTContext:

FunctionProtoType #267 0x20c10fd58a0 'void ()' (canonical FunctionProtoType #210 0x20c10fd6580) exceptionspec_uninstantiated
|-ExceptionSourceDecl CXXConstructor 0x20c10fd5798 #266 'e' 'void () noexcept(b<__is_same(d<>, d<>)>::c && b<__is_same(d<>, d<>)>::c)'#286 cdecl
|-ExceptionSourceTemplate CXXConstructor 0x20c10fd6608 #212 'e' 'void () noexcept(b<__is_same(d<>, d<>)>::c && b<__is_same(d<>, d<f::c...>)>::c)'#251
`-BuiltinType #2 0x20c0f5bf7f0 'void'

Then I'd say lets move forward with what you've got -- I recall running into similar issues when working on the JSON node dumper.

This revision is now accepted and ready to land.Aug 10 2023, 5:37 AM