ast-dump-stmt.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // RUN: %clang_cc1 -fcxx-exceptions -ast-dump -ast-dump-filter Test %s | FileCheck -strict-whitespace %s
  2. namespace n {
  3. void function() {}
  4. int Variable;
  5. }
  6. using n::function;
  7. using n::Variable;
  8. void TestFunction() {
  9. void (*f)() = &function;
  10. // CHECK: DeclRefExpr{{.*}} (UsingShadow{{.*}}function
  11. Variable = 4;
  12. // CHECK: DeclRefExpr{{.*}} (UsingShadow{{.*}}Variable
  13. }
  14. // CHECK: FunctionDecl {{.*}} TestCatch1
  15. void TestCatch1() {
  16. // CHECK: CXXTryStmt
  17. // CHECK-NEXT: CompoundStmt
  18. try {
  19. }
  20. // CHECK-NEXT: CXXCatchStmt
  21. // CHECK-NEXT: VarDecl {{.*}} x
  22. // CHECK-NEXT: CompoundStmt
  23. catch (int x) {
  24. }
  25. }
  26. // CHECK: FunctionDecl {{.*}} TestCatch2
  27. void TestCatch2() {
  28. // CHECK: CXXTryStmt
  29. // CHECK-NEXT: CompoundStmt
  30. try {
  31. }
  32. // CHECK-NEXT: CXXCatchStmt
  33. // CHECK-NEXT: NULL
  34. // CHECK-NEXT: CompoundStmt
  35. catch (...) {
  36. }
  37. }
  38. void TestAllocationExprs() {
  39. int *p;
  40. p = new int;
  41. delete p;
  42. p = new int[2];
  43. delete[] p;
  44. p = ::new int;
  45. ::delete p;
  46. }
  47. // CHECK: FunctionDecl {{.*}} TestAllocationExprs
  48. // CHECK: CXXNewExpr {{.*}} 'int *' Function {{.*}} 'operator new'
  49. // CHECK: CXXDeleteExpr {{.*}} 'void' Function {{.*}} 'operator delete'
  50. // CHECK: CXXNewExpr {{.*}} 'int *' array Function {{.*}} 'operator new[]'
  51. // CHECK: CXXDeleteExpr {{.*}} 'void' array Function {{.*}} 'operator delete[]'
  52. // CHECK: CXXNewExpr {{.*}} 'int *' global Function {{.*}} 'operator new'
  53. // CHECK: CXXDeleteExpr {{.*}} 'void' global Function {{.*}} 'operator delete'
  54. // Don't crash on dependent exprs that haven't been resolved yet.
  55. template <typename T>
  56. void TestDependentAllocationExpr() {
  57. T *p = new T;
  58. delete p;
  59. }
  60. // CHECK: FunctionTemplateDecl {{.*}} TestDependentAllocationExpr
  61. // CHECK: CXXNewExpr {{.*'T \*'$}}
  62. // CHECK: CXXDeleteExpr {{.*'void'$}}