aboutsummaryrefslogtreecommitdiff
path: root/srcpos.h
diff options
context:
space:
mode:
authorJulia Lawall <Julia.Lawall@lip6.fr>2018-10-26 17:44:33 +0200
committerDavid Gibson <david@gibson.dropbear.id.au>2018-11-13 15:29:27 +1100
commitbaa1d2cf7894a32bf2f640ef40ebce561b2df565 (patch)
tree375454c91eef6ff64df067a1aef86896ae7dd09e /srcpos.h
parentff2ad38f6a5a87603c519096fd7066082c4c6f75 (diff)
downloaddtc-baa1d2cf7894a32bf2f640ef40ebce561b2df565.zip
dtc-baa1d2cf7894a32bf2f640ef40ebce561b2df565.tar.gz
dtc-baa1d2cf7894a32bf2f640ef40ebce561b2df565.tar.bz2
annotations: add positions
Extend the parser to record positions, in build_node, build_node_delete, and build_property. srcpos structures are added to the property and node types, and to the parameter lists of the above functions that construct these types. Nodes and properties that are created by the compiler rather than from parsing source code have NULL as the srcpos value. merge_nodes, defined in livetree.c, uses srcpos_extend to combine multiple positions, resulting in a list of positions. srcpos_extend is defined in srcpos.c. New elements are added at the end. The srcpos type, define in srcpos.h, is now a list structure with a next field. Another change to srcpos.c is to make srcpos_copy always do a full copy, including a copy of the file substructure. This is required because when dtc is used on the output of cpp, the successive detected file names overwrite the file name in the file structure. The next field does not need to be deep copied, because it is only updated in newly copied positions and the positions to which it points have also been copied. File names are only updated in uncopied position structures. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'srcpos.h')
-rw-r--r--srcpos.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/srcpos.h b/srcpos.h
index 9ded12a..d88e7cb 100644
--- a/srcpos.h
+++ b/srcpos.h
@@ -74,6 +74,7 @@ struct srcpos {
int last_line;
int last_column;
struct srcfile_state *file;
+ struct srcpos *next;
};
#define YYLTYPE struct srcpos
@@ -105,6 +106,8 @@ extern struct srcpos srcpos_empty;
extern void srcpos_update(struct srcpos *pos, const char *text, int len);
extern struct srcpos *srcpos_copy(struct srcpos *pos);
+extern struct srcpos *srcpos_extend(struct srcpos *new_srcpos,
+ struct srcpos *old_srcpos);
extern char *srcpos_string(struct srcpos *pos);
extern void PRINTF(3, 0) srcpos_verror(struct srcpos *pos, const char *prefix,