[PATCH] D111419: [Demangle] Add support for D types back referencing

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 28 09:28:18 PST 2022


RKSimon added a comment.

This is the coverity dump (if you have access its at https://scan.coverity.com/projects/llvm):

  292const char *Demangler::parseTypeBackref(const char *Mangled) {
  293  // A type back reference always points to a letter.
  294  //    TypeBackRef:
  295  //        Q NumberBackRef
  296  //        ^
  297  const char *Backref;
  298
  299  // If we appear to be moving backwards through the mangle string, then
  300  // bail as this may be a recursive back reference.
     1. Condition Mangled - this->Str >= this->LastBackref, taking false branch.
  301  if (Mangled - Str >= LastBackref)
  302    return nullptr;
  303
     2. save: Saving non-local this->LastBackref in local SaveRefPos.
  304  int SaveRefPos = LastBackref;
     3. modify: Modifying non-local this->LastBackref.
  305  LastBackref = Mangled - Str;
  306
  307  // Get position of the back reference.
  308  Mangled = decodeBackref(Mangled, Backref);
  309
  310  // Can't decode back reference.
     4. Condition Backref == NULL, taking true branch.
  311  if (Backref == nullptr)
     CID 1469001 (#1 of 1): Failure to restore non-local value (MISSING_RESTORE)5. end_of_scope: Value of non-local this->LastBackref that was saved in SaveRefPos is not restored as it was along other paths.
  312    return nullptr;
  313
  314  // TODO: Add support for function type back references.
  315  Backref = parseType(Backref);
  316
     A1. restore_example: The original value of non-local this->LastBackref was restored here.
  317  LastBackref = SaveRefPos;
  318
  319  if (Backref == nullptr)
  320    return nullptr;
  321
  322  return Mangled;
  323}
  324


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111419



More information about the llvm-commits mailing list