[PATCH 4/6] let -dD report macro defintions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 lib.c                                       |  5 +++++
 validation/empty-file                       |  0
 validation/preprocessor/dump-macros-empty.c |  7 +++++++
 validation/preprocessor/dump-macros-multi.c |  7 +++++++
 validation/preprocessor/dump-macros.c       | 18 ++++++++++++++++++
 5 files changed, 37 insertions(+)
 create mode 100644 validation/empty-file
 create mode 100644 validation/preprocessor/dump-macros-empty.c
 create mode 100644 validation/preprocessor/dump-macros-multi.c
 create mode 100644 validation/preprocessor/dump-macros.c

diff --git a/lib.c b/lib.c
index 991ead9bd..700681c01 100644
--- a/lib.c
+++ b/lib.c
@@ -1075,9 +1075,14 @@ void create_builtin_stream(void)
 
 static struct symbol_list *sparse_tokenstream(struct token *token)
 {
+	int builtin = token && !token->pos.stream;
+
 	// Preprocess the stream
 	token = preprocess(token);
 
+	if (dump_macro_defs && !builtin)
+		dump_macro_definitions();
+
 	if (preprocess_only) {
 		while (!eof_token(token)) {
 			int prec = 1;
diff --git a/validation/empty-file b/validation/empty-file
new file mode 100644
index 000000000..e69de29bb
diff --git a/validation/preprocessor/dump-macros-empty.c b/validation/preprocessor/dump-macros-empty.c
new file mode 100644
index 000000000..672c66c71
--- /dev/null
+++ b/validation/preprocessor/dump-macros-empty.c
@@ -0,0 +1,7 @@
+/*
+ * check-name: dump-macros with empty file
+ * check-command: sparse -E -dD empty-file
+ *
+ * check-output-ignore
+check-output-pattern-1-times: #define __CHECKER__ 1
+ */
diff --git a/validation/preprocessor/dump-macros-multi.c b/validation/preprocessor/dump-macros-multi.c
new file mode 100644
index 000000000..2f6e8d04f
--- /dev/null
+++ b/validation/preprocessor/dump-macros-multi.c
@@ -0,0 +1,7 @@
+/*
+ * check-name: dump-macros with multiple files
+ * check-command: sparse -E -dD empty-file $file
+ *
+ * check-output-ignore
+check-output-pattern-2-times: #define __CHECKER__ 1
+ */
diff --git a/validation/preprocessor/dump-macros.c b/validation/preprocessor/dump-macros.c
new file mode 100644
index 000000000..79f3de6a2
--- /dev/null
+++ b/validation/preprocessor/dump-macros.c
@@ -0,0 +1,18 @@
+#define ABC abc
+#undef ABC
+
+#define	DEF def
+#undef DEF
+#define DEF xyz
+
+#define NYDEF ydef
+/*
+ * check-name: dump-macros
+ * check-command: sparse -E -dD -DIJK=ijk -UNDEF -UNYDEF $file
+ *
+ * check-output-ignore
+check-output-pattern-1-times: #define __CHECKER__ 1
+check-output-contains: #define IJK ijk
+check-output-contains: #define DEF xyz
+check-output-contains: #define NYDEF ydef
+ */
-- 
2.12.0

--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux