File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ pub(crate) mod attributes {
79
79
}
80
80
}
81
81
82
- pub trait CppSemanticAttributeCreator {
82
+ pub ( crate ) trait CppSemanticAttributeCreator {
83
83
fn do_add ( & mut self , ts : TokenStream ) ;
84
84
fn is_enabled ( & self ) -> bool ;
85
85
@@ -189,6 +189,29 @@ pub trait CppSemanticAttributeCreator {
189
189
layout( #sz, #align, #packed)
190
190
} )
191
191
}
192
+
193
+ fn location ( & mut self ,
194
+ location : Option < & crate :: clang:: SourceLocation > ,
195
+ ) {
196
+ if let Some ( location) = location {
197
+ let ( file, line, col, byte_offset) = location. location ( ) ;
198
+ let file = file. name ( ) ;
199
+ if let Some ( filename) = file {
200
+ self . add ( quote ! {
201
+ source_file( #filename)
202
+ } ) ;
203
+ self . add ( quote ! {
204
+ source_col( #col)
205
+ } ) ;
206
+ self . add ( quote ! {
207
+ source_line( #line)
208
+ } ) ;
209
+ self . add ( quote ! {
210
+ byte_offset( #byte_offset)
211
+ } ) ;
212
+ }
213
+ }
214
+ }
192
215
}
193
216
194
217
pub struct CppSemanticAttributeAdder < ' a > {
Original file line number Diff line number Diff line change @@ -973,6 +973,7 @@ impl CodeGenerator for Type {
973
973
if has_unused_template_args {
974
974
semantic_annotations. discards_template_param ( ) ;
975
975
}
976
+ semantic_annotations. location ( item. location ( ) ) ;
976
977
tokens. append_all ( semantic_annotations. result ( ) ) ;
977
978
978
979
let alias_style = if ctx. options ( ) . type_alias . matches ( & name) {
@@ -2229,6 +2230,7 @@ impl CodeGenerator for CompInfo {
2229
2230
if let Some ( layout) = layout {
2230
2231
semantic_annotations. layout ( & layout) ;
2231
2232
}
2233
+ semantic_annotations. location ( item. location ( ) ) ;
2232
2234
2233
2235
if ctx. options ( ) . rust_features ( ) . repr_align {
2234
2236
if let Some ( explicit) = explicit_align {
@@ -3293,6 +3295,7 @@ impl CodeGenerator for Enum {
3293
3295
}
3294
3296
}
3295
3297
semantic_annotations. visibility ( self . visibility ) ;
3298
+ semantic_annotations. location ( item. location ( ) ) ;
3296
3299
3297
3300
// TODO(emilio): Delegate this to the builders?
3298
3301
match variation {
@@ -4471,6 +4474,7 @@ impl CodeGenerator for Function {
4471
4474
}
4472
4475
4473
4476
semantic_annotations. visibility ( self . visibility ( ) ) ;
4477
+ semantic_annotations. location ( item. location ( ) ) ;
4474
4478
4475
4479
let abi = match signature. abi ( ctx, Some ( name) ) {
4476
4480
ClangAbi :: Known ( Abi :: ThisCall )
You can’t perform that action at this time.
0 commit comments