[PATCH] D155383: [clang][AST] TextNodeDumper learned to output exception specifications
Timo Stripf via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 10 04:06:35 PDT 2023
strimo378 updated this revision to Diff 548964.
strimo378 added a comment.
Added test cases and applied review comments.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D155383/new/
https://reviews.llvm.org/D155383
Files:
clang/lib/AST/TextNodeDumper.cpp
clang/test/AST/ast-dump-functionprototype.cpp
Index: clang/test/AST/ast-dump-functionprototype.cpp
===================================================================
--- /dev/null
+++ clang/test/AST/ast-dump-functionprototype.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -std=c++17 -Wno-dynamic-exception-spec -ast-dump %s | FileCheck -strict-whitespace %s
+
+struct A {};
+struct B {};
+
+typedef void (type1)() noexcept(10 > 5);
+
+// CHECK: TypedefDecl {{.*}} type1 'void () noexcept(10 > 5)':'void () noexcept(10 > 5)'
+// CHECK-NEXT: `-ParenType {{.*}}
+// CHECK-NEXT: `-FunctionProtoType {{.*}} 'void () noexcept(10 > 5)' exceptionspec_noexcept_true cdecl
+// CHECK-NEXT: |-NoexceptExpr: ConstantExpr {{.*}} 'bool'
+// CHECK-NEXT: | `-value: Int 1
+// CHECK-NEXT: `-BuiltinType {{.*}} 'void'
+
+typedef void (type2)() throw(A, B);
+
+// CHECK: TypedefDecl {{.*}} type2 'void () throw(A, B)':'void () throw(A, B)'
+// CHECK-NEXT: `-ParenType {{.*}}
+// CHECK-NEXT: `-FunctionProtoType {{.*}} 'void () throw(A, B)' exceptionspec_dynamic cdecl
+// CHECK-NEXT: |-Exceptions: 'A':'A', 'B':'B'
+// CHECK-NEXT: `-BuiltinType {{.*}} 'void'
+
Index: clang/lib/AST/TextNodeDumper.cpp
===================================================================
--- clang/lib/AST/TextNodeDumper.cpp
+++ clang/lib/AST/TextNodeDumper.cpp
@@ -1541,7 +1541,64 @@
OS << " &&";
break;
}
- // FIXME: Exception specification.
+
+ switch (EPI.ExceptionSpec.Type) {
+ case EST_None:
+ break;
+ case EST_DynamicNone:
+ OS << " exceptionspec_dynamic_none";
+ break;
+ case EST_Dynamic:
+ OS << " exceptionspec_dynamic";
+ break;
+ case EST_MSAny:
+ OS << " exceptionspec_ms_any";
+ break;
+ case EST_NoThrow:
+ OS << " exceptionspec_nothrow";
+ break;
+ case EST_BasicNoexcept:
+ OS << " exceptionspec_basic_noexcept";
+ break;
+ case EST_DependentNoexcept:
+ OS << " exceptionspec_dependent_noexcept";
+ break;
+ case EST_NoexceptFalse:
+ OS << " exceptionspec_noexcept_false";
+ break;
+ case EST_NoexceptTrue:
+ OS << " exceptionspec_noexcept_true";
+ break;
+ case EST_Unevaluated:
+ OS << " exceptionspec_unevaluated";
+ break;
+ case EST_Uninstantiated:
+ OS << " exceptionspec_uninstantiated";
+ break;
+ case EST_Unparsed:
+ OS << " exceptionspec_unparsed";
+ break;
+ }
+ if (!EPI.ExceptionSpec.Exceptions.empty()) {
+ AddChild([=] {
+ OS << "Exceptions:";
+ for (unsigned I = 0, N = EPI.ExceptionSpec.Exceptions.size(); I != N;
+ ++I) {
+ if (I)
+ OS << ",";
+ dumpType(EPI.ExceptionSpec.Exceptions[I]);
+ }
+ });
+ }
+ if (EPI.ExceptionSpec.NoexceptExpr) {
+ AddChild([=] {
+ OS << "NoexceptExpr: ";
+ Visit(EPI.ExceptionSpec.NoexceptExpr);
+ });
+ }
+ dumpDeclRef(EPI.ExceptionSpec.SourceDecl, "ExceptionSourceDecl");
+ dumpDeclRef(EPI.ExceptionSpec.SourceTemplate, "ExceptionSourceTemplate");
+
// FIXME: Consumed parameters.
VisitFunctionType(T);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155383.548964.patch
Type: text/x-patch
Size: 3033 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230810/19493b51/attachment.bin>
More information about the cfe-commits
mailing list