[PATCH] D157795: [clang] Add missing field to SectionAttr json AST dump

serge via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 14 14:01:35 PDT 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4cf7666b8f09: [clang] Add missing field to SectionAttr json AST dump (authored by serge-sans-paille).

Changed prior to commit:
  https://reviews.llvm.org/D157795?vs=549646&id=550078#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157795/new/

https://reviews.llvm.org/D157795

Files:
  clang/include/clang/AST/JSONNodeDumper.h
  clang/lib/AST/JSONNodeDumper.cpp
  clang/test/AST/ast-dump-attr-json.cpp


Index: clang/test/AST/ast-dump-attr-json.cpp
===================================================================
--- clang/test/AST/ast-dump-attr-json.cpp
+++ clang/test/AST/ast-dump-attr-json.cpp
@@ -15,6 +15,8 @@
 __attribute__((unavailable)) int unavailable_var0;
 __attribute__((unavailable("reason"))) int unavailable_var1;
 
+__attribute__ ((section ("SECTION_NAME"))) int section_var;
+
 // NOTE: CHECK lines have been autogenerated by gen_ast_dump_json_test.py
 // using --filters=VarDecl
 
@@ -380,3 +382,50 @@
 // CHECK-NEXT:   }
 // CHECK-NEXT:  ]
 // CHECK-NEXT: }
+
+
+// CHECK-NOT: {{^}}Dumping
+// CHECK:  "kind": "VarDecl",
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "offset": 593,
+// CHECK-NEXT:   "line": 18,
+// CHECK-NEXT:   "col": 48,
+// CHECK-NEXT:   "tokLen": 11
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:    "offset": 546,
+// CHECK-NEXT:    "col": 1,
+// CHECK-NEXT:    "tokLen": 13
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:    "offset": 593,
+// CHECK-NEXT:    "col": 48,
+// CHECK-NEXT:    "tokLen": 11
+// CHECK-NEXT:   }
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "name": "section_var",
+// CHECK-NEXT:  "mangledName": "section_var",
+// CHECK-NEXT:  "type": {
+// CHECK-NEXT:   "qualType": "int"
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "inner": [
+// CHECK-NEXT:   {
+// CHECK-NEXT:    "id": "0x{{.*}}",
+// CHECK-NEXT:    "kind": "SectionAttr",
+// CHECK-NEXT:    "range": {
+// CHECK-NEXT:     "begin": {
+// CHECK-NEXT:      "offset": 562,
+// CHECK-NEXT:      "col": 17,
+// CHECK-NEXT:      "tokLen": 7
+// CHECK-NEXT:     },
+// CHECK-NEXT:     "end": {
+// CHECK-NEXT:      "offset": 585,
+// CHECK-NEXT:      "col": 40,
+// CHECK-NEXT:      "tokLen": 1
+// CHECK-NEXT:     }
+// CHECK-NEXT:    },
+// CHECK-NEXT:    "section_name": "SECTION_NAME"
+// CHECK-NEXT:   }
+// CHECK-NEXT:  ]
+// CHECK-NEXT: }
Index: clang/lib/AST/JSONNodeDumper.cpp
===================================================================
--- clang/lib/AST/JSONNodeDumper.cpp
+++ clang/lib/AST/JSONNodeDumper.cpp
@@ -550,6 +550,10 @@
     JOS.attribute("message", UA->getMessage());
 }
 
+void JSONNodeDumper::VisitSectionAttr(const SectionAttr *SA) {
+  JOS.attribute("section_name", SA->getName());
+}
+
 void JSONNodeDumper::VisitTypedefType(const TypedefType *TT) {
   JOS.attribute("decl", createBareDeclRef(TT->getDecl()));
   if (!TT->typeMatchesDecl())
Index: clang/include/clang/AST/JSONNodeDumper.h
===================================================================
--- clang/include/clang/AST/JSONNodeDumper.h
+++ clang/include/clang/AST/JSONNodeDumper.h
@@ -212,6 +212,7 @@
   void VisitCleanupAttr(const CleanupAttr *CA);
   void VisitDeprecatedAttr(const DeprecatedAttr *DA);
   void VisitUnavailableAttr(const UnavailableAttr *UA);
+  void VisitSectionAttr(const SectionAttr *SA);
 
   void VisitTypedefType(const TypedefType *TT);
   void VisitUsingType(const UsingType *TT);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157795.550078.patch
Type: text/x-patch
Size: 2970 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230814/fd6a6407/attachment-0001.bin>


More information about the cfe-commits mailing list