[PATCH] D149733: [clang][USR] Prevent crashes on incomplete FunctionDecls

Erich Keane via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 3 07:12:38 PDT 2023


erichkeane added a comment.

Hmm... So I don't see us being able to change how we create `FunctionDecl`s, the way we are doing it with a 'build up to the final thing' is about all we can do.  However, it should never escape its 'creation' functions without its type set.

IF I were to design this from scratch, I probably would have designed a `FunctionDeclBuilder` type thing that modeled a `FunctionDecl`, but asserted when being `finalized` (to get the `FunctionDecl` from it) if it wasn't complete.  However, we don't really have anything that models that in this codebase, and I'm not sure we really want to add something like that...

I don't recall the case of a Null type being valid for functions (perhaps Aaron does?  Or perhaps its an error condition?).  But otherwise, I would expect `FunctionDecl` to have a type as soon as it escapes the function responsible for 'making' it (that is, the one that calls the ::Create and is filling in everything).  If that patch added a path that doesn't set the return type, perhaps we should just fix that?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149733



More information about the cfe-commits mailing list