lebedev.ri created this revision.
lebedev.ri added reviewers: aaron.ballman, steveire.
lebedev.ri added projects: OpenMP, clang.
Herald added a subscriber: guansong.

Was trying to understand how complicated it would be to write
a clang-tidy `openmp-exception-escape`-ish check once D57100 
<https://reviews.llvm.org/D57100> lands.

Just so it happens, all the data is already there,
it is just conveniently omitted from AST dump.


Repository:
  rC Clang

https://reviews.llvm.org/D57452

Files:
  lib/AST/ASTDumper.cpp
  test/AST/dump.cpp


Index: test/AST/dump.cpp
===================================================================
--- test/AST/dump.cpp
+++ test/AST/dump.cpp
@@ -61,7 +61,7 @@
 // CHECK-NEXT: |       | `-ImplicitCastExpr {{.+}} <col:78> 'int' 
<LValueToRValue>
 // CHECK-NEXT: |       |   `-DeclRefExpr {{.+}} <col:78> 'int' lvalue 
OMPCapturedExpr {{.+}} '.capture_expr.' 'int'
 // CHECK-NEXT: |       `-CapturedStmt {{.+}} <line:[[@LINE-15]]:5, 
line:[[@LINE-14]]:9>
-// CHECK-NEXT: |         |-CapturedDecl {{.+}} <<invalid sloc>> <invalid sloc>
+// CHECK-NEXT: |         |-CapturedDecl {{.+}} <<invalid sloc>> <invalid sloc> 
nothrow
 // CHECK-NEXT: |         | |-ForStmt {{.+}} <line:[[@LINE-17]]:5, 
line:[[@LINE-16]]:9>
 // CHECK:      |         | | `-UnaryOperator {{.+}} <line:[[@LINE-17]]:7, 
col:9> 'int' lvalue prefix '++'
 // CHECK-NEXT: |         | |   `-DeclRefExpr {{.+}} <col:9> 'int' lvalue 
OMPCapturedExpr {{.+}} 'a' 'int &'
Index: lib/AST/ASTDumper.cpp
===================================================================
--- lib/AST/ASTDumper.cpp
+++ lib/AST/ASTDumper.cpp
@@ -727,6 +727,8 @@
 }
 
 void ASTDumper::VisitCapturedDecl(const CapturedDecl *D) {
+  if (D->isNothrow())
+    OS << " nothrow";
   dumpStmt(D->getBody());
 }
 


Index: test/AST/dump.cpp
===================================================================
--- test/AST/dump.cpp
+++ test/AST/dump.cpp
@@ -61,7 +61,7 @@
 // CHECK-NEXT: |       | `-ImplicitCastExpr {{.+}} <col:78> 'int' <LValueToRValue>
 // CHECK-NEXT: |       |   `-DeclRefExpr {{.+}} <col:78> 'int' lvalue OMPCapturedExpr {{.+}} '.capture_expr.' 'int'
 // CHECK-NEXT: |       `-CapturedStmt {{.+}} <line:[[@LINE-15]]:5, line:[[@LINE-14]]:9>
-// CHECK-NEXT: |         |-CapturedDecl {{.+}} <<invalid sloc>> <invalid sloc>
+// CHECK-NEXT: |         |-CapturedDecl {{.+}} <<invalid sloc>> <invalid sloc> nothrow
 // CHECK-NEXT: |         | |-ForStmt {{.+}} <line:[[@LINE-17]]:5, line:[[@LINE-16]]:9>
 // CHECK:      |         | | `-UnaryOperator {{.+}} <line:[[@LINE-17]]:7, col:9> 'int' lvalue prefix '++'
 // CHECK-NEXT: |         | |   `-DeclRefExpr {{.+}} <col:9> 'int' lvalue OMPCapturedExpr {{.+}} 'a' 'int &'
Index: lib/AST/ASTDumper.cpp
===================================================================
--- lib/AST/ASTDumper.cpp
+++ lib/AST/ASTDumper.cpp
@@ -727,6 +727,8 @@
 }
 
 void ASTDumper::VisitCapturedDecl(const CapturedDecl *D) {
+  if (D->isNothrow())
+    OS << " nothrow";
   dumpStmt(D->getBody());
 }
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to