[PATCH] D51003: Allow demangler's node allocator to fail, and bail out of the entire demangling process when it does. Use this to support a "lookup" query for the mangling canonicalizer that does not create new nodes.

Richard Smith - zygoloid via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 22 17:30:25 PDT 2018


rsmith added a comment.

In https://reviews.llvm.org/D51003#1208827, @erik.pilkington wrote:

> It seems like we would need to add a lot more nullptr checks in order to really support this then this patch does. One potential workaround is to add a subclass of Node in ItaniumManglingCanonicalizer.cpp that serves as the canonical 'sentinel' node. We could just hand that out whenever we would otherwise allocate anything, and ignore the results of parse() if we ever did. I think that would probably maybe work.


This patch fixes up every place where we create a node and do not immediately return it; all parsing functions returning a `Node*` are already assumed to potentially fail, so their callers already perform a null check. So I think this is the full extent of what we need to do to support this.

(If we wanted to actually make the demangler be able to run with a fixed size buffer, there are two other things we need to address: NodeArray allocation and the explicit malloc/free calls made by PODSmallVector. Those both seem feasible, if we ever want to actually go there.)


Repository:
  rL LLVM

https://reviews.llvm.org/D51003





More information about the llvm-commits mailing list