Switch kernel header parsing to python libclang

Replace the tokenizer in cpp.py with libclang.

Bug: 18937958
Change-Id: I27630904c6d2849418cd5ca3d3c612ec3078686d
diff --git a/libc/kernel/uapi/mtd/inftl-user.h b/libc/kernel/uapi/mtd/inftl-user.h
index 926de01..85ef0b5 100644
--- a/libc/kernel/uapi/mtd/inftl-user.h
+++ b/libc/kernel/uapi/mtd/inftl-user.h
@@ -24,72 +24,72 @@
 #define PERCENTUSED 98
 #define SECTORSIZE 512
 struct inftl_bci {
- __u8 ECCsig[6];
+  __u8 ECCsig[6];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __u8 Status;
- __u8 Status1;
+  __u8 Status;
+  __u8 Status1;
 } __attribute__((packed));
 struct inftl_unithead1 {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __u16 virtualUnitNo;
- __u16 prevUnitNo;
- __u8 ANAC;
- __u8 NACs;
+  __u16 virtualUnitNo;
+  __u16 prevUnitNo;
+  __u8 ANAC;
+  __u8 NACs;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __u8 parityPerField;
- __u8 discarded;
+  __u8 parityPerField;
+  __u8 discarded;
 } __attribute__((packed));
 struct inftl_unithead2 {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __u8 parityPerField;
- __u8 ANAC;
- __u16 prevUnitNo;
- __u16 virtualUnitNo;
+  __u8 parityPerField;
+  __u8 ANAC;
+  __u16 prevUnitNo;
+  __u16 virtualUnitNo;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __u8 NACs;
- __u8 discarded;
+  __u8 NACs;
+  __u8 discarded;
 } __attribute__((packed));
 struct inftl_unittail {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __u8 Reserved[4];
- __u16 EraseMark;
- __u16 EraseMark1;
+  __u8 Reserved[4];
+  __u16 EraseMark;
+  __u16 EraseMark1;
 } __attribute__((packed));
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 union inftl_uci {
- struct inftl_unithead1 a;
- struct inftl_unithead2 b;
- struct inftl_unittail c;
+  struct inftl_unithead1 a;
+  struct inftl_unithead2 b;
+  struct inftl_unittail c;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct inftl_oob {
- struct inftl_bci b;
- union inftl_uci u;
+  struct inftl_bci b;
+  union inftl_uci u;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct INFTLPartition {
- __u32 virtualUnits;
- __u32 firstUnit;
+  __u32 virtualUnits;
+  __u32 firstUnit;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __u32 lastUnit;
- __u32 flags;
- __u32 spareUnits;
- __u32 Reserved0;
+  __u32 lastUnit;
+  __u32 flags;
+  __u32 spareUnits;
+  __u32 Reserved0;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __u32 Reserved1;
+  __u32 Reserved1;
 } __attribute__((packed));
 struct INFTLMediaHeader {
- char bootRecordID[8];
+  char bootRecordID[8];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __u32 NoOfBootImageBlocks;
- __u32 NoOfBinaryPartitions;
- __u32 NoOfBDTLPartitions;
- __u32 BlockMultiplierBits;
+  __u32 NoOfBootImageBlocks;
+  __u32 NoOfBinaryPartitions;
+  __u32 NoOfBDTLPartitions;
+  __u32 BlockMultiplierBits;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __u32 FormatFlags;
- __u32 OsakVersion;
- __u32 PercentUsed;
- struct INFTLPartition Partitions[4];
+  __u32 FormatFlags;
+  __u32 OsakVersion;
+  __u32 PercentUsed;
+  struct INFTLPartition Partitions[4];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 } __attribute__((packed));
 #define INFTL_BINARY 0x20000000
diff --git a/libc/kernel/uapi/mtd/mtd-abi.h b/libc/kernel/uapi/mtd/mtd-abi.h
index 3641554..4fe1973 100644
--- a/libc/kernel/uapi/mtd/mtd-abi.h
+++ b/libc/kernel/uapi/mtd/mtd-abi.h
@@ -21,44 +21,44 @@
 #include <linux/types.h>
 struct erase_info_user {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __u32 start;
- __u32 length;
+  __u32 start;
+  __u32 length;
 };
 struct erase_info_user64 {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __u64 start;
- __u64 length;
+  __u64 start;
+  __u64 length;
 };
 struct mtd_oob_buf {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __u32 start;
- __u32 length;
- unsigned char __user *ptr;
+  __u32 start;
+  __u32 length;
+  unsigned char __user * ptr;
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct mtd_oob_buf64 {
- __u64 start;
- __u32 pad;
- __u32 length;
+  __u64 start;
+  __u32 pad;
+  __u32 length;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __u64 usr_ptr;
+  __u64 usr_ptr;
 };
 enum {
- MTD_OPS_PLACE_OOB = 0,
+  MTD_OPS_PLACE_OOB = 0,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- MTD_OPS_AUTO_OOB = 1,
- MTD_OPS_RAW = 2,
+  MTD_OPS_AUTO_OOB = 1,
+  MTD_OPS_RAW = 2,
 };
 struct mtd_write_req {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __u64 start;
- __u64 len;
- __u64 ooblen;
- __u64 usr_data;
+  __u64 start;
+  __u64 len;
+  __u64 ooblen;
+  __u64 usr_data;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __u64 usr_oob;
- __u8 mode;
- __u8 padding[7];
+  __u64 usr_oob;
+  __u8 mode;
+  __u8 padding[7];
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MTD_ABSENT 0
@@ -93,28 +93,28 @@
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MTD_OTP_USER 2
 struct mtd_info_user {
- __u8 type;
- __u32 flags;
+  __u8 type;
+  __u32 flags;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __u32 size;
- __u32 erasesize;
- __u32 writesize;
- __u32 oobsize;
+  __u32 size;
+  __u32 erasesize;
+  __u32 writesize;
+  __u32 oobsize;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __u64 padding;
+  __u64 padding;
 };
 struct region_info_user {
- __u32 offset;
+  __u32 offset;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __u32 erasesize;
- __u32 numblocks;
- __u32 regionindex;
+  __u32 erasesize;
+  __u32 numblocks;
+  __u32 regionindex;
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct otp_info {
- __u32 start;
- __u32 length;
- __u32 locked;
+  __u32 start;
+  __u32 length;
+  __u32 locked;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 #define MEMGETINFO _IOR('M', 1, struct mtd_info_user)
@@ -147,40 +147,40 @@
 #define MEMWRITE _IOWR('M', 24, struct mtd_write_req)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct nand_oobinfo {
- __u32 useecc;
- __u32 eccbytes;
- __u32 oobfree[8][2];
+  __u32 useecc;
+  __u32 eccbytes;
+  __u32 oobfree[8][2];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __u32 eccpos[32];
+  __u32 eccpos[32];
 };
 struct nand_oobfree {
- __u32 offset;
+  __u32 offset;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __u32 length;
+  __u32 length;
 };
 #define MTD_MAX_OOBFREE_ENTRIES 8
 #define MTD_MAX_ECCPOS_ENTRIES 64
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct nand_ecclayout_user {
- __u32 eccbytes;
- __u32 eccpos[MTD_MAX_ECCPOS_ENTRIES];
- __u32 oobavail;
+  __u32 eccbytes;
+  __u32 eccpos[MTD_MAX_ECCPOS_ENTRIES];
+  __u32 oobavail;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- struct nand_oobfree oobfree[MTD_MAX_OOBFREE_ENTRIES];
+  struct nand_oobfree oobfree[MTD_MAX_OOBFREE_ENTRIES];
 };
 struct mtd_ecc_stats {
- __u32 corrected;
+  __u32 corrected;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __u32 failed;
- __u32 badblocks;
- __u32 bbtblocks;
+  __u32 failed;
+  __u32 badblocks;
+  __u32 bbtblocks;
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 enum mtd_file_modes {
- MTD_FILE_MODE_NORMAL = MTD_OTP_OFF,
- MTD_FILE_MODE_OTP_FACTORY = MTD_OTP_FACTORY,
- MTD_FILE_MODE_OTP_USER = MTD_OTP_USER,
+  MTD_FILE_MODE_NORMAL = MTD_OTP_OFF,
+  MTD_FILE_MODE_OTP_FACTORY = MTD_OTP_FACTORY,
+  MTD_FILE_MODE_OTP_USER = MTD_OTP_USER,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- MTD_FILE_MODE_RAW,
+  MTD_FILE_MODE_RAW,
 };
 #endif
diff --git a/libc/kernel/uapi/mtd/nftl-user.h b/libc/kernel/uapi/mtd/nftl-user.h
index dc7b896..98a7e8a 100644
--- a/libc/kernel/uapi/mtd/nftl-user.h
+++ b/libc/kernel/uapi/mtd/nftl-user.h
@@ -21,49 +21,49 @@
 #include <linux/types.h>
 struct nftl_bci {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- unsigned char ECCSig[6];
- __u8 Status;
- __u8 Status1;
-}__attribute__((packed));
+  unsigned char ECCSig[6];
+  __u8 Status;
+  __u8 Status1;
+} __attribute__((packed));
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct nftl_uci0 {
- __u16 VirtUnitNum;
- __u16 ReplUnitNum;
- __u16 SpareVirtUnitNum;
+  __u16 VirtUnitNum;
+  __u16 ReplUnitNum;
+  __u16 SpareVirtUnitNum;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __u16 SpareReplUnitNum;
+  __u16 SpareReplUnitNum;
 } __attribute__((packed));
 struct nftl_uci1 {
- __u32 WearInfo;
+  __u32 WearInfo;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __u16 EraseMark;
- __u16 EraseMark1;
+  __u16 EraseMark;
+  __u16 EraseMark1;
 } __attribute__((packed));
 struct nftl_uci2 {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __u16 FoldMark;
- __u16 FoldMark1;
- __u32 unused;
+  __u16 FoldMark;
+  __u16 FoldMark1;
+  __u32 unused;
 } __attribute__((packed));
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 union nftl_uci {
- struct nftl_uci0 a;
- struct nftl_uci1 b;
- struct nftl_uci2 c;
+  struct nftl_uci0 a;
+  struct nftl_uci1 b;
+  struct nftl_uci2 c;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct nftl_oob {
- struct nftl_bci b;
- union nftl_uci u;
+  struct nftl_bci b;
+  union nftl_uci u;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct NFTLMediaHeader {
- char DataOrgID[6];
- __u16 NumEraseUnits;
+  char DataOrgID[6];
+  __u16 NumEraseUnits;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __u16 FirstPhysicalEUN;
- __u32 FormattedSize;
- unsigned char UnitSizeFactor;
+  __u16 FirstPhysicalEUN;
+  __u32 FormattedSize;
+  unsigned char UnitSizeFactor;
 } __attribute__((packed));
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MAX_ERASE_ZONES (8192 - 512)
diff --git a/libc/kernel/uapi/mtd/ubi-user.h b/libc/kernel/uapi/mtd/ubi-user.h
index dbe1279..e055172 100644
--- a/libc/kernel/uapi/mtd/ubi-user.h
+++ b/libc/kernel/uapi/mtd/ubi-user.h
@@ -19,9 +19,9 @@
 #ifndef __UBI_USER_H__
 #define __UBI_USER_H__
 #include <linux/types.h>
-#define UBI_VOL_NUM_AUTO (-1)
+#define UBI_VOL_NUM_AUTO (- 1)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
-#define UBI_DEV_NUM_AUTO (-1)
+#define UBI_DEV_NUM_AUTO (- 1)
 #define UBI_MAX_VOLUME_NAME 127
 #define UBI_IOC_MAGIC 'o'
 #define UBI_IOCMKVOL _IOW(UBI_IOC_MAGIC, 0, struct ubi_mkvol_req)
@@ -42,82 +42,82 @@
 #define UBI_IOCEBUNMAP _IOW(UBI_VOL_IOC_MAGIC, 4, __s32)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define UBI_IOCEBISMAP _IOR(UBI_VOL_IOC_MAGIC, 5, __s32)
-#define UBI_IOCSETVOLPROP _IOW(UBI_VOL_IOC_MAGIC, 6,   struct ubi_set_vol_prop_req)
+#define UBI_IOCSETVOLPROP _IOW(UBI_VOL_IOC_MAGIC, 6, struct ubi_set_vol_prop_req)
 #define UBI_IOCVOLCRBLK _IOW(UBI_VOL_IOC_MAGIC, 7, struct ubi_blkcreate_req)
 #define UBI_IOCVOLRMBLK _IO(UBI_VOL_IOC_MAGIC, 8)
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 #define MAX_UBI_MTD_NAME_LEN 127
 #define UBI_MAX_RNVOL 32
 enum {
- UBI_DYNAMIC_VOLUME = 3,
+  UBI_DYNAMIC_VOLUME = 3,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- UBI_STATIC_VOLUME = 4,
+  UBI_STATIC_VOLUME = 4,
 };
 enum {
- UBI_VOL_PROP_DIRECT_WRITE = 1,
+  UBI_VOL_PROP_DIRECT_WRITE = 1,
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 };
 struct ubi_attach_req {
- __s32 ubi_num;
- __s32 mtd_num;
+  __s32 ubi_num;
+  __s32 mtd_num;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __s32 vid_hdr_offset;
- __s16 max_beb_per1024;
- __s8 padding[10];
+  __s32 vid_hdr_offset;
+  __s16 max_beb_per1024;
+  __s8 padding[10];
 };
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ubi_mkvol_req {
- __s32 vol_id;
- __s32 alignment;
- __s64 bytes;
+  __s32 vol_id;
+  __s32 alignment;
+  __s64 bytes;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __s8 vol_type;
- __s8 padding1;
- __s16 name_len;
- __s8 padding2[4];
+  __s8 vol_type;
+  __s8 padding1;
+  __s16 name_len;
+  __s8 padding2[4];
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- char name[UBI_MAX_VOLUME_NAME + 1];
+  char name[UBI_MAX_VOLUME_NAME + 1];
 } __packed;
 struct ubi_rsvol_req {
- __s64 bytes;
+  __s64 bytes;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __s32 vol_id;
+  __s32 vol_id;
 } __packed;
 struct ubi_rnvol_req {
- __s32 count;
+  __s32 count;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __s8 padding1[12];
- struct {
- __s32 vol_id;
- __s16 name_len;
+  __s8 padding1[12];
+  struct {
+    __s32 vol_id;
+    __s16 name_len;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __s8 padding2[2];
- char name[UBI_MAX_VOLUME_NAME + 1];
- } ents[UBI_MAX_RNVOL];
+    __s8 padding2[2];
+    char name[UBI_MAX_VOLUME_NAME + 1];
+  } ents[UBI_MAX_RNVOL];
 } __packed;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ubi_leb_change_req {
- __s32 lnum;
- __s32 bytes;
- __s8 dtype;
+  __s32 lnum;
+  __s32 bytes;
+  __s8 dtype;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __s8 padding[7];
+  __s8 padding[7];
 } __packed;
 struct ubi_map_req {
- __s32 lnum;
+  __s32 lnum;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __s8 dtype;
- __s8 padding[3];
+  __s8 dtype;
+  __s8 padding[3];
 } __packed;
 struct ubi_set_vol_prop_req {
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
- __u8 property;
- __u8 padding[7];
- __u64 value;
+  __u8 property;
+  __u8 padding[7];
+  __u64 value;
 } __packed;
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
 struct ubi_blkcreate_req {
- __s8 padding[128];
+  __s8 padding[128];
 } __packed;
 #endif
 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */