[PATCH] D153376: Introducing llvm-cm: A Cost Model Tool
Ondrej Sykora via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 29 02:26:58 PDT 2023
ondrasej added inline comments.
================
Comment at: llvm/tools/llvm-cm/llvm-cm.cpp:70
+// Class for error handling.
+class ExitIf {
+ public:
----------------
mtrofin wrote:
> nit: `class ExitIf final`
>
> upon looking more closely at the usage pattern - @ondrasej , why raii and not just a function call? raii will exit at scope exit, which is undesirable (the goal is to exit right away). A function call "just works" because `exit(1)`, no?
As discussed offline yesterday: RAII is there to make the streaming operators after `ExitIf()` work.
With RAII, and with the intended use (`ExitIf(Cond) << "Some message";`), the following happens:
1. a temporary `ExitIf` instance is created and takes note of `Cond`,
2. all streaming operators are applied to the temporary (collecting the messages),
3. it's a temporary value (there's no variable name), so its scope is limited to the statement where it appears.
Basically, it processes the chain of `<<`, and then immediately exits.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D153376/new/
https://reviews.llvm.org/D153376
More information about the llvm-commits
mailing list