[clang] dc8a77d - [analyzer] ProjectMap: Do not serialize fields with default values
Valeriy Savchenko via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 16 03:31:27 PDT 2020
Author: Valeriy Savchenko
Date: 2020-06-16T13:30:01+03:00
New Revision: dc8a77de7db71dc52b0c75b3bb5437d9ae0ccc8c
URL: https://github.com/llvm/llvm-project/commit/dc8a77de7db71dc52b0c75b3bb5437d9ae0ccc8c
DIFF: https://github.com/llvm/llvm-project/commit/dc8a77de7db71dc52b0c75b3bb5437d9ae0ccc8c.diff
LOG: [analyzer] ProjectMap: Do not serialize fields with default values
Differential Revision: https://reviews.llvm.org/D81568
Added:
Modified:
clang/utils/analyzer/ProjectMap.py
Removed:
################################################################################
diff --git a/clang/utils/analyzer/ProjectMap.py b/clang/utils/analyzer/ProjectMap.py
index 5b15e405d26c..62b7e48fde9b 100644
--- a/clang/utils/analyzer/ProjectMap.py
+++ b/clang/utils/analyzer/ProjectMap.py
@@ -118,4 +118,17 @@ def _save(projects: List[ProjectInfo], path: str):
@staticmethod
def _convert_infos_to_dicts(projects: List[ProjectInfo]) -> List[JSON]:
- return [project._asdict() for project in projects]
+ return [ProjectMap._convert_info_to_dict(project)
+ for project in projects]
+
+ @staticmethod
+ def _convert_info_to_dict(project: ProjectInfo) -> JSON:
+ whole_dict = project._asdict()
+ defaults = project._field_defaults
+
+ # there is no need in serializing fields with default values
+ for field, default_value in defaults.items():
+ if whole_dict[field] == default_value:
+ del whole_dict[field]
+
+ return whole_dict
More information about the cfe-commits
mailing list