[clang] 11f3286 - [clang] Add aliasee field to AliasAttr json AST dump

via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 14 14:00:09 PDT 2023


Author: serge-sans-paille
Date: 2023-08-14T22:59:40+02:00
New Revision: 11f3286585ce86df8107617536226dea24e74d94

URL: https://github.com/llvm/llvm-project/commit/11f3286585ce86df8107617536226dea24e74d94
DIFF: https://github.com/llvm/llvm-project/commit/11f3286585ce86df8107617536226dea24e74d94.diff

LOG: [clang] Add aliasee field to AliasAttr json AST dump

Differential Revision: https://reviews.llvm.org/D157775

Added: 
    clang/test/AST/ast-dump-attr-json.cpp

Modified: 
    clang/include/clang/AST/JSONNodeDumper.h
    clang/lib/AST/JSONNodeDumper.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/AST/JSONNodeDumper.h b/clang/include/clang/AST/JSONNodeDumper.h
index 5e2756f2a20317..c465137187cba4 100644
--- a/clang/include/clang/AST/JSONNodeDumper.h
+++ b/clang/include/clang/AST/JSONNodeDumper.h
@@ -208,6 +208,8 @@ class JSONNodeDumper
   void Visit(const concepts::Requirement *R);
   void Visit(const APValue &Value, QualType Ty);
 
+  void VisitAliasAttr(const AliasAttr *AA);
+
   void VisitTypedefType(const TypedefType *TT);
   void VisitUsingType(const UsingType *TT);
   void VisitFunctionType(const FunctionType *T);

diff  --git a/clang/lib/AST/JSONNodeDumper.cpp b/clang/lib/AST/JSONNodeDumper.cpp
index 958b0e6cf2ef6c..318e7d22db4567 100644
--- a/clang/lib/AST/JSONNodeDumper.cpp
+++ b/clang/lib/AST/JSONNodeDumper.cpp
@@ -530,6 +530,10 @@ JSONNodeDumper::createCXXBaseSpecifier(const CXXBaseSpecifier &BS) {
   return Ret;
 }
 
+void JSONNodeDumper::VisitAliasAttr(const AliasAttr *AA) {
+  JOS.attribute("aliasee", AA->getAliasee());
+}
+
 void JSONNodeDumper::VisitTypedefType(const TypedefType *TT) {
   JOS.attribute("decl", createBareDeclRef(TT->getDecl()));
   if (!TT->typeMatchesDecl())

diff  --git a/clang/test/AST/ast-dump-attr-json.cpp b/clang/test/AST/ast-dump-attr-json.cpp
new file mode 100644
index 00000000000000..40a49e0cab9490
--- /dev/null
+++ b/clang/test/AST/ast-dump-attr-json.cpp
@@ -0,0 +1,84 @@
+// RUN: %clang_cc1 -Wdocumentation -ast-dump=json %s | FileCheck %s
+
+int global_decl;
+extern __attribute__((alias("global_decl"))) int global_alias;
+
+// NOTE: CHECK lines have been autogenerated by gen_ast_dump_json_test.py
+// using --filters=VarDecl
+
+
+// CHECK-NOT: {{^}}Dumping
+// CHECK:  "kind": "VarDecl",
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "offset": 73,
+// CHECK-NEXT:   "file": "{{.*}}",
+// CHECK-NEXT:   "line": 3,
+// CHECK-NEXT:   "col": 5,
+// CHECK-NEXT:   "tokLen": 11
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:    "offset": 69,
+// CHECK-NEXT:    "col": 1,
+// CHECK-NEXT:    "tokLen": 3
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:    "offset": 73,
+// CHECK-NEXT:    "col": 5,
+// CHECK-NEXT:    "tokLen": 11
+// CHECK-NEXT:   }
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "name": "global_decl",
+// CHECK-NEXT:  "mangledName": "global_decl",
+// CHECK-NEXT:  "type": {
+// CHECK-NEXT:   "qualType": "int"
+// CHECK-NEXT:  }
+// CHECK-NEXT: }
+
+
+// CHECK-NOT: {{^}}Dumping
+// CHECK:  "kind": "VarDecl",
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "offset": 135,
+// CHECK-NEXT:   "line": 4,
+// CHECK-NEXT:   "col": 50,
+// CHECK-NEXT:   "tokLen": 12
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:    "offset": 86,
+// CHECK-NEXT:    "col": 1,
+// CHECK-NEXT:    "tokLen": 6
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:    "offset": 135,
+// CHECK-NEXT:    "col": 50,
+// CHECK-NEXT:    "tokLen": 12
+// CHECK-NEXT:   }
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "name": "global_alias",
+// CHECK-NEXT:  "mangledName": "global_alias",
+// CHECK-NEXT:  "type": {
+// CHECK-NEXT:   "qualType": "int"
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "storageClass": "extern",
+// CHECK-NEXT:  "inner": [
+// CHECK-NEXT:   {
+// CHECK-NEXT:    "id": "0x{{.*}}",
+// CHECK-NEXT:    "kind": "AliasAttr",
+// CHECK-NEXT:    "range": {
+// CHECK-NEXT:     "begin": {
+// CHECK-NEXT:      "offset": 108,
+// CHECK-NEXT:      "col": 23,
+// CHECK-NEXT:      "tokLen": 5
+// CHECK-NEXT:     },
+// CHECK-NEXT:     "end": {
+// CHECK-NEXT:      "offset": 127,
+// CHECK-NEXT:      "col": 42,
+// CHECK-NEXT:      "tokLen": 1
+// CHECK-NEXT:     }
+// CHECK-NEXT:    },
+// CHECK-NEXT:    "decl": "global_decl"
+// CHECK-NEXT:   }
+// CHECK-NEXT:  ]
+// CHECK-NEXT: }


        


More information about the cfe-commits mailing list