[PATCH] D112075: Use safe yaml load_all

Qiu Chaofan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 4 02:31:37 PDT 2021


qiucf added a comment.

The YAML test files may contain some tags, here including `!Passed` `!Missed` `!Failure` `!AnalysisAliasing` `!AnalysisFPCommute` `!Analysis`.

I think it's the reason that the safe loader can't find appropriate constructor for these tags.

  --- a/llvm/tools/opt-viewer/optrecord.py
  +++ b/llvm/tools/opt-viewer/optrecord.py
  @@ -235,6 +235,7 @@ class Remark(yaml.YAMLObject):
  
  
   class Analysis(Remark):
  +    yaml_loader = yaml.SafeLoader
       yaml_tag = '!Analysis'
  
       @property
  @@ -243,14 +244,17 @@ class Analysis(Remark):
  
  
   class AnalysisFPCommute(Analysis):
  +    yaml_loader = yaml.SafeLoader
       yaml_tag = '!AnalysisFPCommute'
  
  
   class AnalysisAliasing(Analysis):
  +    yaml_loader = yaml.SafeLoader
       yaml_tag = '!AnalysisAliasing'
  
  
   class Passed(Remark):
  +    yaml_loader = yaml.SafeLoader
       yaml_tag = '!Passed'
  
       @property
  @@ -259,6 +263,7 @@ class Passed(Remark):
  
  
   class Missed(Remark):
  +    yaml_loader = yaml.SafeLoader
       yaml_tag = '!Missed'
  
       @property
  @@ -266,6 +271,7 @@ class Missed(Remark):
           return "red"
  
   class Failure(Missed):
  +    yaml_loader = yaml.SafeLoader
       yaml_tag = '!Failure'
  
   def get_remarks(input_file, filter_=None):
  @@ -274,7 +280,7 @@ def get_remarks(input_file, filter_=None):
       file_remarks = defaultdict(functools.partial(defaultdict, list))
  
       with io.open(input_file, encoding = 'utf-8') as f:
  -        docs = yaml.load_all(f, Loader=Loader)
  +        docs = yaml.safe_load_all(f)
  
           filter_e = None
           if filter_:

And I think this isn't related to AIX. I found the same issue on Linux. Try `llvm/test/tools/opt-viewer/Inputs/suppress/s.opt.yaml`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112075/new/

https://reviews.llvm.org/D112075



More information about the llvm-commits mailing list