Skip to contentSkip to conversation

delay removing file scope

PATCH Applied Christopher Li 2 participants 2 messages Nov 30, 2006 – Dec 5, 2006 Sparse checker

lore
Share & tools
lore

Christopher Li

author maintainer
#0 lore raw

PATCH 1/1 delay removing file scope

Sparse only returns the used symbol. By the time it return the symbol, it already destroyed the file scope.

This patch preserve the file scope. The caller can examine the unused symbols. e.g. If I want to generate ctags base on sparse, it need those unused symbols.

lib.c +1 -2
Index: sparse/lib.c
===================================================================
@@ -661,9 +661,8 @@
 	/* Clear previous symbol list */
 	translation_unit_used_list = NULL;
 
-	start_file_scope();
+	new_file_scope();
 	res = sparse_file(filename);
-	end_file_scope();
 
 	/* Drop the tokens for this file after parsing */
 	clear_token_alloc();
scope.c +7 -0
Index: sparse/scope.c
===================================================================
@@ -96,6 +96,13 @@
 	end_scope(&file_scope);
 }
 
+void new_file_scope(void)
+{
+	if (file_scope != &builtin_scope)
+		end_file_scope();
+	start_file_scope();
+}
+
 void end_symbol_scope(void)
 {
 	end_scope(&block_scope);
scope.h +1 -0
Index: sparse/scope.h
===================================================================
@@ -28,6 +28,7 @@
 
 extern void start_file_scope(void);
 extern void end_file_scope(void);
+extern void new_file_scope(void);
 
 extern void start_symbol_scope(void);
 extern void end_symbol_scope(void);
#1 lore raw
Quoted 6 lines · Christopher Li

Sparse only returns the used symbol. By the time it return the symbol, it already destroyed the file scope.

This patch preserve the file scope. The caller can examine the unused symbols. e.g. If I want to generate ctags base on sparse, it need those unused symbols.

Merged, thanks. I look forward to seeing your sparse-based ctags generator; a ctags which actually *parses C* would provide significant improvements. :)

- Josh Triplett