summaryrefslogtreecommitdiff
path: root/libc/kernel/tools/clean_header.py
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2015-01-28 10:07:51 -0800
committerTao Bao <tbao@google.com>2015-02-06 14:48:41 -0800
commitd7db594b8d1dab36b711bd887a9dd21675c87243 (patch)
tree214b4e6e4510386ffc05c9a43dd3c153c6cf89a0 /libc/kernel/tools/clean_header.py
parent11829be3e1a9e9e2271ba64a78c327bde6e044eb (diff)
Switch kernel header parsing to python libclang
Replace the tokenizer in cpp.py with libclang. Bug: 18937958 Change-Id: I27630904c6d2849418cd5ca3d3c612ec3078686d
Diffstat (limited to 'libc/kernel/tools/clean_header.py')
-rwxr-xr-xlibc/kernel/tools/clean_header.py14
1 files changed, 4 insertions, 10 deletions
diff --git a/libc/kernel/tools/clean_header.py b/libc/kernel/tools/clean_header.py
index ebebe80f9..0e0ed7658 100755
--- a/libc/kernel/tools/clean_header.py
+++ b/libc/kernel/tools/clean_header.py
@@ -60,12 +60,7 @@
# using them anyway.
#
#
-# 3. Whitespace cleanup:
-#
-# The final pass removes any comments and empty lines from the final headers.
-#
-#
-# 4. Add a standard disclaimer:
+# 3. Add a standard disclaimer:
#
# The message:
#
@@ -141,8 +136,9 @@ def cleanupFile(path, original_path):
# now, let's parse the file
#
- blocks = cpp.BlockParser().parseFile(path)
- if not blocks:
+ parser = cpp.BlockParser()
+ blocks = parser.parseFile(path)
+ if not parser.parsed:
sys.stderr.write( "error: can't parse '%s'" % path )
sys.exit(1)
@@ -157,9 +153,7 @@ def cleanupFile(path, original_path):
blocks.optimizeIf01()
blocks.removeVarsAndFuncs( statics )
blocks.replaceTokens( kernel_token_replacements )
- blocks.removeComments()
blocks.removeMacroDefines( kernel_ignored_macros )
- blocks.removeWhiteSpace()
out = StringOutput()
out.write( kernel_disclaimer )