summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Nemet <anemet@apple.com>2017-03-02 17:00:53 +0000
committerAdam Nemet <anemet@apple.com>2017-03-02 17:00:53 +0000
commita8b692a8e113e8bc5e7b8cb9a4958d895232b743 (patch)
tree1e0e94d66f9f58a266eb67872d333ef33be650b3
parent2057c42517184847bc0763ecb4adcc9c0dd1c913 (diff)
downloadbcm5719-llvm-a8b692a8e113e8bc5e7b8cb9a4958d895232b743.tar.gz
bcm5719-llvm-a8b692a8e113e8bc5e7b8cb9a4958d895232b743.zip
[opt-viewer] Don't use __getattr__ for missing YAML attributes
__getattr__ does not work well with debugging. If the attribute function has a run-time error, a missing attribute is reported instead. llvm-svn: 296765
-rw-r--r--llvm/utils/opt-viewer/optrecord.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/llvm/utils/opt-viewer/optrecord.py b/llvm/utils/opt-viewer/optrecord.py
index 630d417dd74..4a5733dae7d 100644
--- a/llvm/utils/opt-viewer/optrecord.py
+++ b/llvm/utils/opt-viewer/optrecord.py
@@ -40,11 +40,11 @@ class Remark(yaml.YAMLObject):
# Work-around for http://pyyaml.org/ticket/154.
yaml_loader = Loader
- def __getattr__(self, name):
- # If hotness is missing, assume 0
- if name == 'Hotness':
- return 0
- raise AttributeError(name)
+ def initmissing(self):
+ if not hasattr(self, 'Hotness'):
+ self.Hotness = 0
+ if not hasattr(self, 'Args'):
+ self.Args = []
@property
def File(self):
@@ -146,6 +146,7 @@ def get_remarks(input_file):
with open(input_file) as f:
docs = yaml.load_all(f, Loader=Loader)
for remark in docs:
+ remark.initmissing()
# Avoid remarks withoug debug location or if they are duplicated
if not hasattr(remark, 'DebugLoc') or remark.key in all_remarks:
continue
OpenPOWER on IntegriCloud