Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions llvm/utils/merge-json.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import argparse
import json
import sys
import os


def main():
Expand All @@ -35,6 +36,14 @@ def main():
except (IOError, json.JSONDecodeError) as e:
continue

# LLVM passes this argument by default but it is not supported by clang,
# causing annoying errors in the generated compile_commands.json file.
# Remove it here before we deduplicate the entries.
for entry in merged_data:
if isinstance(entry, dict) and "command" in entry:
if os.path.basename(entry["command"].partition(" ")[0]) != "g++":
entry["command"] = entry["command"].replace("-fno-lifetime-dse ", "")

# Deduplicate by converting each entry to a tuple of sorted key-value pairs
unique_data = list({json.dumps(entry, sort_keys=True) for entry in merged_data})
unique_data = [json.loads(entry) for entry in unique_data]
Expand Down