[PATCH] D141855: [include-mapping] Parse zombie_names.html into a removed symbols map.

Viktoriia Bakalova via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 16 08:18:45 PST 2023


VitaNuo created this revision.
VitaNuo added a reviewer: hokein.
Herald added a project: All.
VitaNuo requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141855

Files:
  clang/tools/include-mapping/gen_std.py


Index: clang/tools/include-mapping/gen_std.py
===================================================================
--- clang/tools/include-mapping/gen_std.py
+++ clang/tools/include-mapping/gen_std.py
@@ -64,6 +64,14 @@
                       default='cpp',
                       help='Generate c or cpp symbols',
                       required=True)
+  parser.add_argument('-output',
+                      default='SymbolMap.inc',
+                      help='path to the output file for symbol map',
+                      required=True)
+  parser.add_argument('-removedoutput',
+                      default='RemovedSymbolMap.inc',
+                      help='path to the output file for removed symbols map',
+                      required=False)                    
   return parser.parse_args()
 
 
@@ -87,6 +95,9 @@
       (symbol_index_root, "regex_constants.html", "std::regex_constants::"),
       (symbol_index_root, "this_thread.html", "std::this_thread::"),
     ]
+    removed_symbols = cppreference_parser.GetSymbols(
+      [(symbol_index_root, "zombie_names.html", "std::")])
+    WriteSymbols(args.language, removed_symbols, args.removedoutput, page_root)
   elif args.language == 'c':
     page_root = os.path.join(args.cppreference, "en", "c")
     symbol_index_root = page_root
@@ -96,24 +107,28 @@
     exit("Path %s doesn't exist!" % symbol_index_root)
 
   symbols = cppreference_parser.GetSymbols(parse_pages)
+  WriteSymbols(args.language, symbols, args.output, page_root)
 
+def WriteSymbols(language, symbols, path, page_root):
   # We don't have version information from the unzipped offline HTML files.
   # so we use the modified time of the symbol_index.html as the version.
   index_page_path = os.path.join(page_root, "index.html")
   cppreference_modified_date = datetime.datetime.fromtimestamp(
     os.stat(index_page_path).st_mtime).strftime('%Y-%m-%d')
-  print(CODE_PREFIX % (args.language.upper(), cppreference_modified_date))
-  for symbol in symbols:
-    if len(symbol.headers) == 1:
-      # SYMBOL(unqualified_name, namespace, header)
-      print("SYMBOL(%s, %s, %s)" % (symbol.name, symbol.namespace,
-                                    symbol.headers[0]))
-    elif len(symbol.headers) == 0:
-      sys.stderr.write("No header found for symbol %s\n" % symbol.name)
-    else:
-      # FIXME: support symbols with multiple headers (e.g. std::move).
-      sys.stderr.write("Ambiguous header for symbol %s: %s\n" % (
-          symbol.name, ', '.join(symbol.headers)))
+  with open(path, "w") as f:  
+    f.write(CODE_PREFIX % (language.upper(), cppreference_modified_date))
+    f.write("\n")
+    for symbol in symbols:
+      if len(symbol.headers) == 1:
+        # SYMBOL(unqualified_name, namespace, header)
+        f.write("SYMBOL(%s, %s, %s)\n" % (symbol.name, symbol.namespace,
+                                      symbol.headers[0]))
+      elif len(symbol.headers) == 0:
+        sys.stderr.write("No header found for symbol %s\n" % symbol.name)
+      else:
+        # FIXME: support symbols with multiple headers (e.g. std::move).
+        sys.stderr.write("Ambiguous header for symbol %s: %s\n" % (
+            symbol.name, ', '.join(symbol.headers)))
 
 
 if __name__ == '__main__':


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141855.489566.patch
Type: text/x-patch
Size: 3255 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230116/933b82ec/attachment.bin>


More information about the cfe-commits mailing list