[clang] 422bcd1 - [clang][ExtractAPI] Add semicolons to vars and fields and to test reference JSON

Erick Velez via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 31 23:29:25 PDT 2023


Author: Erick Velez
Date: 2023-07-31T23:29:04-07:00
New Revision: 422bcd10c48bac9042ed9f33f3d17eb81ebfd21a

URL: https://github.com/llvm/llvm-project/commit/422bcd10c48bac9042ed9f33f3d17eb81ebfd21a
DIFF: https://github.com/llvm/llvm-project/commit/422bcd10c48bac9042ed9f33f3d17eb81ebfd21a.diff

LOG: [clang][ExtractAPI] Add semicolons to vars and fields and to test reference JSON

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

Added: 
    

Modified: 
    clang/lib/ExtractAPI/DeclarationFragments.cpp
    clang/test/ExtractAPI/anonymous_record_no_typedef.c
    clang/test/ExtractAPI/global_record.c
    clang/test/ExtractAPI/global_record_multifile.c
    clang/test/ExtractAPI/known_files_only.c
    clang/test/ExtractAPI/language.c
    clang/test/ExtractAPI/objc_interface.m
    clang/test/ExtractAPI/relative_include.m
    clang/test/ExtractAPI/struct.c
    clang/test/ExtractAPI/typedef_struct_enum.c
    clang/test/ExtractAPI/underscored.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/ExtractAPI/DeclarationFragments.cpp b/clang/lib/ExtractAPI/DeclarationFragments.cpp
index 1e52f221c7982d..20335768ac30b0 100644
--- a/clang/lib/ExtractAPI/DeclarationFragments.cpp
+++ b/clang/lib/ExtractAPI/DeclarationFragments.cpp
@@ -389,7 +389,8 @@ DeclarationFragmentsBuilder::getFragmentsForVar(const VarDecl *Var) {
   return Fragments.append(getFragmentsForType(T, Var->getASTContext(), After))
       .appendSpace()
       .append(Var->getName(), DeclarationFragments::FragmentKind::Identifier)
-      .append(std::move(After));
+      .append(std::move(After))
+      .append(";", DeclarationFragments::FragmentKind::Text);
 }
 
 DeclarationFragments
@@ -495,7 +496,8 @@ DeclarationFragmentsBuilder::getFragmentsForField(const FieldDecl *Field) {
   return getFragmentsForType(Field->getType(), Field->getASTContext(), After)
       .appendSpace()
       .append(Field->getName(), DeclarationFragments::FragmentKind::Identifier)
-      .append(std::move(After));
+      .append(std::move(After))
+      .append(";", DeclarationFragments::FragmentKind::Text);
 }
 
 DeclarationFragments

