llvm-project
1eea6381 - [clang][NFC] Use constructor instead of factory function in `CFGStmtMap` (#172530)

Commit
25 days ago
[clang][NFC] Use constructor instead of factory function in `CFGStmtMap` (#172530) `CFGStmtMap::Build` accepts pointers and returns a pointer to dynamically allocated memory. In the one location where the type is actually constructed, the pointers are guaranteed to be non-null. By accepting references to statically enforce this, we can remove the only way for the construction to fail. By making this change, we also allow our user to decide how they want to own the memory (either directly or indirectly). The user does not actually need dynamic allocation here, so we replace the `std::unique_ptr` with `std::optional`. This simplifies the code by requiring fewer checks, makes comments on what happens redundant because the code can obviously do only one thing, avoids potential bugs, and improves performance by allocating less.
Author
Parents
Loading