File tree Expand file tree Collapse file tree 5 files changed +80
-21
lines changed
Expand file tree Collapse file tree 5 files changed +80
-21
lines changed Original file line number Diff line number Diff line change 1+ def-source source0.c function_with_quotes_in_type yes
2+
3+ function function_with_quotes_in_type is defined in source0.c:
4+
5+ 35: void function_with_quotes_in_type(void __attribute__((btf_type_tag("user"))) *)
6+ 36: {
7+ 37: }
Original file line number Diff line number Diff line change @@ -5,5 +5,6 @@ file source0.c defines the following entities:
55function close
66function func_accepting_a_struct
77function function_with_comment_in_header
8+ function function_with_quotes_in_type
89function open
910struct struct_in_c_file
Original file line number Diff line number Diff line change @@ -31,3 +31,7 @@ int func_accepting_a_struct(struct some_struct* p)
3131 return ((some_struct_t * )p )-> x +
3232 ((union some_union * )p )-> x ;
3333}
34+
35+ void function_with_quotes_in_type (void __attribute__((btf_type_tag ("user" ))) * )
36+ {
37+ }
Original file line number Diff line number Diff line change 11{
22 "definitions" : [
3- {
4- "name" : " some_enum" ,
5- "kind" : " enum" ,
6- "body" : {
7- "file" : " source0.h" ,
8- "start_line" : 45 ,
9- "end_line" : 48
10- },
11- "comment" : {}
12- },
133 {
144 "name" : " close" ,
155 "type" : " int ()" ,
8979 }
9080 ]
9181 },
82+ {
83+ "name" : " function_with_quotes_in_type" ,
84+ "type" : " void (void __attribute__((btf_type_tag(\" user\" )))*)" ,
85+ "kind" : " function" ,
86+ "body" : {
87+ "file" : " source0.c" ,
88+ "start_line" : 35 ,
89+ "end_line" : 37
90+ },
91+ "comment" : {}
92+ },
9293 {
9394 "name" : " open" ,
9495 "type" : " int ()" ,
148149 },
149150 "comment" : {}
150151 },
152+ {
153+ "name" : " some_union" ,
154+ "kind" : " union" ,
155+ "body" : {
156+ "file" : " source0.h" ,
157+ "start_line" : 40 ,
158+ "end_line" : 43
159+ },
160+ "comment" : {}
161+ },
162+ {
163+ "name" : " some_enum" ,
164+ "kind" : " enum" ,
165+ "body" : {
166+ "file" : " source0.h" ,
167+ "start_line" : 45 ,
168+ "end_line" : 48
169+ },
170+ "comment" : {}
171+ },
151172 {
152173 "name" : " another_struct_t" ,
153174 "kind" : " typedef" ,
187208 "end_line" : 34
188209 },
189210 "comment" : {}
190- },
191- {
192- "name" : " some_union" ,
193- "kind" : " union" ,
194- "body" : {
195- "file" : " source0.h" ,
196- "start_line" : 40 ,
197- "end_line" : 43
198- },
199- "comment" : {}
200211 }
201212 ]
202213}
Original file line number Diff line number Diff line change @@ -52,11 +52,47 @@ class JSONPrinter {
5252 Scope Top;
5353};
5454
55+ inline void print (JSONPrinter& Printer, const char * V) {
56+ printf (" \" " );
57+ if (V) {
58+ for (; *V; ++V) {
59+ switch (*V) {
60+ case ' "' :
61+ printf (" \\\" " );
62+ break ;
63+ case ' \\ ' :
64+ printf (" \\\\ " );
65+ break ;
66+ case ' \b ' :
67+ printf (" \\ b" );
68+ break ;
69+ case ' \f ' :
70+ printf (" \\ f" );
71+ break ;
72+ case ' \n ' :
73+ printf (" \\ n" );
74+ break ;
75+ case ' \r ' :
76+ printf (" \\ r" );
77+ break ;
78+ case ' \t ' :
79+ printf (" \\ t" );
80+ break ;
81+ default :
82+ if ((unsigned char )*V < 0x20 )
83+ printf (" \\ u%04x" , (unsigned char )*V);
84+ else
85+ printf (" %c" , *V);
86+ }
87+ }
88+ }
89+ printf (" \" " );
90+ }
91+
5592inline void print (JSONPrinter& Printer, int V) { printf (" %d" , V); }
5693inline void print (JSONPrinter& Printer, unsigned V) { printf (" %u" , V); }
5794inline void print (JSONPrinter& Printer, int64_t V) { printf (" %ld" , V); }
5895inline void print (JSONPrinter& Printer, bool V) { printf (" %s" , V ? " true" : " false" ); }
59- inline void print (JSONPrinter& Printer, const char * V) { printf (" \" %s\" " , V ? V : " " ); }
6096inline void print (JSONPrinter& Printer, const std::string& V) { print (Printer, V.c_str ()); }
6197
6298template <typename E> void print (JSONPrinter& Printer, const std::unique_ptr<E>& V) {
You can’t perform that action at this time.
0 commit comments