diff  --git a/clang/test/ExtractAPI/anonymous_record_no_typedef.c b/clang/test/ExtractAPI/anonymous_record_no_typedef.c
index 880a42c30ceb8d..0890e3cbdb6d08 100644
--- a/clang/test/ExtractAPI/anonymous_record_no_typedef.c
+++ b/clang/test/ExtractAPI/anonymous_record_no_typedef.c
@@ -316,6 +316,10 @@ struct Vehicle {
         {
           "kind": "identifier",
           "spelling": "type"
+        },
+        {
+          "kind": "text",
+          "spelling": ";"
         }
       ],
       "identifier": {
@@ -367,6 +371,10 @@ struct Vehicle {
         {
           "kind": "identifier",
           "spelling": "information"
+        },
+        {
+          "kind": "text",
+          "spelling": ";"
         }
       ],
       "identifier": {

diff  --git a/clang/test/ExtractAPI/global_record.c b/clang/test/ExtractAPI/global_record.c
index 7ca89875d66ae5..c287c791d947e6 100644
--- a/clang/test/ExtractAPI/global_record.c
+++ b/clang/test/ExtractAPI/global_record.c
@@ -68,6 +68,10 @@ char unavailable __attribute__((unavailable));
         {
           "kind": "identifier",
           "spelling": "num"
+        },
+        {
+          "kind": "text",
+          "spelling": ";"
         }
       ],
       "identifier": {

diff  --git a/clang/test/ExtractAPI/global_record_multifile.c b/clang/test/ExtractAPI/global_record_multifile.c
index b1e9f9ed21d425..fd4022fada6a04 100644
--- a/clang/test/ExtractAPI/global_record_multifile.c
+++ b/clang/test/ExtractAPI/global_record_multifile.c
@@ -70,6 +70,10 @@ char unavailable __attribute__((unavailable));
         {
           "kind": "identifier",
           "spelling": "num"
+        },
+        {
+          "kind": "text",
+          "spelling": ";"
         }
       ],
       "identifier": {

diff  --git a/clang/test/ExtractAPI/known_files_only.c b/clang/test/ExtractAPI/known_files_only.c
index ddb6e577823a85..1e51139c0cae4b 100644
--- a/clang/test/ExtractAPI/known_files_only.c
+++ b/clang/test/ExtractAPI/known_files_only.c
@@ -66,6 +66,10 @@ struct Foo { int a; };
         {
           "kind": "identifier",
           "spelling": "num"
+        },
+        {
+          "kind": "text",
+          "spelling": ";"
         }
       ],
       "identifier": {

diff  --git a/clang/test/ExtractAPI/language.c b/clang/test/ExtractAPI/language.c
index b9f69b272a44c3..3a434d475134f8 100644
--- a/clang/test/ExtractAPI/language.c
+++ b/clang/test/ExtractAPI/language.c
@@ -70,6 +70,10 @@ char objc;
         {
           "kind": "identifier",
           "spelling": "c"
+        },
+        {
+          "kind": "text",
+          "spelling": ";"
         }
       ],
       "identifier": {
@@ -150,6 +154,10 @@ char objc;
         {
           "kind": "identifier",
           "spelling": "objc"
+        },
+        {
+          "kind": "text",
+          "spelling": ";"
         }
       ],
       "identifier": {

diff  --git a/clang/test/ExtractAPI/objc_interface.m b/clang/test/ExtractAPI/objc_interface.m
index 3f53546866513c..02663a790683a2 100644
--- a/clang/test/ExtractAPI/objc_interface.m
+++ b/clang/test/ExtractAPI/objc_interface.m
@@ -579,6 +579,10 @@ - (char)getIvar;
         {
           "kind": "identifier",
           "spelling": "Ivar"
+        },
+        {
+          "kind": "text",
+          "spelling": ";"
         }
       ],
       "identifier": {

diff  --git a/clang/test/ExtractAPI/relative_include.m b/clang/test/ExtractAPI/relative_include.m
index a1483a36921d95..41830813ea4101 100644
--- a/clang/test/ExtractAPI/relative_include.m
+++ b/clang/test/ExtractAPI/relative_include.m
@@ -102,6 +102,10 @@
         {
           "kind": "identifier",
           "spelling": "MyInt"
+        },
+        {
+          "kind": "text",
+          "spelling": ";"
         }
       ],
       "identifier": {
@@ -153,6 +157,10 @@
         {
           "kind": "identifier",
           "spelling": "MyChar"
+        },
+        {
+          "kind": "text",
+          "spelling": ";"
         }
       ],
       "identifier": {

diff  --git a/clang/test/ExtractAPI/struct.c b/clang/test/ExtractAPI/struct.c
index cd6d25d8358213..a77293b9a53716 100644
--- a/clang/test/ExtractAPI/struct.c
+++ b/clang/test/ExtractAPI/struct.c
@@ -161,6 +161,10 @@ struct Color {
         {
           "kind": "identifier",
           "spelling": "Red"
+        },
+        {
+          "kind": "text",
+          "spelling": ";"
         }
       ],
       "identifier": {
@@ -213,6 +217,10 @@ struct Color {
         {
           "kind": "identifier",
           "spelling": "Green"
+        },
+        {
+          "kind": "text",
+          "spelling": ";"
         }
       ],
       "identifier": {
@@ -265,6 +273,10 @@ struct Color {
         {
           "kind": "identifier",
           "spelling": "Blue"
+        },
+        {
+          "kind": "text",
+          "spelling": ";"
         }
       ],
       "identifier": {
@@ -317,6 +329,10 @@ struct Color {
         {
           "kind": "identifier",
           "spelling": "Alpha"
+        },
+        {
+          "kind": "text",
+          "spelling": ";"
         }
       ],
       "docComment": {

diff  --git a/clang/test/ExtractAPI/typedef_struct_enum.c b/clang/test/ExtractAPI/typedef_struct_enum.c
index b3648aebf67d29..590dbd1ab31668 100644
--- a/clang/test/ExtractAPI/typedef_struct_enum.c
+++ b/clang/test/ExtractAPI/typedef_struct_enum.c
@@ -328,6 +328,10 @@ struct Foo {
         {
           "kind": "identifier",
           "spelling": "bar"
+        },
+        {
+          "kind": "text",
+          "spelling": ";"
         }
       ],
       "identifier": {

diff  --git a/clang/test/ExtractAPI/underscored.c b/clang/test/ExtractAPI/underscored.c
index e619849c8ceca5..7a8578a5a7c3b1 100644
--- a/clang/test/ExtractAPI/underscored.c
+++ b/clang/test/ExtractAPI/underscored.c
@@ -85,6 +85,10 @@ typedef _HiddenTypedef ExposedTypedefToHidden;
         {
           "kind": "identifier",
           "spelling": "exposed_global"
+        },
+        {
+          "kind": "text",
+          "spelling": ";"
         }
       ],
       "identifier": {
@@ -190,6 +194,10 @@ typedef _HiddenTypedef ExposedTypedefToHidden;
         {
           "kind": "identifier",
           "spelling": "a"
+        },
+        {
+          "kind": "text",
+          "spelling": ";"
         }
       ],
       "identifier": {


        


More information about the cfe-commits mailing list